Error creating spatial reference from Alaska state plane system

936
5
Jump to solution
04-10-2019 10:50 AM
RyanDavis1
Occasional Contributor

We have a state plane feature class that covers the entire United States.  We use it to find the name of a coordinate system and plug it into arcpy.SpatialReference().  This works great for everywhere but most Alaska coordinate systems.

For some reason, it fails on every Alaska coordinate system except for one.

For what it's worth, it will accept the WKID. 

I know it's probably better to use the WKID than a string, but I inherited this project and it's not currently set up to use the WKID. 

Does anyone have a reason why the function would accept the first Alaska value, but not the second?  I can't tell if this is a bug or if someone on my end failed to update coordinate system names.  Is there a file to browse accepted system names?  The PDF (http://desktop.arcgis.com/en/arcmap/10.5/analyze/arcpy-classes/pdf/projected_coordinate_systems.pdf) isn't much help.

Thanks.

0 Kudos
1 Solution

Accepted Solutions
MelitaKennedy
Esri Notable Contributor

Ah, how tricky of me. I think to align the zone numbers, there are 2 spaces before the numbers for zones 1 - 9. This occurs in the "display names" used in the coordinate system picker, not in the CRS names themselves. Here's one of them:

"NAD 1983 StatePlane Alaska  1 FIPS 5001 (US Feet)"

Beware, when I copy-pasted it, the second space was stripped out. I had to add it back in. This is true in all the AK zones across the various geographic CRS/datums because I always copy and paste the set (in Notepad which doesn't change the spaces) and then update the geographic CRS names.

Melita

edit was to add phrase in last sentence.

View solution in original post

5 Replies
DanPatterson_Retired
MVP Emeritus

fails for me even when raw encoding the string... spaces or not don't make a difference, but the WKID is fine

Melita Kennedy‌ bug? or something obviously missed?

0 Kudos
MelitaKennedy
Esri Notable Contributor

Ah, how tricky of me. I think to align the zone numbers, there are 2 spaces before the numbers for zones 1 - 9. This occurs in the "display names" used in the coordinate system picker, not in the CRS names themselves. Here's one of them:

"NAD 1983 StatePlane Alaska  1 FIPS 5001 (US Feet)"

Beware, when I copy-pasted it, the second space was stripped out. I had to add it back in. This is true in all the AK zones across the various geographic CRS/datums because I always copy and paste the set (in Notepad which doesn't change the spaces) and then update the geographic CRS names.

Melita

edit was to add phrase in last sentence.

DanPatterson_Retired
MVP Emeritus

Use underscores... spaces are evil

RyanDavis1
Occasional Contributor

Ahhh, that makes sense.  

Yet another argument to use the WKID, but this should help me get to a quick fix.

Thank you both Dan Patterson‌ and Melita Kennedy‌.

0 Kudos
RandyBurton
MVP Alum

I have had several occasions to need the name of coordinate system, with no underscores, the proper spacing, parenthesis around 'feet', etc.  I noticed that ListSpatialReferences appears to provide that if you look at the function's return string.  A slight modification of the sample code by inserting line 9: 

import arcpy

# Get the list of spatial references
srs = arcpy.ListSpatialReferences("*alaska*")

# Create a SpatialReference object for each one and print the
# central meridian
for sr_string in srs:
    print sr_string.split('/')[-1] # coordinate system name text
    # sr_object = arcpy.SpatialReference(sr_string)
    # print "{0.centralMeridian}   {0.name}".format(sr_object)

'''
part of the output:

NAD 1983 StatePlane Alaska  1 FIPS 5001 (US Feet)
NAD 1983 StatePlane Alaska  2 FIPS 5002 (US Feet)
NAD 1983 StatePlane Alaska  3 FIPS 5003 (US Feet)
NAD 1983 StatePlane Alaska  4 FIPS 5004 (US Feet)
NAD 1983 StatePlane Alaska  5 FIPS 5005 (US Feet)
NAD 1983 StatePlane Alaska  6 FIPS 5006 (US Feet)
NAD 1983 StatePlane Alaska  7 FIPS 5007 (US Feet)
NAD 1983 StatePlane Alaska  8 FIPS 5008 (US Feet)
NAD 1983 StatePlane Alaska  9 FIPS 5009 (US Feet)
NAD 1983 StatePlane Alaska 10 FIPS 5010 (US Feet)
'''‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

You can see the double spaces after 'Alaska' and the parenthesis around 'feet'  in lines 16-24.

0 Kudos