I am am quite new to writing python scripts using the notebook on ArcGIS pro. I have a script that runs perfectly and it is part of a larger analysis. For the full analysis I have built a model builder with several geoprocessing tools included.
I want to know how I can add this notebook script to be part of the model I'm building. As this model houses multiple analyses, I want tho have all the tools including the python script from the notebook run all at once by one click.
I really appreciate any suggestion on this.
I would suggest exporting the notebook to a .PY script file, and then in ArcGIS Pro, in a toolbox, configure a script tool to point to the script. One you have a script tool configured, you can add the script tool to your model, and it will be run when you run the model.
This tutorial shows how to convert a Notebook to a PY script and configure it as a script tool:
https://learngis.maps.arcgis.com/home/item.html?id=24e13f2f4fe8453b9d1107e1f5b1d3cf
Thank you Bob, your response was really helpful. Is there a way I can force this script to run first before other tool in the model?
Emeka,
Yes, you can use a Precondition in Model Builder to determine which parts of disconnected processes run first.
However, to make a precondition, you need to configure your script tool to have an output parameter.
https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/adding-a-script-tool.htm
You configure the output of the script tool to be the precondition for starting the next tool by connecting the output to the next tool as a precondition.
Thank you so much Bob. Your answers were really helpful.