[FWTools] Comparing SRS objects

David Fawcett david.fawcett at gmail.com
Mon Nov 20 09:36:11 EST 2006


In a Python script, I want to compare spatial reference systems.  For
context, I am creating a map image with Python MapScript, the map SRS is
UTM, the layer SRS for one of the layers could sometimes be in UTM or
sometimes in Lat/Long.  The extent of the map will be based on this layer.

As I build the layer, I want to check to see what SRS it is in, if it is in
Lat/Long, I am planning to grab it's extent in lat/long, create a rectObj,
and then project this rectObj to UTM so I can use the coordinates for my map
extent.

Assuming that this is a reasonable way to approach the problem, I am curious
how to use OGR, OSR, or MapScript to compare SRS's.  If I create SRS
objects, can I just check that they are equal, as below, or do I need to
dump them to WKT or proj Defs and do a string comparison?

e.g.

    srs_one = osr.SpatialReference()
    srs_two = osr.SpatialReference()

    srs_one .ImportFromEPSG(4326)
    srs_two .ImportFromEPSG(26915)

    if srs_one == srs_two:
        print "they are the same"
    else:
        print "they are different"


Thanks,

David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20061120/9f41b173/attachment.html


More information about the FWTools mailing list