3

I am using the following code segment to create a spatial reference.

    spatialReferance = arcpy.SpatialReference()
    spatialReferance.factoryCode = spatialReferanceFactoryCode
    spatialReferance.create()

But it gives the following error:

Runtime error : ERROR 999999: Error executing function. the input string is not a geographic or projected coordinate system

How can I programmatically determine whether a factory code is valid or not?

blah238
  • 35,793
  • 7
  • 94
  • 195
Emi
  • 2,405
  • 2
  • 22
  • 40

1 Answers1

8

See Do ArcGIS SpatialReference object factory codes correspond with EPSG numbers? in particular @mkennedy and @blah238 answers.

As to whether a factory code is valid or not... In Python, you can use the EAFP method (Easier to Ask for Forgiveness than Permission)

try:
    spatialReference.factoryCode = spatialReferenceFactoryCode
    spatialReference.create()
except RuntimeError:
    print 'factoryCode is not valid'
user2856
  • 65,736
  • 6
  • 115
  • 196