<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Peter,<div><br></div><div>Thanks for your reply - yes, that's exactly what I want to do - transform to cartesian coords.</div><div><br></div><div>Here's the math that I've already got... I was just wondering if GDAL's transform object somehow encapsulated it.</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp;&nbsp; &nbsp;latitude *= <span style="color: #643820">DEG_TO_RAD</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; longitude *= <span style="color: #643820">DEG_TO_RAD</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; <span style="color: #aa0d91">double</span> sinLatitude = <span style="color: #2e0d6e">sin</span>(latitude);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; <span style="color: #aa0d91">double</span> cosLatitude = <span style="color: #2e0d6e">cos</span>(latitude);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; <span style="color: #aa0d91">double</span> N = wgs84SemiMajorAxis / <span style="color: #2e0d6e">sqrt</span>(<span style="color: #1c00cf">1.0</span> - sinLatitude * sinLatitude * sinAngularEccentricitySq);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; <span style="color: #aa0d91">double</span> h = elevation;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; x = (N + h) * cosLatitude * <span style="color: #2e0d6e">cos</span>(longitude);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; y = (N * cosAngularEccentricitySq + h) * sinLatitude;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">&nbsp; &nbsp; z = (N + h) * cosLatitude * <span style="color: #2e0d6e">sin</span>(longitude);</div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div></div><div>Apparently not though given your reply. :-)</div><div><br></div><div>Kind regards,</div><div>Christopher</div><div><br><div><div>On 03/07/2009, at 5:44 PM, Peter J Halls wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Christopher,<br><br> &nbsp;&nbsp;&nbsp;WGS84 *is* a spherical model. &nbsp;In any spherical coordinate system, x &amp; y are represented by angles to the centre of the sphere. &nbsp;No projection equation is going to return you x &amp; y in metres for a sphere: it makes no sense of the maths. &nbsp;The 'baseline' surface can be obtained from the projection specification - ie the radius or ellipsoid dimensions which, with the angle, enable a surface point to be calculated by simple trigonometry. &nbsp;Normally, one applies the local datum parameters, in order to resolve the complications of the Earth's irregular surface. &nbsp;The projection parameters are standard and defined in the GCS table - look in the GDAL/data directory for gcs.csv.<br><br> &nbsp;&nbsp;&nbsp;There is no projection that represents the planet in a solid, 3d space using Cartesian dimensions: it simply does not make sense to attempt. &nbsp;Maybe it would be useful to look out the 'bible' on map projections - 'Map Projections: a working manual' by the late John P Snyder ... it is available for download from the USGS web site. &nbsp;The opening chapter of that book explains why and how projections work: I think that may not only help you understand what was wrong with your question but also enable you to see how to achieve your goal. &nbsp;The later chapters give the equations for the various projections.<br><br>Best wishes,<br><br>Peter<br><br>Christopher Hunt wrote:<br><blockquote type="cite">Sorry for the hopefully not so dumb question here.<br></blockquote><blockquote type="cite">If I want to transform from one projection to a projection of the earth in 3D, how would I set up my target srs?<br></blockquote><blockquote type="cite">I want to take a WGS-84 lat/long/elevation and have an x,y,z returned in metres.<br></blockquote><blockquote type="cite">Here's my present code:<br></blockquote><blockquote type="cite"> &nbsp;// Read the image's projection<br></blockquote><blockquote type="cite"> &nbsp;OGRSpatialReference projSpatialReference(dataset-&gt;GetProjectionRef());<br></blockquote><blockquote type="cite"> &nbsp;scoped_ptr&lt;OGRSpatialReference&gt; latLongSpatialReference(projSpatialReference.CloneGeogCS());<br></blockquote><blockquote type="cite"> &nbsp;transform = OGRCreateCoordinateTransformation(latLongSpatialReference.get(), &amp;projSpatialReference);<br></blockquote><blockquote type="cite">...and of course that transforms from lat/long/elevation to the projection srs nicely. What I'm looking for is a way to specify the target srs so that it yields the x, y, z values for WGS84 3d sphere i.e. the earth.<br></blockquote><blockquote type="cite">Kind regards,<br></blockquote><blockquote type="cite">Christopher<br></blockquote><blockquote type="cite">------------------------------------------------------------------------<br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">gdal-dev mailing list<br></blockquote><blockquote type="cite"><a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br></blockquote><blockquote type="cite"><a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote><br>-- <br>--------------------------------------------------------------------------------<br>Peter J Halls, GIS Advisor, University of York<br>Telephone: 01904 433806 &nbsp;&nbsp;&nbsp;&nbsp;Fax: 01904 433740<br>Snail mail: Computing Service, University of York, Heslington, York YO10 5DD<br>This message has the status of a private and personal communication<br>--------------------------------------------------------------------------------<br></div></blockquote></div><br></div></body></html>