Hi to all,
I tried this script with ArcGIS API from Python 1.4.2 like arcgis.geometry module — arcgis 1.4.2 documentation .
from arcgis.gis import GIS
from arcgis import geometry
input_geom = [{"x": -17568824.55, "y": 2428377.35}, {"x": -17568456.88, "y": 2428431.352}]
result = geometry.project(geometries = input_geom, in_sr = 3857, out_sr = 4326)
I get this error:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-8-a89d8e1c23f7> in <module>() ----> 1 result = geometry.project(geometries = input_geom, in_sr = 3857, out_sr = 4326, ) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\geometry\functions.py in project(geometries, in_sr, out_sr, transformation, transform_foward, gis) 646 if gis is None: 647 gis = arcgis.env.active_gis --> 648 return gis._tools.geometry.project( 649 geometries, 650 in_sr, AttributeError: 'NoneType' object has no attribute '_tools'
What I'm doing wrong?
Thanks Karsten
Solved! Go to Solution.
It looks like you need to connect to a GIS first. This worked for me:
from arcgis.geometry import project
from arcgis.gis import GIS
# This is the line you're missing
gis = GIS()
input_geoms = [{"x": -17568824.55, "y": 2428377.35}, {"x": -17568456.88, "y": 2428431.352}]
result = project(geometries=input_geoms, in_sr=3857, out_sr=4326)
result
It looks like you need to connect to a GIS first. This worked for me:
from arcgis.geometry import project
from arcgis.gis import GIS
# This is the line you're missing
gis = GIS()
input_geoms = [{"x": -17568824.55, "y": 2428377.35}, {"x": -17568456.88, "y": 2428431.352}]
result = project(geometries=input_geoms, in_sr=3857, out_sr=4326)
result