Changes between Initial Version and Version 1 of UsersWikiExamplesSpikeAnalyzer


Ignore:
Timestamp:
Dec 3, 2009, 6:15:38 AM (14 years ago)
Author:
nik1166
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiExamplesSpikeAnalyzer

    v1 v1  
     1= Spike-Analyzer =
     2
     3Function for determining spikes in polygons
     4
     5This function tries to determine spikes by using the buffer-function. A small negative buffer removes spikes and decreases the perimeter of the polygon significantly. It should be used either as a preselection for the spike-remover to increase performance or stand-alone for simple analyze purposes. Default values are (-0.02 [meters], 1) and lead to useful results.
     6
     7= Function =
     8{{{
     9
     10-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     11--
     12-- $Id: spike_analyzer.sql 2009-12-01 08:00 Andreas Schmidt(andreas.schmidtATiz.bwl.de)  &  Nils Krüger(nils.kruegerATiz.bwl.de) $
     13--
     14-- spike_analyzer - helps to find spikes in polygons
     15-- http://www.izlbw.de/
     16-- Copyright 2009 Informatikzentrum Landesverwaltung Baden-Württemberg (IZLBW) Germany
     17-- Version 1.0
     18--
     19-- This is free software; you can redistribute and/or modify it under
     20-- the terms of the GNU General Public Licence. See the COPYING file.
     21-- This software is without any warrenty and you use it at your own risk
     22-- 
     23-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     24
     25
     26create or replace function spike_analyzer(geom geometry, testbuffer float, spikeindex float)
     27returns boolean as
     28$$
     29
     30select case when st_geometrytype($1) in ('ST_Polygon', 'ST_MultiPolygon') then
     31        (select case when
     32                (select max(index) from
     33                        (select (case when (st_perimeter(geom) > 0 and st_area(geom) > 0 and st_perimeter(st_buffer(geom, $2)) > 0)
     34                                then st_area(st_buffer(geom, $2)) / st_area(geom) / (st_perimeter(st_buffer(geom, $2))/st_perimeter(geom))
     35                                else 0
     36                        end) as index from
     37                                (
     38                                        select (st_dumprings($1)).geom
     39                                ) as sub
     40                        ) as max
     41                ) > $3
     42                then true
     43                else false
     44        end)
     45        else false
     46end;
     47
     48$$
     49language 'sql'
     50immutable
     51;
     52
     53comment on function public.tet_spike_analyzer(geometry, float, float) is 'Function to detect spikes in polygon-features, default values are (-0.02 [meters], 1) and lead to useful results';
     54
     55}}}