I have a PostGIS database with a layer of 60k polygons, some of them erroneous. These erroneous polygons are extremely narrow, long shaped. Maybe I can best describe them as 'Needle' shaped polygons. I need to detect these 'needle' polygons with an SQL query.
Can I do this with a ratio calculation on the edges or is there a more efficient and robust SQL function to do this?
At present I used the LongestLine function with a default setting for the length, which does not seem to be 100% robust:
SELECT t.identifier, t.country, t.id_planting_site, ST_AsText(ST_LongestLine(pol, pol)) AS llinewkt,
--ST_MaxDistance(pol, pol) AS max_dist,
ST_Length(ST_LongestLine(pol, pol), true) AS lenll_m,
ST_AsText(ST_ShortestLine(pol, pol)) AS slinewkt,
--ST_MaxDistance(pol, pol) AS min_dist,
ST_Length(ST_ShortestLine(pol, pol), true) AS lenls_m
FROM registration_areas AS t
where
ST_Length(ST_LongestLine(pol, pol), true) > 10000
order by t.country
I also tried the MinimumBoundingCircle:
ST_Area(geom)/(ST_Area(ST_MinimumBoundingCircle(geom))
However, as many of these 'needle' polygons also have self-intersections, this solution does not seem to be robust neither.
ST_MaximumInscribedCircleto find polygons with a small "width". – dr_jts Dec 01 '23 at 19:29