Thanks guys. <br><br>Since I am really only looking at two potential SRS's, I think that I will end up dumping the SRS to wkt and using the find() method to see if the wkt contains 'NAD_1983_UTM_Zone_15N' or even just 'UTM' or 'WGS', depending on which one I am looking for.
<br><br>I was hoping to write something that was more extensible, but don't really need to. When I came up with the idea for this script, I had just assumed that there was a exportToEPSG() function ; /<br><br>Ed, I appreciate your comments on how there really is no good way to do this. With the relatively small community of people writing Python GDAL and MapScript code, it is hard to get a feeling for best practices or most efficient ways of doing things.
<br><br>David.<br><br><div><span class="gmail_quote">On 11/20/06, <b class="gmail_sendername">Ed McNierney</b> <<a href="mailto:ed@topozone.com">ed@topozone.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
David -<br><br>In my (limited) experience I have found this an exceptionally difficult<br>thing to do. I found it hard enough that I gave up!<br><br>We used to offer an ArcIMS interface to our WMS image services. We<br>
created an ArcIMS emulator that, in essence, translated ArcIMS image<br>requests to WMS image requests. This worked fine until ESRI changed the<br>ArcGIS client interface so it specified the image SRS in WKT format<br>rather than with an EPSG index. Since the WMS interface required an
<br>EPSG index, we needed to translate arbitrary WKT descriptions (esp.<br>ESRI-flavored ones) into EPSG codes. Oy! Since there is a reasonable<br>degree of flexibility in a WKT description, it is quite easy to come up<br>
with two WKT projections that are, in practice, "the same projection"<br>but which look different.<br><br>Fortunately, that was the same release in which ESRI added real OGC WMS<br>client support to ArcGIS, so we simply surrendered and discontinued
<br>ArcIMS support, and provided support exclusively for our OGC WMS<br>interface.<br><br>This is one of the chief benefits, IMHO, of the EPSG or any other<br>catalog-style system. EPSG:4326 is the same as EPSG:4326 and is not the
<br>same as EPSG:26915 and that's pretty darn easy to figure out.<br><br> - Ed<br><br>Ed McNierney<br>President and Chief Mapmaker<br>TopoZone.com / Maps a la carte, Inc.<br>73 Princeton Street, Suite 305<br>North Chelmsford, MA 01863
<br><a href="mailto:ed@topozone.com">ed@topozone.com</a><br>(978) 251-4242<br><br>-----Original Message-----<br>From: <a href="mailto:fwtools-bounces@lists.maptools.org">fwtools-bounces@lists.maptools.org</a><br>[mailto:<a href="mailto:fwtools-bounces@lists.maptools.org">
fwtools-bounces@lists.maptools.org</a>] On Behalf Of Frank Warmerdam<br>Sent: Monday, November 20, 2006 4:26 PM<br>To: David Fawcett<br>Cc: <a href="mailto:fwtools@lists.maptools.org">fwtools@lists.maptools.org</a><br>Subject: Re: [FWTools] Comparing SRS objects
<br><br>David Fawcett wrote:<br>> In a Python script, I want to compare spatial reference systems. For<br>> context, I am creating a map image with Python MapScript, the map SRS<br>> is UTM, the layer SRS for one of the layers could sometimes be in UTM
<br>> or sometimes in Lat/Long. The extent of the map will be based on this<br>layer.<br>><br>> As I build the layer, I want to check to see what SRS it is in, if it<br>> is in Lat/Long, I am planning to grab it's extent in lat/long, create
<br>> a rectObj, and then project this rectObj to UTM so I can use the<br>> coordinates for my map extent.<br>><br>> Assuming that this is a reasonable way to approach the problem, I am<br>> curious how to use OGR, OSR, or MapScript to compare SRS's. If I
<br>> create SRS objects, can I just check that they are equal, as below, or<br><br>> do I need to dump them to WKT or proj Defs and do a string comparison?<br>><br>> e.g.<br>><br>> srs_one = osr.SpatialReference
()<br>> srs_two = osr.SpatialReference()<br>><br>> srs_one .ImportFromEPSG(4326)<br>> srs_two .ImportFromEPSG(26915)<br>><br>> if srs_one == srs_two:<br>> print "they are the same"
<br>> else:<br>> print "they are different"<br><br>David,<br><br>I think this will only determine if they are the same object, not if the<br>coordinate system description is the same. There is an IsSame() method
<br>on the osr.SpatialReference, so you could instead do:<br> if srs_one.IsSame(srs_two):<br> ...<br><br>that said, the IsSame() method is not really very robust.<br><br>Another approach would be to convert them both to WKT and compare those
<br>strings, though you will get a lot of apparent differences which are not<br>actually significant to the underlying definition.<br><br>Best regards,<br>--<br>---------------------------------------+--------------------------------
<br>---------------------------------------+------<br>I set the clouds in motion - turn up | Frank Warmerdam,<br><a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a><br>light and sound - activate the windows | <a href="http://pobox.com/~warmerdam">
http://pobox.com/~warmerdam</a><br>and watch the world go round - Rush | President OSGeo,<br><a href="http://osgeo.org">http://osgeo.org</a><br><br>_______________________________________________<br>FWTools mailing list
<br><a href="mailto:FWTools@lists.maptools.org">FWTools@lists.maptools.org</a><br><a href="http://lists.maptools.org/mailman/listinfo/fwtools">http://lists.maptools.org/mailman/listinfo/fwtools</a><br><a href="http://fwtools.maptools.org/">
http://fwtools.maptools.org/</a><br></blockquote></div><br>