<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 10 (filtered)">
<title>RE: [postgis-users] couldn't get the correct projected values</title>

<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
 /* List Definitions */
 ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Thanks </span></font><font size=2
  color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
  color:navy'>Regina</span></font><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>! </span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Just goes to show, if you drag your heals
writing a function for long enough, someone else will do it!  </span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hmmm, I am dragging my heals coding a C
library for some embedded hydrology functions in PHP … are you listening
universe?!? </span></font><font size=2 color=navy face=Wingdings><span
style='font-size:10.0pt;font-family:Wingdings;color:navy'>J</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>

<div>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Robert W. Burgholzer</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Surface Water Modeler</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Office of Water Supply and Planning</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Virginia Department of Environmental
Quality</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><a
href="mailto:rwburgholzer@deq.virginia.gov">rwburgholzer@deq.virginia.gov</a></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>804-698-4405</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Open Source Modeling Tools:</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><a
href="http://sourceforge.net/projects/npsource/">http://sourceforge.net/projects/npsource/</a></span></font></p>

</div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <b><span
style='font-weight:bold'>On Behalf Of </span></b>Obe, Regina<br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, May 16, 2008 2:37 PM<br>
<b><span style='font-weight:bold'>To:</span></b> PostGIS Users Discussion<br>
<b><span style='font-weight:bold'>Subject:</span></b> RE: [postgis-users]
couldn't get the correct projected values</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

<div id=idOWAReplyText47318>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=black
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:black'>Bob,</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>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)</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>Its called UpdateGeometrySRID. 
In this case, you would use it like so</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>SELECT UpdateGeometrySRID('public',
'</span></font><font size=2><span style='font-size:10.0pt'>il_izmir3</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>',
'the_geom', 4326);</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>What the above does in 1 step is the
following:</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

</div>

<div>

<p style='margin-left:1.0in;text-indent:-.25in'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>1.<font size=1
face="Times New Roman"><span style='font:7.0pt "Times New Roman"'>     
</span></font></span></font>Drop geometry SRID constraint of table
public.il_izmir3 for geometry field called the_geom.</p>

<p style='margin-left:1.0in;text-indent:-.25in'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>2.<font size=1
face="Times New Roman"><span style='font:7.0pt "Times New Roman"'>     
</span></font></span></font>Update all records SRIDs of the_geom field in this
table to 4326</p>

<p style='margin-left:1.0in;text-indent:-.25in'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>3.<font size=1
face="Times New Roman"><span style='font:7.0pt "Times New Roman"'>     
</span></font></span></font>Readd the constraint </p>

<p style='margin-left:1.0in;text-indent:-.25in'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>4.<font size=1
face="Times New Roman"><span style='font:7.0pt "Times New Roman"'>     
</span></font></span></font>Correct the geometry_columns meta table with the
new SRID</p>

</div>

<p style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>Hope that clears things up,</span></font></p>

<p style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>Regina</span></font></p>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

</div>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p class=MsoNormal style='margin-right:0in;margin-bottom:12.0pt;margin-left:
.5in'><b><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:
Tahoma;font-weight:bold'>From:</span></font></b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>
postgis-users-bounces@postgis.refractions.net on behalf of Burgholzer,Robert<br>
<b><span style='font-weight:bold'>Sent:</span></b> Fri 5/16/2008 2:27 PM<br>
<b><span style='font-weight:bold'>To:</span></b> PostGIS Users Discussion<br>
<b><span style='font-weight:bold'>Subject:</span></b> RE: [postgis-users]
couldn't get the correct projected values</span></font></p>

</div>

<div>

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

</div>

</div>

</body>

</html>