1

Given a series of overlapping lines (MultiLineString) in Geojson how can I create polygons for those portions that form an enclosed a space?

Sample data - https://gist.github.com/maphew/7bb77059574ea714977edae41e4b114c a grid of overlapping lines

Operational environment is web browser and/or a server with Node.js. Desktop tools such as ArcGIS and QGIS are not available. Connection to a remote service API is acceptable but prefer to avoid. (Following principle of minimizing external dependencies.)

This is my first significant foray into javascript-land, some hand-holding may be needed. ;-)

What hasn't worked

Seeing OGR DXF Closed Polyline Conversion I tried to filter the geojson through DXF to shapefile polygons using command line ogr2ogr (v2.2.0). Thinking if I could get it to work there I could replicate in . A polygon shapefile is created but it has no features. -skipfailures didn't help.

4
  • Related gis.stackexchange.com/questions/58245/… Commented Jun 25, 2017 at 3:53
  • I suppose you had better to use a ready solution to create polygons. For example PostGIS ST_Polygonize and ST_node or GRASS GIS.
    – Zoltan
    Commented Jun 25, 2017 at 11:58
  • 1
    There is a node module - turf/linestring-to-polygon which might do the trick. If you want to do it all in the browser then You can probably implement the algorithm described here using turf. (docs).
    – RoperMaps
    Commented Jun 26, 2017 at 8:35
  • 1
    Thanks @RoperMaps. Turf/linestring-to-polyon doesn't work, but in Turf I found another module, less than 1 month old, called Turf/polygonize. It reads like it should work, but doesn't. I filed a bug, hopefully it gets fixed soon. :-) Commented Jun 27, 2017 at 19:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.