Hi was so excited last year to see your posts and have been using the code examples to query and edit an AGOL item to update the polyline length. lyr.edit_features(updates = df.spatial.to_featureset()) edit_features takes a featureset for the updates parameter, and you can convert your dataframe directly to a featureset once you've performed your calculations. If you have trouble projecting your dataframe / geoseriesaccessor, as I sometimes do, note that you can also specify a different spatial reference to be output from your query itself, by specifying out_sr=* as a parameter.ĮDIT: I forgot to mention, when you're done, you can submit your edits in one go, rather than as part of an interative process. New_col_list = ĭf = df.apply(lambda extent: extent) Mind you, centroid and extent return tuples, so you may need to do some extra work to reformat that as needed for your fields. Lyr = ('itemID').layersĭf = lyr.query(where = 'AreaSqFeet IS NULL', as_df=True) # Using content.get avoids potentially inconsistent results from a search # Grab the layer directly, without as many intermediate outputs You can also use the project_as method to get those outputs into degrees.įrom arcgis.features import GeoSeriesAccessor This class allows you to perform operations like area, extent, etc., on an entire series of shapes, which avoids needing to iterate over your dataframe. Accomplishing your goal is quite simple, but you have to create an intermediate GeoSeriesAccessor object. In short, yes, you're not quite using the spatially enabled dataframe correctly. #query the layer for items that meet criteria ie area is nullįset = feature_layer.query(where = 'AreaSqFeet IS NULL')įor index, row in flayer_errows():į # here is where I think I would calculate area, centroids and extentsįeature_layer.edit_features(updates = fset.features) #check if editing and updating are enabled Search_result = ('NotebookTesting', 'Feature Layer') #access portal and pull the feature service and layer for analysis The error I receive below: AttributeError: 'dict' object has no attribute 'area' 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. Calculate the XY min/max extents of polygons in decimal degrees (not the spatial reference of the item)ģ. Calculate area (this can also be done using attribute rules)Ģ. This is what I would like to be able to do:ġ. Am I using the spatially enable data frame incorrectly or is there a different way this should be computed? 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. What I cannot figure out is how to field calculate things like geometry, extents, and point centroids in different coordinates. Our data is branch versioned and hosted on an enterprise portal. In most cases, field size limitation makes it likely that spatial reference strings will be truncated if you run this tool on a shapefile.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. Use geodatabase feature classes rather than shapefiles. If you receive this warning, delete your results, create a field of sufficient length (more than 600 characters), and rerun the tool. If you receive this warning, some of the spatial reference strings generated may have been truncated, making them useless. The tool will issue a warning if the spatial reference string has been truncated because the field length is not long enough. Spatial reference strings vary in length but are usually quite long, and you need to ensure that the field has enough space. The UTM Zone Field parameter, which contains the UTM spatial reference string, should have a length of 600 characters or more. For best results, the datum of your input features should be the same as the datum of the data frame. The tool does not perform any geotransformations. If a UTM zone is calculated, however, the result may not be accurate. If the datum of the feature's data source is different than that of the data frame, you will receive a warning. The datum for the calculated UTM coordinate system string is taken from the datum of the active data frame's coordinate system. You will receive a warning when a UTM zone cannot be calculated for a particular feature. Geometries located at extreme latitudes, near either the north or south pole, may not be appropriate for UTM zone calculation. Input features can be points, lines, or polygons.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |