Select to view content in your preferred language

Adding Fields and Features to a Feature Layer

01-26-2018 03:34 AM
New Contributor III

I added fields to a Feature Layer and now there are problems with adding Features to this. So I would like to ask, how can I solve this issue?

This is my actual workflow:

I have a Feature Service with a Feature Layer and I want to join this with the structure and data into another Feature Service which has already some Feature Layers. An empty feature 

1. I get the necessary information for the new Feature Layer form the existing one (fields, geometry type and name). This information is stored in a dictionary with the correct key as they are required in the layer description. The "Shape_length", "Shape_area" and "FID" fields are removed.

dictLayer = {}
dictLayer["fields"] =["fields"]
dictLayer["geometryType"] =["geometryType"]
dictLayer["name"] =["name"]‍‍‍‍

2. The dictionary is appended to a list and a dictionary is built out of this. This dictionary is used to update the layer's definition. This works very well and the layer with the fields occures in ArcGIS Online.

layersList = []

dictUpdate = {"layers" : layersList }

3. The features that should be added to the layer are converted into a FeatureSet. Now there are many Features that should be added to the Feature Layer in one list. This meets the requirements of the "edit_features()" method. So this method is called with the Feature Set as parameter

layerEdit.edit_features(adds = fset)

When this function is executed this error message occures:

The given key was not present in the dictionary.
---------------------------------------------------------------------------RuntimeError                              Traceback (most recent call last)<ipython-input-35-f124a193606a> in <module>()----> 1 layerEdit.edit_features(adds = fset)~\AppData\Local\Continuum\Anaconda3\envs\arcgis\lib\site-packages\arcgis-1.3.0-py3.5.egg\arcgis\features\ in edit_features(self, adds, updates, deletes, gdb_version, use_global_ids, rollback_on_failure)    943             print("Parameters not valid for edit_features")    944             return None--> 945         return, postdata=params, token=self._token)    946     947     # ----------------------------------------------------------------------~\AppData\Local\Continuum\Anaconda3\envs\arcgis\lib\site-packages\arcgis-1.3.0-py3.5.egg\arcgis\_impl\ in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token, verify_cert, token, try_json, out_folder, file_name, force_bytes, add_headers)   1151                                          verify_cert=verify_cert, is_retry=True)   1152 -> 1153                 self._handle_json_error(resp_json['error'], errorcode)   1154                 return None   1155         except AttributeError:~\AppData\Local\Continuum\Anaconda3\envs\arcgis\lib\site-packages\arcgis-1.3.0-py3.5.egg\arcgis\_impl\ in _handle_json_error(self, error, errorcode)   1171    1172         errormessage = errormessage + "\n(Error Code: " + str(errorcode) +")"-> 1173         raise RuntimeError(errormessage)   1174    1175 class _StrictURLopener(request.FancyURLopener):RuntimeError: The given key was not present in the dictionary. (Error Code: 500)

It seams to me as there is a problem with the geometry. Because i get a query result with all Features and attributes but there is no information about Shape_Area and Shape_Length.

When I swith to the "Data" tab in ArcGIS Online there is a number of Features but no entry in the Table view.

This is the URL to the Service of this example: 

What is the reason for this problem?


0 Kudos
0 Replies