[postgis-users] RE:Is the Earth round??

Carlos Ferrão cferrao at gmail.com
Thu May 25 02:48:19 PDT 2006


Hi Paul,
I guess the two inserts do not work because postGIS doesn't retrieve
me polygons in the -360-0 range.

My original polygon is:
177.87 72.75,-179.15 72.40,174.19 66.05,173.92 65.70,171.66
65.98,171.91 66.33,177.87 72.75

Which would be divided into
Polygon 1- The Unretrievable
-287.25 -182.13, -287.6 -179.15,-293.95 -185.81, -294.3 186.08,
-294.02 -188.34,-293.67 -188.09, -287.25 -182.13
and Polygon 2 - The Retrievable
177.87 72.75,180.85 72.40,174.19 66.05,173.92 65.70,171.66
65.98,171.91 66.33,177.87 72.75

The insert goes ok and the polygons are valid. However, a SQL query
with a bounding box that intersects polygon 1 doesn't retrieve any
results:
SELECT * FROM mytable where
Intersects(GeometryFromText('POLYGON((-179.3502 81.8773,-179.3502
1.2996, -105.9206 1.2996, -105.9206 81.8773, -179.3502
81.8773))',4326),mypolygon);

a SQL query that intersects polygon 2 works good:
SELECT * from mytable where
Intersects(GeometryFromText('POLYGON((70.8303 77.9783,70.8303 2.5993,
178.7004 2.5993, 178.7004 77.9783, 70.8303
77.9783))',4326),mypolygon);

Any ideas for a workaround on this?

Thanks,
Carlos.

On 5/24/06, Paul Ramsey <pramsey at refractions.net> wrote:
> A multipolygon will not work, since its overall bounding box will
> still straddle the meridian.  The cleanest way to implement a
> dateline hack is probably a pre-commit trigger that tests inputs for
> dateline crossing, and re-writes them into two inserts instead of
> one, as you suggest.
>
> P
>
> On May 24, 2006, at 7:20 AM, Carlos Ferrão wrote:
>
> > Hi,
> > Thanks for the prompt answers on this list.
> > The main purpose is to have a database with metadata of satellite
> > image products and search for them given date and coordinate
> > constraints. I already did it using Oracle Spatial Module but was
> > looking for a low cost solution (btw, this issue doesn't happen there)
> > with Postgres+PostGIS (GEOS & Proj4).
> >
> > The products follow WGS84 (+/-180) lon/lat and I have images from
> > around the world, so I cannot simply move the meridian to another
> > place.
> >
> > I added my polygon using 0-360 (Brent's suggestion) and I got a valid
> > one. Unfortunately, this product is only retrieved if my bounding box
> > is near the 180 limit of my map interface and ignores the -177 value.
> >
> > In order to workaround all this, I'm considering (assuming that no
> > satellite takes an image bigger than half of the globe) doubling the
> > products that cross the dateline, and process the coordinates to put
> > one in the -180/180 and another in 180/360. Then I'd do a select
> > distinct (just in case I have a very large BBox) to retrieve always
> > one product.
> >
> > Second option is to split the coordinates into two polygons and define
> > a multipolygon for each product.
> > Any of these ideas imply further processing of satellite metadata so
> > if there is a better method to do this I appreciate any input.
> >
> > Thanks,
> > Carlos.
> > _______________________________________________
> > 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