0

I am creating a database in PostGIS and I have a column that will save the boundaries of boroughs.

The app will later query the database, asking what points, lines or polygons are inside those boundaries.

The borough boundaries are closed linestrings, but I dont know if this affects the query speed or the efficiency of functions like ST_Within or ST_Intersects.

In that context, what is the correct way to save boundaries , as closed linestrings or as polygons ?

  • 3
    well, any spatial relationship to be queried on your boroughs as an area need to be queried on their areal representation. You can either store them as polygons or cast their geometries to polygons before querying them (which, obviously, is rather unnecessary). you could store your boundaries both as (multi)lines and polygons in the same table in case you actually need the linestrings for something, or in different spatial tables with relations to their attributes in a base table – ThingumaBob Dec 16 '17 at 14:57
  • 2
    A Within relationship on a linestring will only find intersection with the boundary (perimeter), which exceedingly difficult to hit. Polyline and polygon figures require exactly the same storage, so there is no reason to store the wrong topology type. – Vince Dec 16 '17 at 16:18
  • @Vince In sum, the user will pick the "pen" from openlayers, draw the boundaries and then I will query "is this geometry inside the area that the user draw?". Do you imply that ST_Within will not help me? – slevin Dec 16 '17 at 16:27
  • 3
    It won't help you if you store the wrong topology. If you want point-in-polygon comparison, you need to query a polygon with your point. – Vince Dec 16 '17 at 16:44
0

I am creating a database in PostGIS and I have a column that will save the boundaries of boroughs.

I agree with others the borough should be one polygon. Then you can at a later point decompose that one polygon to many others for the purposes of indexing.

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.