[postgis-users] couldn't get the correct projected values

Obe, Regina robe.dnd at cityofboston.gov
Fri May 16 11:36:54 PDT 2008


Bob,
 
Actually there is a function that does what I think you are talking about and that would be the right way to implement what Andy is suggesting (rather than as you stated ST_SetSRID)
 
Its called UpdateGeometrySRID.  In this case, you would use it like so
SELECT UpdateGeometrySRID('public', 'il_izmir3', 'the_geom', 4326);
 
What the above does in 1 step is the following:
 

1.	Drop geometry SRID constraint of table public.il_izmir3 for geometry field called the_geom.

2.	Update all records SRIDs of the_geom field in this table to 4326

3.	Readd the constraint 

4.	Correct the geometry_columns meta table with the new SRID

Hope that clears things up,

Regina

 

________________________________

From: postgis-users-bounces at postgis.refractions.net on behalf of Burgholzer,Robert
Sent: Fri 5/16/2008 2:27 PM
To: PostGIS Users Discussion
Subject: RE: [postgis-users] couldn't get the correct projected values



I see what you're saying, but if you used shp2pgsql to import your shapes, and didn't specify a geometry, it sets the SRID = -1, and this is how it will appear in the Rules entry for your table, AND therefore, it should throw an error if you set the SRID -- or maybe that trigger only fires on an insert not an update.

Either way, I don't know what will happen if you do not update the entry in the geometry_columns table, which holds your SRID, maybe nothing, or maybe there are functions inside PostGIS that look at the SRID entry in the geom. Table.  If there are functions that look to the table for the SRID, that could be problematic.

Thus, still best practice to keep all things in SRID agreement, that is: geometry_column entry, SRID on geometries, and in Rules. It will save you headaches down the road.  And setSRID only changes one of those, the one on the geometries themselves.

Robert W. Burgholzer
Surface Water Modeler
Office of Water Supply and Planning
Virginia Department of Environmental Quality
rwburgholzer at deq.virginia.gov
804-698-4405
Open Source Modeling Tools:
http://sourceforge.net/projects/npsource/

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Andy Anderson
Sent: Friday, May 16, 2008 2:15 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] couldn't get the correct projected values

But Regina's thought was that this *was* the original geometry, just 
not documented as such by setting the SRID. That was the basis for my 
comment.

-- Andy

On May 16, 2008, at 1:46 PM, Burgholzer,Robert wrote:

> Andy,
>> fix the original table:
>>      update il_izmir3 set the_geom = ST_SetSRID(the_geom, 4326);
>
> Unfortunately, no.  As Regina pointed out, all this does is to 
> change the SRID number, it doesn't actually transform (reproject, 
> that is) the geometry.  SetSRID is usually used when importing from 
> some WKT or other geometry operation that yields a geom descriptot 
> without an SRID set (or possibly with an improper one set).
>
> To be honest, I would be surprised if "set the_geom = setSRID
> (the_geom)" did not yield an error, as the table is created with 
> rules that mandate the geometry be of a certain SRID to prevent you 
> from inadvertently mixing shapes with different SRIDs in a given 
> table.  At least, this is the default behaviour if you create your 
> tables from shapefiles (shp2pgsql).
>
> The one thing I have found lacking (perhaps if I was truly 
> bothered, I would write a function), is a function such as 
> "transformGeomCol(geomcolname, newSrid)" which would update the 
> Restriction on the column and then execute a transform on the 
> column.  When I first started using PostGIS I imported a whole 
> bunch of shapefiles and neglected to set the SRID, and then had to 
> go back later and manually redefine everything.
>
> Robert W. Burgholzer
> Surface Water Modeler
> Office of Water Supply and Planning
> Virginia Department of Environmental Quality
> rwburgholzer at deq.virginia.gov
> 804-698-4405
> Open Source Modeling Tools:
> http://sourceforge.net/projects/npsource/
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-
> users-bounces at postgis.refractions.net] On Behalf Of Andy Anderson
> Sent: Friday, May 16, 2008 11:38 AM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] couldn't get the correct projected values
>
> On May 16, 2008, at 6:55 AM, Obe, Regina wrote:
>
>> What is the SRID of your il_izmir3 geometry to begin with?
>>
>> If you imported it and incorrectly stated it as 32635 rather than
>> 4269 or 4326, then presumably the transform will do nothing since
>> it will see 32635 -> 32635 (you are already - nothing to do here).
>
> Excellent idea! But if this is the case, shouldn't the first thing to
> do be to fix the original table:
>
>       update il_izmir3 set the_geom = ST_SetSRID(the_geom, 4326);
>
> and then Ahmet's original step 1 should work.
>
> -- Andy
>
>>
>> I am going to guess that the SRID of your il_izmir3 is incorrectly
>> stated and that to fix, scrap the second statement and change your
>> first statement to  (note if your data is NAD83 longlat rather than
>> WGS long lat change the 4326 to 4269)
>>
>> create table izmir_il4 as select
>> gid,il_kod,iladi,transform(ST_SetSRID(the_geom,4326),32635) as
>> the_geom from il_izmir3;
>>
>> or alternatively change your second statement to
>>
>> UPDATE izmir_il4 SET the_geom=Transform(ST_SetSRID(the_geom,4326),
>> 32635);
>>
>> Note its safer to recreate the table since who knows what
>> projection you stated the first as so you are still transforming a
>> guess to a guess.
>>
>> 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 Paragon
>> Corporation
>> Sent: Friday, May 16, 2008 6:18 AM
>> To: 'PostGIS Users Discussion'
>> Subject: RE: [postgis-users] couldn't get the correct projected 
>> values
>>
>> You are confusing setsrid with transform.
>>
>> Remember setsrid - doesn't change the geometry it simple certifies
>> that a
>> geometry is of a particular projection - basically
>>
>> I am because I say I am
>>
>>
>> Transform - moves a geometry from one projection to another
>>
>> I am not , but please make me so.  Of course the please make me so
>> will fail
>> if you don't know what it is  to begin with
>>
>>
>> So all being said, your statement 2 is wrong and should be
>>
>> update izmir_il4 set the_geom=Transform(the_geom,32635);
>>
>> 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
>> orkun
>> Sent: Friday, May 16, 2008 4:00 AM
>> To: postgis-users at postgis.refractions.net
>> Subject: [postgis-users] couldn't get the correct projected values
>>
>> hello
>>
>> whatever I have done, I couldn't get the correct projected values
>> in postgis
>> environment.
>>
>> 1. # lon/lat to utm projection
>>
>> create table izmir_il4 as select
>> gid,il_kod,iladi,transform(the_geom,32635) as the_geom from 
>> il_izmir3;
>>
>> 2.
>> update izmir_il4 set the_geom=setsrid(the_geom,32635);
>>
>> 3.
>>
>> select extent(the_geom) from izmir_il4;
>>
>> extent
>> ---------------------------------------------------------------------
>> -
>> ----
>> BOX(26.2226982116699 37.8668251037598,28.4587249755859
>> 39.3925666809082)
>>
>> but these are not utm values. They are still in lon/lat values
>>
>> I checked extent values with proj values. I got correct values:
>>
>> echo "26.2226982116699 37.8668251037598" | proj +proj=utm +zone=35
>> +ellps=WGS84 +datum=WGS84
>> 431631.23       4191323.84
>> orkun at orkun-desktop:/usr/local/izmir/veri/izmir3$ echo
>> "28.4587249755859
>> 39.3925666809082" | proj +proj=utm +zone=35 +ellps=WGS84 +datum=WGS84
>> 625615.27       4361356.53
>>
>>
>> how can get values generated from "proj" in postgis environment ?
>> what am I doing wrong ?
>>
>> here is the srid values of 32635 :
>> 32635 | +proj=utm +zone=35 +ellps=WGS84 +datum=WGS84 +units=m 
>> +no_defs
>>
>> regards
>>
>> --
>> Ahmet Temiz
>> Jeo. Müh.
>> Afet Isleri Gen. Md.lügü
>> Deprem Ar. D.
>>
>> Ahmet Temiz
>> Geo. Eng.
>> General Dir. of
>> Disaster Affairs
>>
>>
>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>> _______________________________________________
>> 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.
>>
>> _______________________________________________
>> 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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080516/70520159/attachment.html>


More information about the postgis-users mailing list