[postgis-users] Creating polygons from lines fails

Stefan Donath DonathStefan at gmx.de
Tue May 5 04:05:28 PDT 2009


Hi Kevin,

thanks for mailing!

I do the following command:

INSERT INTO pl_zonen_gen VALUES ('SELECT right_pl_zone, 
ST_BuildArea(ST_Collect(geometry))
FROM pl_zonen_kante_gen GROUP BY right_pl_zone','xxxx')

I get error message:

ERROR: parse error - invalid geometry
SQL Status:XX000

What does that refer to?

To make my problem more clear: I have a table with edges of german 
postal code areas and attributes like right_pl_zone=<postalcodearea1> 
and left_pl_zone=<postalcodearea2> and I need to create polygons from that.

I have an empty polygontable with a geometry field and a character field 
for the postalcode
I want to do something like this (with vb.net):

for each postalcode in postalcode_list
    INSERT INTO polygontable VALUES(MakePolygon(SELECT geometry FROM 
geomtable WHERE right_pl_zone=postalcode OR left_pl_zone=postalcode), 
postalcode)
next

So maybe you would like to help me again with the SQL-string or give me 
an advice how to do it! Thanks a lot!

Stefan.




Kevin Neufeld wrote:
> Use ST_Polygonize() or ST_BuildArea() depending on your preference.
>
> ie.
> SELECT attribute1, attribute2, ST_BuildArea(ST_Collect(my_line_geom))
> FROM my_line_table
> GROUP BY attribute1, attribute2;
>
> -- Kevin
>
> Stefan Donath wrote:
>> Hi
>>
>> I need to create polygons from lines. Using OpenJUMP it works fine 
>> with the geometry but I'm loosing all attribute data!
>>
>> Could anyone please tell me how to do that in PostGIS!
>>
>> Thanks a lot - Stefan.
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list