[postgis-users] Converting multilinestring to polygon

Francis Dupont Francis.X.Dupont at USherbrooke.ca
Wed May 28 10:26:58 PDT 2008


Hi!

In response to Andy Lam Yin Cong e-mail about converting a multilinestring to a
polygon, I have created the following command to do the conversion:

ALTER TABLE my_table ADD COLUMN geo_txt TEXT
UPDATE my_table SET geo_txt = ST_AsText(ST_BuildArea(the_geom))
SELECT DropGeometryColumn('public', 'my_table', 'the_geom')
SELECT AddGeometryColumn('public', 'my_table', 'the_geom', 2037, 'POLYGON', 2)
UPDATE my_table SET the_geom = ST_GeomFromText(geo_txt, 2037)
ALTER TABLE my_table DROP COLUMN geo_txt


If there's a better way of doing this, let me know!

Francis



More information about the postgis-users mailing list