Spike-Analyzer
Function for determining spikes in polygons
This 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.
Function
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- -- $Id: spike_analyzer.sql 2009-12-01 08:00 Andreas Schmidt(andreas.schmidtATiz.bwl.de) & Nils Krüger(nils.kruegerATiz.bwl.de) $ -- -- spike_analyzer - helps to find spikes in polygons -- http://www.izlbw.de/ -- Copyright 2009 Informatikzentrum Landesverwaltung Baden-Württemberg (IZLBW) Germany -- Version 1.0 -- -- This is free software; you can redistribute and/or modify it under -- the terms of the GNU General Public Licence. See the COPYING file. -- This software is without any warrenty and you use it at your own risk -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - create or replace function spike_analyzer(geom geometry, testbuffer float, spikeindex float) returns boolean as $$ select case when st_geometrytype($1) in ('ST_Polygon', 'ST_MultiPolygon') then (select case when (select max(index) from (select (case when (st_perimeter(geom) > 0 and st_area(geom) > 0 and st_perimeter(st_buffer(geom, $2)) > 0) then st_area(st_buffer(geom, $2)) / st_area(geom) / (st_perimeter(st_buffer(geom, $2))/st_perimeter(geom)) else 0 end) as index from ( select (st_dumprings($1)).geom ) as sub ) as max ) > $3 then true else false end) else false end; $$ language 'sql' immutable ; comment on function 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';
Last modified
15 years ago
Last modified on 12/08/09 11:39:49
Attachments (1)
-
spike_example.png
(5.0 KB
) - added by 15 years ago.
SpikeExample
Download all attachments as: .zip
Note:
See TracWiki
for help on using the wiki.