Good Morning,
I am trying to calculate geometry attributes (polygon extents, point centroids, areas etc) on a feature service hosted in our stand alone portal using notebooks and the ArcGIS API for Python. Our data is branch versioned and hosted on an enterprise portal. What I cannot figure out is how to field calculate things like geometry, extents, and point centroids in different coordinates. It seems the syntax on the API reference page doesn't work when trying to work with data accessed and assigned to a spatially enable data frame. Am I using the spatially enable data frame incorrectly or is there a different way this should be computed?
This is what I would like to be able to do:
1. Calculate area (this can also be done using attribute rules)
2. Calculate the XY min/max extents of polygons in decimal degrees (not the spatial reference of the item)
3. Calculate centroids in decimal degrees.
Here is the code below. My problem is the feature set/spatially enable data frame is a dictionary and it appears the geometry module doesn't work the same with those items. The error I receive below:
AttributeError: 'dict' object has no attribute 'area'
from arcgis.gis import GIS
#import modules
from arcgis.features import *
from arcgis.geometry import *
import os
import datetime
#access portal and pull the feature service and layer for analysis
gis = GIS('home')
search_result = gis.content.search('NotebookTesting', 'Feature Layer')
item = search_result[0]
item_layers = item.layers
feature_layer = item_layers[0]
#check if editing and updating are enabled
feature_layer.properties.capabilities
#query the layer for items that meet criteria ie area is null
fset = feature_layer.query(where = 'AreaSqFeet IS NULL')
flayer_rows = fset.sdf
fset.sdf
for index, row in flayer_rows.iterrows():
if row ['Area_SqFeet'] == None:
fset.features[index].geometry.area # here is where I think I would calculate area, centroids and extents
feature_layer.edit_features(updates = fset.features)