Hello Esri Community,
I'm working on a project where a user submits a shapefile to a website and among other things, the spatial reference of that shapefile will be stored.
Is there any way I can extract the spatial reference of that submitted shapefile? Since we're not using ArcMap nor ArcPro, we can't use arcpy unfortunately - It must be done through API for Python.
Attached below is a sample zipped shapefile that I'm currently working on.
Any help on this is greatly appreciated!
Regards,
Mina
Solved! Go to Solution.
Hi @Anonymous User
The below assumes the shapefile is available in AGOL.
Use the shapefile item id
from arcgis.gis import GIS
## connect to agol
agol = GIS("Your AGOL URL", "username", "password")
## access the shapefile item
item = agol.content.get("shapefile_item_id_in_agol")
## print the spatial reference
print(item["spatialReference"])
Isn't the projection info found in the SitesForDemo_NAD83_Snapped.prj file that's packaged up in the zip file? I guess without arcpy you would have to temporarily unzip that file and read thru it to locate: PROJCS ["NAD_1983_2011_UTM_Zone_11N"
However, there's nothing that says/guarantees that what is being uploaded will contain that .prj file and you would have to handle that in your code.
Hi @Anonymous User
The below assumes the shapefile is available in AGOL.
Use the shapefile item id
from arcgis.gis import GIS
## connect to agol
agol = GIS("Your AGOL URL", "username", "password")
## access the shapefile item
item = agol.content.get("shapefile_item_id_in_agol")
## print the spatial reference
print(item["spatialReference"])
Isn't the projection info found in the SitesForDemo_NAD83_Snapped.prj file that's packaged up in the zip file? I guess without arcpy you would have to temporarily unzip that file and read thru it to locate: PROJCS ["NAD_1983_2011_UTM_Zone_11N"
However, there's nothing that says/guarantees that what is being uploaded will contain that .prj file and you would have to handle that in your code.