6

I'm attemping to write a function to test if a list of datasets are in the same projection. Naively, I thought I could test the text of WKTs, but that does not work in the following case:

'PROJCS["NAD_1983_UTM_Zone_14N",GEOGCS["NAD83",DATUM["North_American_Datum_1983", ...'

'PROJCS["NAD83 / UTM zone 14N",GEOGCS["NAD83",DATUM["North_American_Datum_1983", ...'

Even though the projections are identical, and the rest of the WKT is identical, the tags leading them are not which makes me wonder if there is a formal mechanism for testing the equality of projection systems.

I am programming with the GDAL extensions in Python.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Feb 7, 2013 at 19:39

2 Answers 2

6

To add to @Mike T's answer, GDAL/OSR SpatialReference object has a IsSame() function that can be used in Python GDAL like so:

from osgeo import osr
spref1 = osr.SpatialReference()
spref1.ImportFromEPSG(4326)
spref2 = osr.SpatialReference()
spref2.ImportFromEPSG(4269)
comparison = spref1.IsSame(spref2)

If the value of comparison is 1 then it is the same spatial reference. In the above example, it will return 0.

answered Mar 26, 2020 at 3:21
6

Try importing the WKT into an GDAL/OSR SpatialReference object, and compare the non-zero SRIDs. It is much simpler to compare two integers than to compare two text markups.

Look at this answer to Shapefile PRJ to PostGIS SRID lookup table? to get an idea how to use GDAL for this purpose.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Feb 7, 2013 at 19:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.