AnsweredAssumed Answered

Object of type 'FeatureLayer' is not JSON serializable when trying to select features using a query

Question asked by Missouri_EMGIS on Apr 9, 2018

Using ArcGIS API for Python, I'm attempting to build a script that selects only National Weather Service warning polygons from a feature layer in my AGOL organization.


First I brought in my AGOL Org feature layer containing all NWS weather alerts using this line:

wwas ='title: Warnings', item_type="feature service", outside_org=False)[0]

Next I want to select only the warning polygons out of that layer, which are coded as 'W' in the "sig" field:

warnings = find_existing_locations(wwas, "sig = 'W'", "only_NWS_warnings")

The error I get reads:

Object of type 'FeatureLayer' is not JSON serializable

At first I thought it was my query expression ("sig = 'W'"), but Python keeps referencing a argument of the function called "context":

~\anaconda3\lib\site-packages\arcgis\features\ in find_existing_locations(input_layers, expressions, output_name, context, gis)

53         expressions,    

54         output_name,

---> 55         context)    



Based on the documentation, context is an optional strong, so I'm not sure why it would pass an error when I've included the mandatory arguments (input_layers, expressions, output_name).