[postgis-users] SRID confusion

Obe, Regina robe.dnd at cityofboston.gov
Fri Oct 31 05:01:58 PDT 2008


Brent,

I don't recall having this issue with the 1.1 series.  So as Kevin said
how the heck did you get those weird geometries in there.  Was the set
of poly/multi poly before you unioned them have those weird SRID=0

 MULTIPOLYGON(SRID=0;((55.78

which as Kevin said is not even valid EWKT representation.  In which
case it could be one bad geometry causing all the problem.


Are you saying even AsEWKT doesn't return the valid SRID for this mutant
polygon? 


So if you do something like

SELECT AsText(geomunion(the_geom)) As wkt, AsEWKT(geomunion(the_geom))
As ewkt
FROM (SELECT SetSRID(ST_MakePoint(x,y),4326) as the_geom
FROM generate_series(1,4) x CROSS JOIN generate_series(5,11) y) as pt

You get both showing invalid SRIDs? If the above looks fine, I would
blame the issue on a questionable geometry colliding with a bug in 1.1

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
pcreso at pcreso.com
Sent: Thursday, October 30, 2008 9:31 PM
To: PostGIS Users Discussion
Subject: RE: [postgis-users] SRID confusion

Hi Regina,

Still using 1.1 on this system.

The isssue I have is that any geometry created by a postgis geometry
processing function has a SRID there for each individual polygon within
the multipOLYGON. 

This causes QGIS to crash, & the internal SRID is always reported as 0
by astext().

If I extract the astext() output, cut out the internal SRID, & re-insert
to the table without this, everything seems happy, & astext() returns
the text with no SRID for the constituent polygons & QGIS is fine

This may have been addressed in later versions of PostGIS, but I don't
recall any mentions of this as a bug or problem for anyone else.

This means there are two acceptable formats for a PostGIS multipolygon
(both acceptable with isvalid() for example), one with internal SRID
values & one without, applications such as QGIS are happy with
geometries which do NOT have the internal SRID specified, but PostGIS is
only creating multipolygons with the internal SIDs explicitly specified.

Cheers....

   Brent


--- On Fri, 10/31/08, Paragon Corporation <lr at pcorp.us> wrote:

> From: Paragon Corporation <lr at pcorp.us>
> Subject: RE: [postgis-users] SRID confusion
> To: "'PostGIS Users Discussion'"
<postgis-users at postgis.refractions.net>
> Date: Friday, October 31, 2008, 11:01 AM
> Brent,
> 
> Which version of PostGIS are you using?  I'm guessing
> an older version.
> 
>  If I do this
> 
> SELECT AsText('SRID=4326;POLYGON((1 2 3, 4 5 6, 7 8 9,
> 1 2 3))')
> 
> I get this
> 
> "POLYGON((1 2,4 5,7 8,1 2))"
> 
> Which observe has no SRID information.
> 
> If I do this
> SELECT AsEWKT('SRID=4326;POLYGON((1 2 3, 4 5 6, 7 8 9,
> 1 2 3))')
> 
> I get
> "SRID=4326;POLYGON((1 2 3,4 5 6,7 8 9,1 2 3))"
> 
> (which observe maintains the SRID info)
> 
> 
> So maybe an earlier version included an SRID which would
> obviously be 0 or
> -1 since it basically throws that information away so is
> for all intents and
> purposes is forced to unknown now.
> 
> So I guess my only suggestion - stay away from AsText if
> you care about SRID
> 
> And Use ST_AsEWKT or AsEWKT instead and ST_GeomFromEWKT or
> GeomFromEWKT.
> 
> Hope that helps,
> Regina
> 
> 
> 
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On
> Behalf Of
> pcreso at pcreso.com
> Sent: Thursday, October 30, 2008 5:37 PM
> To: PostGIS Users Discussion
> Subject: RE: [postgis-users] SRID confusion
> 
> Hi Regina...
> 
> To add to my confusion:
> 
> I'm using AsText, as in the original example below.
> 
> If I try to open this multipolygon with QGIS (v1 pre or
> v0.11) it crashes.
> 
> However:
> 
> If I do the following in a shell script:
> 
> GEOM=`psql -d $DB -Atc "select astext(hole) from
> hole_multi;"` GEOM=`echo
> "$GEOM" | sed 's/SRID=0;//g'` psql -d $DB
> -c "update hole_multi set
> hole=geometryfromtext('$GEOM',4326);"
> 
> ie: remove any internal reference to the SRID & update
> the geomtery value
> from the revised text string, then everything works
> perfectly.
> 
> Is this a bug in how geomunion() write the geometry? Does
> it include the
> constituent SRID's when it shouldn't?
> 
> 
> Thanks
> 
>    Brent
> 
> 
> --- On Fri, 10/31/08, Paragon Corporation
> <lr at pcorp.us> wrote:
> 
> > From: Paragon Corporation <lr at pcorp.us>
> > Subject: RE: [postgis-users] SRID confusion
> > To: "'PostGIS Users Discussion'" 
> > <postgis-users at postgis.refractions.net>
> > Date: Friday, October 31, 2008, 10:14 AM Brent,
> > 
> > Are you using AsText or ST_AsEWKT.
> > 
> > AsText to my knowledges doesn't output SRID so it
> would always be 0.
> > 
> > Hope that helps,
> > Regina
> > 
> > -----Original Message-----
> > From: postgis-users-bounces at postgis.refractions.net
> > [mailto:postgis-users-bounces at postgis.refractions.net]
> On Behalf Of 
> > pcreso at pcreso.com
> > Sent: Thursday, October 30, 2008 4:53 PM
> > To: postgis-users at postgis.refractions.net
> > Subject: [postgis-users] SRID confusion
> > 
> > Hi guys,
> > 
> > I'm not sure what is going on here:
> > 
> > I am working with some strata boundaries for a
> fisheries survey, 
> > mostly depth based strata. SRID=4326
> > 
> > I also have some polygons of areas of untrawlable
> seabed & want to 
> > generate these cropped by stratum. SRID=4326
> > 
> > Aas a step in this process I create a new table with a
> single 
> > multipolygon comprising the geomunion of all the hole
> polygons.
> > SRID=4326
> > 
> > insert into hole_multi
> >                 select 1, geomunion(geom) from holes;
> > 
> > 
> > If I run a query on this table:
> > 
> > select srid(hole), astext(hole) from hole_multi;
> > 
> > I get:
> > 
> >  4326 | MULTIPOLYGON(SRID=0;((55.78 ....
> > 
> > 
> > So the SRID of the column is 4326, but each
> constituent polygon of the 
> > multipolygon, despite coming from a 4326 dataset,
> seems to be set 
> > internally to SRID=0.
> > 
> > The result is the same with:
> >  insert into hole_multi
> >                 select 1,
> setsrid(geomunion(geom),4326) from holes;
> > 
> > 
> > Any ideas?
> > 
> > 
> > Thanks,
> > 
> >    Brent Wood
> > _______________________________________________
> > 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
> _______________________________________________
> 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
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.



More information about the postgis-users mailing list