[postgis-users] Help with intersection/polygons & geometry_columns entry needed.
Brent Wood
pcreso at pcreso.com
Wed May 17 01:26:20 PDT 2006
Now that I have Postgis back with its 360 degree support working fine, I'm
working on a script to take a table with +-180 polygons and generate a table
with these converted to 0-360.
I got such a great response with my bug yesterday that I hope to sleep on this
& have this wonderful community solve these for me by the time I wake up :-)
The approach I've used is to run 2 selects, firstly:
create table foo as
select *,
intersection(geom, polygon(0 to 180))
where geom && polygon(0 to 180)
from foo0;
This should give me closed geometries nicely clipped at 180.
Followed by:
insert into foo
select *,
translate(intersection(geom, polygon(-180 to 0)), 360, 0, 0)
where geom && polygon(-180 to 0)
from foo0;
Which adds nicely close geometries from the eastern hemisphere translated to
0-360.
It seems to work, but there are two issues I can't resolve so far, & I don't
think they are really bugs....
intersection returns a geometry datatype, but I need polygons, multipolygons or
linestrings depending on the original geom type. Casting a geometry to polygon
fails, & polygonise returns a collection. Any suggestions on how to convert
geometries to specific types?
an easy way to create a geometry-columns entry for a table which already has a
geometry column, as created by the "create table as select ..." command. (or
some approach to create a "replica" table with a geometry_columns entry I can
select into). Any ideas on this one?
adTHANKSvance
(again)
Brent Wood
More information about the postgis-users
mailing list