1

I have a polygons for lakes from different sources. Some polygons are more detailed in one source, and some are more detailed in the other.

Given two polygon of the same lake, I want to find which of these two polygons captures the lake shoreline more accurately. In the below example you can see the second one captures the shoreline boundaries better than the first one.

Rideau Lake Polygon 1

Rideau Lake Polygon 2

  • 2
    The distinguishing characteristic between your two examples seems to be vertex density. Is a greater vertex density always "better" ? If so, it's not hard to write a query for that. – dbaston Sep 29 '17 at 15:16
  • As a remark, the second one s missing the holes, so the top one is better for some purposes. Based on the number of subpart you would prefer the top one, and based on the number of vertices the second one. – radouxju Sep 29 '17 at 17:18
  • Instinctively, i'd choose directly the second one, it's much more realistic and detailed. Check on a aerial picture to know what causes the differences with the first but I'd wild-guess the first one comes from some sort of generalization of some more precise data like the second one. – gisnside Sep 29 '17 at 20:52
3

If vertex density is all you care about that's simple, using ST_NPoints()

CREATE TABLE foo(geom) AS
VALUES
  ('POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry),
  ('POLYGON ((0 0, 0 10, 10 10, 15 5, 10 0, 0 0))'::geometry);

SELECT ST_AsText(geom), ST_NPoints(geom)
FROM foo;

                st_astext                | st_npoints 
-----------------------------------------+------------
 POLYGON((0 0,0 10,10 10,10 0,0 0))      |          5
 POLYGON((0 0,0 10,10 10,15 5,10 0,0 0)) |          6
(2 rows)
  • 1
    For vertex density you'd want ST_NPoints(geom)/ST_Length(ST_Boundary(geom)) – dbaston Sep 29 '17 at 15:55
  • @dbaston That what I wanted. I ended up doing like this st_perimeter(geom)/st_npoints(geom) which is same as what you suggested (I think. Both returned that same value). Thank you. – Raja Sep 29 '17 at 16:03
  • I meant st_npoints(geom)/st_perimeter(geom). – Raja Sep 30 '17 at 5:27
1

Are you able to query on perimeter length? The more detailed, the longer the perimeter and hence "better". Here is a link that could be helpful:

  • I ended up doing like this st_perimeter(geom)/st_npoints(geom) which would give me vertex density. Thanks. – Raja Sep 29 '17 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.