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

Burgholzer,Robert rwburgholzer at deq.virginia.gov
Fri May 16 10:46:02 PDT 2008


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



More information about the postgis-users mailing list