Error when running example code from geometry.project (ArcGIS API for Python)

1147
2
Jump to solution
02-23-2019 01:28 PM
MikieKelly
New Contributor III

Hello community,

Any ideas why the following code doesn't work?

from arcgis import geometry

input_geometry = [{
  "xmin": 191038.7271550147,
  "ymin": 493884.06809108134,
  "xmax": 1011248.7009082956,
  "ymax": 971193.3560429906,
  "spatialReference": {
    "wkid": 2157,
    "latestWkid": 2157
  }
}]
projected_extent = geometry.project(geometries=input_geometry,
                                    in_sr=2157,
                                    out_sr=4326)
print(projected_extent)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I get the following error message:

AttributeError: 'NoneType' object has no attribute '_tools'

The same error appears when I run the example code snippet in the documentation on which this is based:

from arcgis.geometry import project

input_geom = [{'x': -17568824.55, 'y': 2428377.35}, {'x': -17568456.88, 'y': 2428431.352}]
result = project(geometries=input_geom, in_sr=3857, out_sr=4326)

print(result)‍‍‍‍‍‍‍‍‍‍

I could construct the request myself, but would rather use the API.

Any suggestions appreciated!

Cheers,

Mikie

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

You don't have an active GIS defined.  Add the following 2 lines before your code:

from arcgis.gis import GIS
gis = GIS()

View solution in original post

2 Replies
JoshuaBixby
MVP Esteemed Contributor

You don't have an active GIS defined.  Add the following 2 lines before your code:

from arcgis.gis import GIS
gis = GIS()
MikieKelly
New Contributor III

Thanks Joshua - that does the trick!