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("WGS84").<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>>>> srs2.ExportToPrettyWkt()<br>'PROJCS["NAD83(NSRS2007) / Maine East",\n GEOGCS["NAD83(NSRS2007)",\n DATUM["NAD83_National_Spatial_Reference_System_2007",\n SPHEROID["GRS 1980",6378137,298.257222101,\n AUTHORITY["EPSG","7019"]],\n<br>
TOWGS84[0,0,0,0,0,0,0],\n AUTHORITY["EPSG","6759"]],\n PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],\n UNIT["degree",0.01745329251994328,\n AUTHORITY["EPSG","9122"]],\n AUTHORITY["EPSG","4759"]],\n UNIT["metre",1,\n AUTHORITY["EPSG","9001"]],\n PROJECTION["Transverse_Mercator"],\n PARAMETER["latitude_of_origin",43.66666666666666],\n PARAMETER["central_meridian",-68.5],\n PARAMETER["scale_factor",0.9999],\n PARAMETER["false_easting",300000],\n PARAMETER["false_northing",0],\n AUTHORITY["EPSG","3557"],\n AXIS["X",EAST],\n AXIS["Y",NORTH]]'<br>
'<br><br>If you want to perform the actual coordinate transformation, besides just having descriptions of the systems, you'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><br><div class="gmail_quote">On Wed, Oct 19, 2011 at 11:21 AM, <span dir="ltr"><<a href="mailto:dev4cx4m9z@snkmail.com">dev4cx4m9z@snkmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I have a big clue - I have inspected the output of ExportToWKT, and the results are interesting<br>
<div class="im"><br>
With WGS84SRS<br>
GDALError = .SetProjCS("WGS84 Datum")<br>
Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
GDALError = .SetWellKnownGeogCS("WGS84") ' Define WGS84 coordinate system<br>
Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
End With<br>
<br>
</div>Produces PROJCS["WGS84 Datum",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]]<br>
With UTMSRS<br>
GDALError = .SetProjCS("UTM coordinate system")<br>
Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
GDALError = .SetWellKnownGeogCS("WGS84") ' Define a UTM coordinate system<br>
<div class="im"> Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
End With<br>
<br>
</div>Produces PROJCS["UTM coordinate system",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]]<br>
<div class="im"><br>
With MapSRS<br>
GDALError = .SetProjCS("Map coordinate system")<br>
Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
</div> GDALError = .ImportFromEPSG(i)<br>
<div class="im"> Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
End With<br>
<br>
</div>Produces GEOGCS["GDA94",DATUM["Geocentric_Datum_of_Australia_1994",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6283"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4283"]]<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 "PROJCS"<br>
<br>
I feel I'm very close to the answer, but I still can't see it.<br>
<div class="im"><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">6wyv643jct@sneakemail.com</a>]<br>
Sent: Wednesday, October 19, 2011 7:54 PM<br>
To: <a href="mailto:marc.hillman@tpg.com.au">marc.hillman@tpg.com.au</a>; <a href="mailto:dev4cx4m9z@snkmail.com">dev4cx4m9z@snkmail.com</a><br>
Subject: Re: [gdal-dev] Confused about datum transformations<br>
<br>
</div>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'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've lost count of the number of times I'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<br>
<div class="im"><br>
<a href="mailto:dev4cx4m9z@snkmail.com">dev4cx4m9z@snkmail.com</a> wrote:<br>
> I have not used org2ogr. I have just realised that the C API for GDAL<br>
> uses a mixture of STD and CDECL. How annoying. Anyway – I have<br>
> carefully checked and all are correct. I get a stack balance problem<br>
> 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>
><br>
><br>
><br>
> I still don’t know whether proj.dll is required.<br>
><br>
><br>
><br>
> From: Chaitanya kumar CH <a href="http://chaitanya.ch-at-gmail.com" target="_blank">chaitanya.ch-at-gmail.com</a> |GDAL|<br>
> [mailto:<a href="mailto:5rm5yuc82t@sneakemail.com">5rm5yuc82t@sneakemail.com</a>]<br>
> Sent: Wednesday, October 19, 2011 6:36 PM<br>
> To: <a href="mailto:marc.hillman@tpg.com.au">marc.hillman@tpg.com.au</a>; <a href="mailto:dev4cx4m9z@snkmail.com">dev4cx4m9z@snkmail.com</a><br>
> Cc: <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
> Subject: Re: [gdal-dev] Confused about datum transformations<br>
><br>
><br>
><br>
> Marc,<br>
><br>
> You don'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>
><br>
> What you need to do is find out if the arguments you are passing to the transformation builder are good. Especially 'MapSRS'. If it doesn't show any problem, plug some debug messages in the OSR code in ogrct.cpp and rebuild gdal.<br>
><br>
> On Wed, Oct 19, 2011 at 12:46 PM, <<a href="mailto:dev4cx4m9z@snkmail.com">dev4cx4m9z@snkmail.com</a>> wrote:<br>
><br>
> 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>
><br>
><br>
><br>
> 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>
><br>
><br>
><br>
> I have set GDAL_DATA to the correct folder.<br>
><br>
> I have checked that the datum numbers I use are in the gcs.csv file.<br>
><br>
><br>
><br>
> From: <a href="mailto:gdal-dev-bounces@lists.osgeo.org">gdal-dev-bounces@lists.osgeo.org</a><br>
> [mailto:<a href="mailto:gdal-dev-bounces@lists.osgeo.org">gdal-dev-bounces@lists.osgeo.org</a><br>
</div>> <mailto:<a href="mailto:gdal-dev-bounces@lists.osgeo.">gdal-dev-bounces@lists.osgeo.</a>.org> ] On Behalf Of<br>
<div><div></div><div class="h5">> <a href="mailto:dev4cx4m9z@snkmail.com">dev4cx4m9z@snkmail.com</a><br>
> Sent: Tuesday, October 18, 2011 4:12 AM<br>
> To: <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
> Subject: RE: [gdal-dev] Confused about datum transformations<br>
><br>
><br>
><br>
> I’m not sure the code will help too much, but here are the relevant<br>
> code fragments. I’m using a hand crafted VB.net wrapper which explains<br>
> some of the syntax<br>
><br>
><br>
><br>
> Private WGS84SRS As New OGRSpatialReference ' Coordinate system in WGS84<br>
><br>
> Private MapSRS As OGRSpatialReference ' Coordinate system of map<br>
><br>
> Private ctWGS84toMap As OGRCoordinateTransformation ' Coordinate transform from WGS84 to map<br>
><br>
><br>
><br>
> With WGS84SRS<br>
><br>
> GDALError = .SetProjCS("WGS84 Datum")<br>
><br>
> Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
><br>
> GDALError = .SetWellKnownGeogCS("WGS84") ' Define WGS84 coordinate system<br>
><br>
> Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
><br>
> End With<br>
><br>
><br>
><br>
> With MapSRS<br>
><br>
> GDALError = .SetProjCS("Map coordinate system")<br>
><br>
> Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
><br>
> GDALError = .ImportFromEPSG(3577)<br>
><br>
> Debug.Assert(GDALError = OGRError.OGRERR_NONE, GetLastErrorMsg())<br>
><br>
> End With<br>
><br>
><br>
><br>
> ctWGS84toMap = GDAL.CreateCoordinateTransformation(WGS84SRS, MapSRS) ' Create a coordinate transformation - WGS84 to map<br>
><br>
> Debug.Assert(ctWGS84toMap IsNot Nothing, GetLastErrorMsg())<br>
><br>
><br>
><br>
> Marc,<br>
><br>
> Can you provide the code leading to the error?<br>
><br>
> On Tue, Oct 18, 2011 at 1:21 PM, Marc Hillman <<a href="mailto:dev4cx4m9z@snkmail.com">dev4cx4m9z@snkmail.com</a>> wrote:<br>
><br>
> 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>
><br>
><br>
><br>
> 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>
><br>
><br>
><br>
><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>
><br>
><br>
><br>
><br>
><br>
><br>
</div></div>> ----------------------------------------------------------------------<br>
> --<br>
<div class="im">><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>
<br>
--<br>
</div>--------------------------------------------------------------------------------<br>
Peter J Halls, GIS Advisor & 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>
-----<br>
<div class="im">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<br>
<br>
</div><div><div></div><div class="h5">_______________________________________________<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>
</div></div></blockquote></div><br>