Where is the spatial reference information for maps and layers in ArcGIS Online?
I've learned through experimentation a few relevant things:
I guess the system mostly works, since most of the time you don't need to be aware of what the spatial reference is, and layers either display or produce errors. And since feature layers are projected on the fly, issues with those don't arise. However, i often work with imagery that I want to add to a map, and unless I've included clues like "UTM" in the title of the raster layer, I don't know what is in which coordinate system.
Am I missing something? This would seem to be easy enough to provide, but my digging hasn't revealed anything.
Solved! Go to Solution.
You can find this information in the REST service directory endpoint for your feature/item.
In AGOL, navigate to your content then open up your item page 'Overview' tab. At the bottom right of the page you have a box with 'URL' above it.
Click on 'View' (just above the box on the right hand side). This then takes you to the REST directory page for that service. There should then be a heading in bold called 'Spatial Reference' and the corresponding WKID.
You can find this information in the REST service directory endpoint for your feature/item.
In AGOL, navigate to your content then open up your item page 'Overview' tab. At the bottom right of the page you have a box with 'URL' above it.
Click on 'View' (just above the box on the right hand side). This then takes you to the REST directory page for that service. There should then be a heading in bold called 'Spatial Reference' and the corresponding WKID.
Indeed, it's there, at least for data. For the map, that box isn't there, but it's easy enough to go to the basemap layers, which will have it.
Yes the basemap of the webmap dictates the spatial reference/projection of all other data, it's not an inherent property of the WebMap.
Hi @JerryDavis
Just an alternative and to place here for others that come across your post as it might be helpful. The below Python code snippet allows for quick access to spatial reference information. You can add in other item types as required. I use this as a basis for quality checking as all our data should be in the same coordinate system and this will go through all Layers in a WebMap or provide for a Feature Service/Image Service, and I can easily find deviations where we have published data in the wrong SRS in error.
from arcgis.gis import GIS
## connect to agol
agol = GIS("home")
## access the item by Item ID
item = agol.content.get("INSERT_ITEM_ID")
## if it is a feature service or image service
if item.type in ("Feature Service", "Image Service"):
## then print the WKID of the SRS
print("WKID: {0}".format(item["spatialReference"]))
## if it is a WebMap
elif item.type == "Web Map":
## access the json data
wm_data = item.get_data()
## print the SRS for the WebMap
print("WebMap WKID: {0}".format(wm_data["spatialReference"]))
## iterate through each layer in the WebMap
for lyr in wm_data["operationalLayers"]:
## print the name of each layer
print("Layer Name: {0}".format(lyr["title"]))
## access the item each layer comes from
item = agol.content.get(lyr["itemId"])
## print the WKID for each layer
print("\t WKID: {0}".format(item["spatialReference"]))
## otherwise print the item type
## can add in another elif to catch this item.typoe as needed
else:
print(item.type)
This has proven very helpful - I've been trying to find a way to bulk export spatial reference information for our ArcGIS Online content for a while and glad I finally stumbled on this code. Nothing else I have found or tried to create myself has worked for feature services - only feature classes.