Hello everyone,
we have created a notebook in ArcGIS Online that creates a Word document based on various parameters. If we let the notebook run on its own, everything works. The output is written to the "arcgis/home" directory.
The next step would be to publish the notebook as a web tool in ArcGIS Online. To do this, we wanted to define an output parameter. The settings currently look like this:
A first question would be what we have to specify as a default value in JSON format. According to the documentation, it has to be a URL to an existing output? Currently, we have simply uploaded the Word template as an item in ArcGIS Online and specified the URL to it.
Afterwards we added this snippet at the end of the notebook:
The name of the variable equals the output variable name for the word file.
After publishing, we open the tool in map viewer and want to run it. Here we immediately notice that the output parameter does not appear in the GUI.
The tool can still be started, but aborts with an error message in the output parameter area.
It seems that the error is in the output parameter section. Do you have any clue, what we are doing wrong in the whole output parameter section (Notebook config, etc.)? The input parameters work.
Best
Sven
Solved! Go to Solution.
Hi @Sven_Harpering and @BenGiese,
Thank you for your patience! I was out of the office and could not respond sooner.
Currently in Map Viewer, it is not possible to use selected features as an input to an analysis tool. That said, if you configure a web tool in Experience Builder's Analysis widget, you will then be able to pass in selected features from the map popups and widgets like Select, Table, etc.
Here is an example of setting a selected feature as analysis input from a map popup:
I hope this helps. Please let me know if you have other questions.
Thank you,
Lingtao
Hi @Sven_Harpering,
Thanks for reaching out!
Looking forward to hearing back from you!
Lingtao
Product Engineer for ArcGIS Notebooks
Hi @xlt208 ,
I'm working with Sven on this project. Thanks for your guidance; it has already helped us a lot.
We are currently keeping {"url": ""} empty and have defined an input where the user can specify the output name. The .docx files are published as items in ArcGIS Online at the end. Our script creates a .docx file for each feature.
You asked for the error message. I don’t have access to it anymore because my script is working now. I think it was a problem with the specification of the output parameters and the URL we were pointing towards.
We want the user to select a feature on a map in the last step. The reports should then be created only for the selected features. This is possible in Experience Builder.
Apparently, the problem is that the selected features are not being passed along. Our input parameter is a feature set, but we still need to convert it to a feature set in the script. The selected features are being lost in the input. Do you have any idea what we need to set up to ensure the selection is considered?
This is our setting for the input features paramter:
This is the Code:
selected_damage = {
"url": "https://services3.arcgis.com/JhD3NyxTJcNiae8J/arcgis/rest/services/survey123_25027c5ec6294a65a7a851be8740f6f8_results/FeatureServer/0"
}
#get the url and return a feature layer
feature_layer_url = selected_damage["url"]
feature_layer = FeatureLayer(feature_layer_url)
# Get the Feature set
feature_set = feature_layer.query(where="1=1") # Abfrage mit allen Features
Until now this only returns a feature set with all features of the feature layer, not the selected.
Hi @xlt208,
do you have any further clue for us?
Thx
Sven
Hi @Sven_Harpering and @BenGiese,
Thank you for your patience! I was out of the office and could not respond sooner.
Currently in Map Viewer, it is not possible to use selected features as an input to an analysis tool. That said, if you configure a web tool in Experience Builder's Analysis widget, you will then be able to pass in selected features from the map popups and widgets like Select, Table, etc.
Here is an example of setting a selected feature as analysis input from a map popup:
I hope this helps. Please let me know if you have other questions.
Thank you,
Lingtao
Hey Lingtao,
i'm trying to export a list of groupIDs, names, and owners to a csv file. I'm fine with that CSV file ending up in the HOME folder. But when I publish, then try to run the tool, it fails. The error message suggests I can't write to the output path..which is HOME.
Any suggestions?
Hi @Alex_Rodriguez,
It sounds like your code was attempting to write the CSV file into the /arcgis/home directory. Is that correct? This directory is unavailable for notebook web tools. You may need to change the output location to a relative path. Here is an example:
csv_file = open("group_info.csv", "w") csv_file.write("xxx") csv_file.close()
output_csv = {"url": "group_info.csv"} # output parameter of the "File" type
Looking forward to hearing how it goes.
Thank you!
Lingtao
Hey Lingtao,
Thanks for your reply. I added the line of code you suggested (assuming I interpreted your post correctly).
Here's what I ended up with:
f = open("/arcgis/home/ExportFiles/GroupsList.csv",
mode='a',
encoding='utf-8')
f.write("whatever I'm writing to the file, line by line")
f.close()
output_csv = {"url": "/arcgis/home/ExportFiles/GroupsList.csv")
Where:
"ExportFiles" is a folder I created to store these output files
I'm opening/closing the output file each time I write to it. I imagine that's not as efficient as it could be...but that's what I'm doing.
End result: I'm getting the same error.
Okay, downloaded a sample notebook that creates 2 CSV files. Ran it as a notebook, works fine.
Published it and ran it as a tool. Failed...for the same reason as mine.
So, as you mentioned, HOME is evidently not available to the tool. But I can't find documentation that indicates what IS available to a tool.
Can anyone clue me in to what folder structure is available to a tool for writing files? Your assistance would be greatly appreciated.
alex