Hi Marc,<br><br> I suppose that when you say: WGS84 datum, you mean geographical coordinates based on the WGS84-datum (i.e. lat,lon)?<br> Which other datums are involved?<br><br>Cheers,<br>Simon<br> <br><br><div class="gmail_quote">
On Wed, Oct 19, 2011 at 12:53 PM,  <span dir="ltr">&lt;<a href="mailto:dev4cx4m9z@snkmail.com">dev4cx4m9z@snkmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div link="blue" vlink="purple" lang="EN-AU"><div><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Well, it’s ‘working’ (sort of) but I’m still confused. I’ll try to explain better what I’m trying to do.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I have a database of map coordinates stored in WGS84 datum.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I load and display a map in my application which may, or may not, use the WGS84 datum. I am setting up a coordinatetransformation to convert WGS84 data to whatever datum the map is. I then use another transformation to translate to screen coordinates.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I’m only worrying about the datum conversion issue first. I will worry about the map projection issue later.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I have successfully created a number of CT’s with no error. When invoked, they’re giving the wrong answer, but I’m still looking into that.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I still don’t understand proj.dll. I downloaded the prebuilt proj.dll, and it seems to only have a few datums. It certainly does not have the ones I’m using. Does it matter, or must proj.dll contain all the datums I intend to use? Is the data pointed to by GDAL_DATA sufficient to translate from any known datum to another?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-size:10.0pt" lang="EN-US">From:</span></b><span style="font-size:10.0pt" lang="EN-US"> Simon Lyngby Kokkendorff <a href="http://silyko-at-gmail.com" target="_blank">silyko-at-gmail.com</a> |GDAL| [mailto:<a href="mailto:r0dk224axt@sneakemail.com" target="_blank">r0dk224axt@sneakemail.com</a>] <br>
<b>Sent:</b> Wednesday, October 19, 2011 8:55 PM</span></p><div><div></div><div class="h5"><br><b>To:</b> <a href="mailto:marc.hillman@tpg.com.au" target="_blank">marc.hillman@tpg.com.au</a>; <a href="mailto:dev4cx4m9z@snkmail.com" target="_blank">dev4cx4m9z@snkmail.com</a><br>
<b>Cc:</b> <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br><b>Subject:</b> Re: [gdal-dev] Confused about datum transformations<u></u><u></u></div></div><p></p><div><div></div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal" style="margin-bottom:12.0pt">Hi Marc,<br><br>  Just to understand your problem fully:  You have data in your database in WGS84, in geographical coordinates, or what? That would correspond to a srs=osr.SpatialReference(), srs.SetWellKnownGeogCS(&quot;WGS84&quot;).<br>
<br>   What kind of projection or geographical coordinate system do you want to project to? It seems to be: EPSG:3557 which is: NAD83(NSRS2007) / Maine East. Is this correct? If you have the GDAL_DATA env-variable pointing to the right directory (containing EPSG definitions etc), gdal should be able to also do:<br>
srs2=osr.SpatialReference(), srs2.ImportFromEPSG(3557), which becomes:<br><br>&gt;&gt;&gt; srs2.ExportToPrettyWkt()<br>&#39;PROJCS[&quot;NAD83(NSRS2007) / Maine East&quot;,\n    GEOGCS[&quot;NAD83(NSRS2007)&quot;,\n        DATUM[&quot;NAD83_National_Spatial_Reference_System_2007&quot;,\n            SPHEROID[&quot;GRS 1980&quot;,6378137,298.257222101,\n                AUTHORITY[&quot;EPSG&quot;,&quot;7019&quot;]],\n<br>
       TOWGS84[0,0,0,0,0,0,0],\n            AUTHORITY[&quot;EPSG&quot;,&quot;6759&quot;]],\n        PRIMEM[&quot;Greenwich&quot;,0,\n            AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],\n        UNIT[&quot;degree&quot;,0.01745329251994328,\n            AUTHORITY[&quot;EPSG&quot;,&quot;9122&quot;]],\n        AUTHORITY[&quot;EPSG&quot;,&quot;4759&quot;]],\n    UNIT[&quot;metre&quot;,1,\n        AUTHORITY[&quot;EPSG&quot;,&quot;9001&quot;]],\n    PROJECTION[&quot;Transverse_Mercator&quot;],\n    PARAMETER[&quot;latitude_of_origin&quot;,43.66666666666666],\n    PARAMETER[&quot;central_meridian&quot;,-68.5],\n    PARAMETER[&quot;scale_factor&quot;,0.9999],\n    PARAMETER[&quot;false_easting&quot;,300000],\n    PARAMETER[&quot;false_northing&quot;,0],\n    AUTHORITY[&quot;EPSG&quot;,&quot;3557&quot;],\n    AXIS[&quot;X&quot;,EAST],\n    AXIS[&quot;Y&quot;,NORTH]]&#39;<br>
&#39;<br><br>If you want to perform the actual coordinate transformation, besides just having descriptions of the systems, you&#39;ll definitely need to have proj4.dll somewhere in your system, where gdal can find it (I guess besides gdal.dll or somewhere in your PATH). <br>
<br>Cheers,<br>Simon<br><br><u></u><u></u></p><div><p class="MsoNormal">On Wed, Oct 19, 2011 at 11:21 AM, &lt;<a href="mailto:dev4cx4m9z@snkmail.com" target="_blank">dev4cx4m9z@snkmail.com</a>&gt; wrote:<u></u><u></u></p>
<p class="MsoNormal">I have a big clue - I have inspected the output of ExportToWKT, and the results are interesting<u></u><u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>       With WGS84SRS<br>           GDALError = .SetProjCS(&quot;WGS84 Datum&quot;)<br>
           Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>           GDALError = .SetWellKnownGeogCS(&quot;WGS84&quot;)          &#39; Define WGS84 coordinate system<br>           Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
       End With<u></u><u></u></p></div><p class="MsoNormal">Produces PROJCS[&quot;WGS84 Datum&quot;,GEOGCS[&quot;WGS 84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS 84&quot;,6378137,298.257223563,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNIT[&quot;degree&quot;,0.0174532925199433,AUTHORITY[&quot;EPSG&quot;,&quot;9108&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]]<br>
       With UTMSRS<br>           GDALError = .SetProjCS(&quot;UTM coordinate system&quot;)<br>           Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>           GDALError = .SetWellKnownGeogCS(&quot;WGS84&quot;)              &#39; Define a UTM coordinate system<u></u><u></u></p>
<div><p class="MsoNormal" style="margin-bottom:12.0pt">           Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>       End With<u></u><u></u></p></div><p class="MsoNormal">Produces PROJCS[&quot;UTM coordinate system&quot;,GEOGCS[&quot;WGS 84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS 84&quot;,6378137,298.257223563,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNIT[&quot;degree&quot;,0.0174532925199433,AUTHORITY[&quot;EPSG&quot;,&quot;9108&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]]<u></u><u></u></p>
<div><p class="MsoNormal"><br>      With MapSRS<br>           GDALError = .SetProjCS(&quot;Map coordinate system&quot;)<br>           Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<u></u><u></u></p></div>
<p class="MsoNormal">           GDALError = .ImportFromEPSG(i)<u></u><u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt">           Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>       End With<u></u><u></u></p>
</div><p class="MsoNormal">Produces GEOGCS[&quot;GDA94&quot;,DATUM[&quot;Geocentric_Datum_of_Australia_1994&quot;,SPHEROID[&quot;GRS 1980&quot;,6378137,298.257222101,AUTHORITY[&quot;EPSG&quot;,&quot;7019&quot;]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[&quot;EPSG&quot;,&quot;6283&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNIT[&quot;degree&quot;,0.0174532925199433,AUTHORITY[&quot;EPSG&quot;,&quot;9122&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;4283&quot;]]<br>
<br>The error when I attempt to create the transformation is always with the SRS that seems to be a projection definition, not a datum. ImportFromEPSG seems to be correctly producing a GEOGCS, but SetWellKnownGeogCS seems to be producing a &quot;PROJCS&quot;<br>
<br>I feel I&#39;m very close to the answer, but I still can&#39;t see it.<u></u><u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>-----Original Message-----<br>From: Peter J Halls <a href="http://P.Halls-at-york.ac.uk" target="_blank">P.Halls-at-york.ac.uk</a> |GDAL| [mailto:<a href="mailto:6wyv643jct@sneakemail.com" target="_blank">6wyv643jct@sneakemail.com</a>]<br>
Sent: Wednesday, October 19, 2011 7:54 PM<br>To: <a href="mailto:marc.hillman@tpg.com.au" target="_blank">marc.hillman@tpg.com.au</a>; <a href="mailto:dev4cx4m9z@snkmail.com" target="_blank">dev4cx4m9z@snkmail.com</a><br>
Subject: Re: [gdal-dev] Confused about datum transformations<u></u><u></u></p></div><p class="MsoNormal">A comment from another GDAL user, rather than the development team.<br><br>GDAL and OGR are actually C++ tools that have C, Java, Python and other language bindings.  What you have picked up is an artefact of the fact that GDAL is not just C.<br>
<br>The proj4 library for your platform is automatically loaded with GDAL and OGR:<br>it must be present but no explicit action is required by the user.<br><br>Chaitanya&#39;s advice was to double check that the transformation parameters are being passed correctly.  Datum transformations *are* fiddly (full stop) to specify and this advice is sound.  You appear to be specifying two parts of the transformation, presumably being content with the default values for the other parameters.  Ideally, you need to get the system to regurgitate its understanding of your parameters in the WKT version of the final transformation specification - ie the complete string.  This is what you are being advised to do.<br>
<br>Problems like this are not confined to GDAL / OGR: I&#39;ve lost count of the number of times I&#39;ve handled projection problems here.  What sounds to be a simple operation is not trivial and unpicking problems most often requires an understanding of the transformation method and all the parameters applied.<br>
<br>Hoping that helps,<br><br>Peter<u></u><u></u></p><div><p class="MsoNormal"><br><a href="mailto:dev4cx4m9z@snkmail.com" target="_blank">dev4cx4m9z@snkmail.com</a> wrote:<br>&gt; I have not used org2ogr. I have just realised that the C API for GDAL<br>
&gt; uses a mixture of STD and CDECL. How annoying. Anyway – I have<br>&gt; carefully checked and all are correct. I get a stack balance problem<br>&gt; if they are not anyway. It’s hard to see how I could get the arguments wrong – one is the string “WGS84”, and the other is an integer.<br>
&gt;<br>&gt;<br>&gt;<br>&gt; I still don’t know whether proj.dll is required.<br>&gt;<br>&gt;<br>&gt;<br>&gt; From: Chaitanya kumar CH <a href="http://chaitanya.ch-at-gmail.com" target="_blank">chaitanya.ch-at-gmail.com</a> |GDAL|<br>
&gt; [mailto:<a href="mailto:5rm5yuc82t@sneakemail.com" target="_blank">5rm5yuc82t@sneakemail.com</a>]<br>&gt; Sent: Wednesday, October 19, 2011 6:36 PM<br>&gt; To: <a href="mailto:marc.hillman@tpg.com.au" target="_blank">marc.hillman@tpg.com.au</a>; <a href="mailto:dev4cx4m9z@snkmail.com" target="_blank">dev4cx4m9z@snkmail.com</a><br>
&gt; Cc: <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>&gt; Subject: Re: [gdal-dev] Confused about datum transformations<br>&gt;<br>&gt;<br>&gt;<br>&gt; Marc,<br>&gt;<br>&gt; You don&#39;t need to rebuild proj.4; you are already using it.. Since you were able to use ogr2ogr to do the transformation, it works.<br>
&gt;<br>&gt; What you need to do is find out if the arguments you are passing to the transformation builder are good. Especially &#39;MapSRS&#39;. If it doesn&#39;t show any problem, plug some debug messages in the OSR code in ogrct.cpp and rebuild gdal.<br>
&gt;<br>&gt; On Wed, Oct 19, 2011 at 12:46 PM, &lt;<a href="mailto:dev4cx4m9z@snkmail.com" target="_blank">dev4cx4m9z@snkmail.com</a>&gt; wrote:<br>&gt;<br>&gt; Thanks for all the suggestions – they have given me many possibilities to eliminate, but I still haven’t really got an answer to the original question.<br>
&gt;<br>&gt;<br>&gt;<br>&gt; Am I required to have proj.dll built with support for the datums/projections I want to use, or is it sufficient to set GDAL_DATA such that gcs.csv and pcs.csv are visible? I’m working in <a href="http://VB.NET" target="_blank">VB.NET</a>, and I’m not confident I can rebuild PROJ with the required datums, so I wish to avoid if possible. I’d even be prepared to use SetGeogCS explicitly as I only use a few datums. If I use SetGeogCS, I can’t see what purpose proj.dll serves.<br>
&gt;<br>&gt;<br>&gt;<br>&gt; I have set GDAL_DATA to the correct folder.<br>&gt;<br>&gt; I have checked that the datum numbers I use are in the gcs.csv file.<br>&gt;<br>&gt;<br>&gt;<br>&gt; From: <a href="mailto:gdal-dev-bounces@lists.osgeo.org" target="_blank">gdal-dev-bounces@lists.osgeo.org</a><br>
&gt; [mailto:<a href="mailto:gdal-dev-bounces@lists.osgeo.org" target="_blank">gdal-dev-bounces@lists.osgeo.org</a><u></u><u></u></p></div><p class="MsoNormal">&gt; &lt;mailto:<a href="mailto:gdal-dev-bounces@lists.osgeo." target="_blank">gdal-dev-bounces@lists.osgeo.</a>.org&gt; ] On Behalf Of<u></u><u></u></p>
<div><div><p class="MsoNormal">&gt; <a href="mailto:dev4cx4m9z@snkmail..com" target="_blank">dev4cx4m9z@snkmail.com</a><br>&gt; Sent: Tuesday, October 18, 2011 4:12 AM<br>&gt; To: <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
&gt; Subject: RE: [gdal-dev] Confused about datum transformations<br>&gt;<br>&gt;<br>&gt;<br>&gt; I’m not sure the code will help too much, but here are the relevant<br>&gt; code fragments. I’m using a hand crafted VB.net wrapper which explains<br>
&gt; some of the syntax<br>&gt;<br>&gt;<br>&gt;<br>&gt; Private WGS84SRS As New OGRSpatialReference     &#39; Coordinate system in WGS84<br>&gt;<br>&gt; Private MapSRS As OGRSpatialReference       &#39; Coordinate system of map<br>
&gt;<br>&gt; Private ctWGS84toMap As OGRCoordinateTransformation       &#39; Coordinate transform from WGS84 to map<br>&gt;<br>&gt;<br>&gt;<br>&gt; With WGS84SRS<br>&gt;<br>&gt;     GDALError = .SetProjCS(&quot;WGS84 Datum&quot;)<br>
&gt;<br>&gt;     Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>&gt;<br>&gt;     GDALError = .SetWellKnownGeogCS(&quot;WGS84&quot;)          &#39; Define WGS84 coordinate system<br>&gt;<br>&gt;     Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
&gt;<br>&gt; End With<br>&gt;<br>&gt;<br>&gt;<br>&gt; With MapSRS<br>&gt;<br>&gt;      GDALError = .SetProjCS(&quot;Map coordinate system&quot;)<br>&gt;<br>&gt;      Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
&gt;<br>&gt;      GDALError = .ImportFromEPSG(3577)<br>&gt;<br>&gt;      Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>&gt;<br>&gt; End With<br>&gt;<br>&gt;<br>&gt;<br>&gt; ctWGS84toMap = GDAL.CreateCoordinateTransformation(WGS84SRS, MapSRS)        &#39; Create a coordinate transformation - WGS84 to map<br>
&gt;<br>&gt; Debug.Assert(ctWGS84toMap IsNot Nothing, GetLastErrorMsg())<br>&gt;<br>&gt;<br>&gt;<br>&gt; Marc,<br>&gt;<br>&gt; Can you provide the code leading to the error?<br>&gt;<br>&gt; On Tue, Oct 18, 2011 at 1:21 PM, Marc Hillman &lt;<a href="mailto:dev4cx4m9z@snkmail.com" target="_blank">dev4cx4m9z@snkmail.com</a>&gt; wrote:<br>
&gt;<br>&gt; I have a GIS database, and all data is stored in WGS84 datum. I have developed an application using GDAL, and I now need to translate my WGS84 coordinates to several different datums, depending what map is loaded. I seem to be going around in circles, and need a nudge in the right direction. I am defining an OGRSpatialReference for each datum (WGS84 and current map) and then attempting to create an OGRCoordinateTransformation for the transformation.. This last step fails with a PROJ.4 error (“No PROJ.4 translation for destination SRS, coordinate transformation initialization failed”<br>
&gt;<br>&gt;<br>&gt;<br>&gt; My question is - Do I need PROJ.4 to do the translation? Can I not just use ImportFromWKT to define my OGRSpatialReference? If so, is there a nice canned list of all the WKT somewhere?  I’m keen to avoid PROJ.4 if possible as I’m not sure I can build it.<br>
&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; gdal-dev mailing list<br>&gt; <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>&gt; <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<u></u><u></u></p></div></div><p class="MsoNormal">&gt; ----------------------------------------------------------------------<br>&gt; --<u></u><u></u></p><div><p class="MsoNormal">
&gt;<br>&gt; _______________________________________________<br>&gt; gdal-dev mailing list<br>&gt; <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>&gt; <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
<br>--<u></u><u></u></p></div><p class="MsoNormal">--------------------------------------------------------------------------------<br>Peter J Halls, GIS Advisor &amp; Team Leader Applications Support and Training,<br>               Information Directorate, University of York<br>
Telephone: 01904 323806     Fax: 01904 323740<br>Snail mail: Harry Fairhurst Building, University of York,<br>            Heslington, York YO10 5DD<br>This message has the status of a private and personal communication<br>
--------------------------------------------------------------------------------<br><br><br><br>-----<u></u><u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt">No virus found in this message.<br>Checked by AVG - <a href="http://www.avg.com" target="_blank">www.avg.com</a><br>
Version: 2012.0.1831 / Virus Database: 2092/4560 - Release Date: 10/18/11<u></u><u></u></p></div><div><div><p class="MsoNormal">_______________________________________________<br>gdal-dev mailing list<br><a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><u></u><u></u></p></div></div></div><p class="MsoNormal"><br><br><u></u><u></u></p><p class="MsoNormal">
No virus found in this message.<br>Checked by AVG - <a href="http://www.avg.com" target="_blank">www.avg.com</a><br>Version: 2012.0.1831 / Virus Database: 2092/4560 - Release Date: 10/18/11<u></u><u></u></p></div></div></div>
</div><br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br>