Select to view content in your preferred language

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

987
0
04-09-2018 07:52 AM
KonradHughes
Emerging Contributor

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 = gis.content.search('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\find_locations.py in find_existing_locations(input_layers, expressions, output_name, context, gis)

53         expressions,    

54         output_name,

---> 55         context)    

56     

57

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).

Tags (1)
0 Kudos
0 Replies