I have a Linestrings layer with all the horizontal signage (lines in the floor) in my town.
I need to calculate the area of the closed linestrings. The thing here is that every side of each closed square is a different linestring. I mean, in the image's sidewalk every rectangle/square is composed of 4 linetrings, instead of being a single linestring the whole rectangle, it is composed of 4 linestrings.
Due to this, when I convert the layer to polygon using ST_MakePolygon I am getting 0 when calculting the st_area of the sidewalk and other elements..
I guess I need to create first a single linestring for every square(rectangle but I don't know how to do it...
I am currently using this query to get the area of closed linestrings with very bad result:
SELECT sub.id, st_area(st_makepolygon(ST_ForceClosed(sub.the_geom))) as area FROM sh_lineas sub where ST_NPoints(sub.the_geom)>3
My approach would be to create a subquery first and do ST_MakeLine with all the lines that are less than 1 cm from one to the other. Is it right?