I have a Notebook published as a web tool and configured for use in the Analysis widget in ExB. I have the input parameter type set to Feature Set. I select the features, set it as the analysis input, run the tool. It sends the features to the notebook/web tool, but they do not appear to be a feature set.
I get errors trying to do any operations on the feature set in the notebook. It says the type is <class 'dict>. Am I doing something wrong on the input side, or do I need to convert it from a dictionary to a feature set first? If I do need to convert it first, I'm not sure how to do that.
The data populated into the input parameter starts off like this:
{'nextObjectId': 1, 'showLegend': True, 'layerDefinition': {'id': '193db8743d9-layer-40', 'name': 'Sample Grid - Selection', 'objectIdField': 'OBJECTID', 'geometryType': 'esriGeometryPolygon', 'fields': [{'alias': 'OBJECTID', 'editable': True, 'name': 'OBJECTID', 'nullable':...
Any insight would be appreciated.
Solved! Go to Solution.
Apparently I needed to create a feature collection from the dictionary. My input parameter is inputFeats, so doing fc=featureCollection(inputFeats) solved it. After that, I was able to query the new feature collection like usual to get a featureset.
Now I have a different issue where only two of the attribute fields are being sent to the web tool.
for passing a layer added from upload data to the webtool, you can configure you input parameter for a feature set and default value you can use the dictionary mentioned above. {'nextObjectId': 1, 'showLegend': True, 'layerDefinition': {'id': '193db8743d9-layer-40', 'name': 'Sample Grid - Selection', 'objectIdField': 'OBJECTID', 'geometryType': 'esriGeometryPolygon', 'fields': [{'alias': 'OBJECTID', 'editable': True, 'name': 'OBJECTID', 'nullable':...
Apparently I needed to create a feature collection from the dictionary. My input parameter is inputFeats, so doing fc=featureCollection(inputFeats) solved it. After that, I was able to query the new feature collection like usual to get a featureset.
Now I have a different issue where only two of the attribute fields are being sent to the web tool.
Hi, could you share how you are doing this? I can't find any tutorials. I am working with a notebook in AGOL and have set an input parameter as FeatureSet. It comes in as a dictionary. What I am really trying to do is exactly what you have described here: select features in the map and use those as input utilizing "Set as Analysis Input" It doesn't seem to be working AT ALL, but figuring out this piece would be helpful. Once I add the featureset and the insert it as a variable, the following is added to the notebook:
selParcels = {
"url": "https://services6.arcgis.com/asdfsdfsdfasd/arcgis/rest/services/MyPArcels/FeatureServer/2"
}
How do I convert this or actually get a featureset from it?
@LisaTunnell I would remove the selParcels variable and URL. It did that for me too but I just commented it out.
Assuming selParcels is your input variable, you would do something like:
selParcelsFC = FeatureCollection(selParcels)
selParcelsQuery = selParcelsFC.query
You don't need to define the selParcels anywhere before the first line above. The first line converts from dictionary to feature collection. Second line will get you a feature set that you can actually work with.
I couldn't find good tutorials either, so just had to kind of stumble through it. Still a work in progress.
for passing a layer added from upload data to the webtool, you can configure you input parameter for a feature set and default value you can use the dictionary mentioned above. {'nextObjectId': 1, 'showLegend': True, 'layerDefinition': {'id': '193db8743d9-layer-40', 'name': 'Sample Grid - Selection', 'objectIdField': 'OBJECTID', 'geometryType': 'esriGeometryPolygon', 'fields': [{'alias': 'OBJECTID', 'editable': True, 'name': 'OBJECTID', 'nullable':...
@AndrewGriffin2 are you saying to use the dictionary mentioned above as the default value?
If your interested in a layer added from upload data? That layer won't have a url. So you need to updated your input parameter so the rest of your code in your notebook knows what dictionary keys to parse etc.. you can get your own dictionary by first publishing your .shp. then do a notebook with input parameter feature set with {'url': 'whateverFeatureserver/0'} output parameter string then go and json.dumps(input)
Thanks @AndrewGriffin2 . I'll give that a shot. I guess I didn't understand the purpose of the default value field. The documentation on this is pretty sparse.
By the way, when you insert variable as a cell, checkout the Metedata of the cell. It's tagged as parameter.