Wednesday 25 May 2016

polygonize - Creating polygons of area surrounded by roads / lines using PostGIS?


I'm currently trying to create polygons that represent the areas surrounded by roads. The roads are stored in PostGIS as points / lines so I have flexibility over what I can do with them.


I'm basically trying to turn the white areas of this example line output into polygons:


enter image description here


Any ideas?




Here is the PostGIS to achieve this (assuming you have a road table full of lines):


SELECT (ST_Dump(ST_Polygonize(roads.geom))).geom AS the_geom FROM

(SELECT ST_Transform(ST_SetSRID(geom, 27700), 4326) AS geom FROM road_lines) AS roads

Answer



Some hints:



  1. You could use the ST_Polygonize processing of PostGIS.

  2. You could have a look at this QGIS plugin (I have not tested it myself...)

  3. If you speak Java, you could use the polygoniser of JTS.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...