1

I have been looking for a answer for days. I don't even know if its possible.

Tried:

ST_AsGeoJson(ST_MakePolygon(ST_transform(geom,4326))) 

ERROR: Shell is not a line

ST_Polygonize(ST_LineMerge(ST_transform(geom,4326))) 

This returns one big polygon with all the multilinestrings, but I want separated polygons.

Is it possible? if yes, how can I do this?

TABLE rede.redetotal_geo
(
  circuit_id character varying(9),
  n_arvores bigint,
  km double precision,
  index double precision,
  geom geometry(MultiLineString,3857)
)

(Multilinestring -> Polygon)

enter image description here

These are my multilinestrings, I want to transform each color to a polygon.

  • You haven't described your inputs and outputs and what you get versus what you want particularly well. A picture (or two or three) is worth a thousand words. – Paul Ramsey Aug 11 '15 at 12:24
  • Sorry, now I added the image – Lucas Rodrigues Aug 11 '15 at 13:14
  • You can use ST_ConcaveHull to get approximate polygon. Since the lines don't actually form the boundary of the areas you're going to have some difficulty getting a perfect coverage of polygons from the data. Another possibility is building a line voronoi using the faces and assign faces to categories based on what lines fall within the faces. I don't know that PostGIS hast he functions for that (look at ST_DelaunayTriangles()) – Paul Ramsey Aug 11 '15 at 15:16
  • Worked, thanks. is there a way to set your comment as correct answer? – Lucas Rodrigues Aug 12 '15 at 11:28
  • But your's linestrings doesn't form a closed rings or anything else that seems to be a polygon. – dmitry.v.kiselev Aug 12 '15 at 13:18
2

You can use ST_ConcaveHull to get approximate polygon. Since the lines don't actually form the boundary of the areas you're going to have some difficulty getting a perfect coverage of polygons from the data. Another possibility is building a line voronoi using the faces and assign faces to categories based on what lines fall within the faces. I don't know that PostGIS hast he functions for that (look at ST_DelaunayTriangles())

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.