I'm seeing this problem in Pro 2.5 through 2.7.
print("Initializing...")
import arcgis
def ExtentTest():
sUrl = "https://services5.arcgis.com/4LKAHwqnBooVDUlX/ArcGIS/rest/services/ParkBoundaries/FeatureServer/0"
sWhere = "ParkName = 'Alta Lake'"
lyr = arcgis.features.FeatureLayer(sUrl)
result = lyr.query(sWhere, return_extent_only=True)
env = arcgis.geometry.Geometry(result["extent"])
print("Env: " + str(env))
sr = env.spatial_reference.as_arcpy
print("SR (arcpy): " + str(sr))
# arcgis.geometry.Envelope.as_arcpy blows away spatial reference
ext = env.as_arcpy
print("Env (arcpy) sr: " + str(ext.spatialReference))
return
print("Running...")
ExtentTest()
print("Done.")
Solved! Go to Solution.
log an issue here
Esri/arcgis-python-api: Documentation and samples for ArcGIS API for Python (github.com)
They don't visit here much
Geometry class is in
C:\Your_install_folder\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\geometry\_types.py
v = getattr(env.polygon.as_arcpy, "spatialReference", None)
v.type
'Projected'
v.PCSCode
2927
v.PCSName
'NAD_1983_HARN_StatePlane_Washington_South_FIPS_4602_Feet'
# ----
e = env.as_arcpy
type(e)
<class 'arcpy.arcobjects.arcobjects.Extent'>
print(e.JSON)
{"xmin":1775364.7645293027,"ymin":980995.92591956258,"xmax":1780568.8384387195,"ymax":985114.23001889884}
print(e.spatialReference)
None # ---- 'tis gone
# ----- now
e.spatialReference = v
e.JSON
'{"xmin":1775364.7645293027,"ymin":980995.92591956258,"xmax":1780568.8384387195,"ymax":985114.23001889884,"spatialReference":{"wkid":2927,"latestWkid":2927}}'
# ---- spatial reference is back
Yup, I'm seeing the same.
log an issue here
Esri/arcgis-python-api: Documentation and samples for ArcGIS API for Python (github.com)
They don't visit here much
Geometry class is in
C:\Your_install_folder\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\geometry\_types.py
v = getattr(env.polygon.as_arcpy, "spatialReference", None)
v.type
'Projected'
v.PCSCode
2927
v.PCSName
'NAD_1983_HARN_StatePlane_Washington_South_FIPS_4602_Feet'
# ----
e = env.as_arcpy
type(e)
<class 'arcpy.arcobjects.arcobjects.Extent'>
print(e.JSON)
{"xmin":1775364.7645293027,"ymin":980995.92591956258,"xmax":1780568.8384387195,"ymax":985114.23001889884}
print(e.spatialReference)
None # ---- 'tis gone
# ----- now
e.spatialReference = v
e.JSON
'{"xmin":1775364.7645293027,"ymin":980995.92591956258,"xmax":1780568.8384387195,"ymax":985114.23001889884,"spatialReference":{"wkid":2927,"latestWkid":2927}}'
# ---- spatial reference is back