Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and...
Transcript of Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and...
![Page 1: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/1.jpg)
Shing LinSimon Suo
Creating and Using Web Tools and Geoprocessing Services
![Page 2: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/2.jpg)
1. Introduction2. Design and Author 3. Run and Publish
• Demo 1 Publish Web Tool• Demo 2 Publish GP Service
4. Consume • Demo 3 Consume Web Tool and GP Service
5. Advanced Considerations6. Resources and New Features
Overview
![Page 3: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/3.jpg)
Concept, Requirements, and WorkflowIntroduction
![Page 4: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/4.jpg)
Web Tool vs Geoprocessing Service
• Web Tool - Publish from ArcMap or Pro to ArcGIS Enterprise
• Geoprocessing Service - Publish from ArcMap or Pro to Stand-Alone Server
![Page 5: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/5.jpg)
Requirements• Software
- ArcGIS Pro 1.4 and above for web tool- ArcGIS Pro 2.3.1 and above for gp service - Enterprise 10.6 and above
• Login account- Web tool
- Must have Admin or Publisher permissions to publish- For Publisher, you need to create a Customized Publisher role in Portal and turn on Publish
Web Tools option in the Administrative Privileges. - GP service
- A server connection (.ags file) with Admin account
![Page 6: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/6.jpg)
Data Preparations and Pre-Publishing Considerations
Design and Author - Script Tool and Pre-publishing Script
![Page 7: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/7.jpg)
Preparation – Data in Script Tool
• Avoid “hard coding” all data paths and dependencies- Favor input parameters which a user can customize- my_param = arcpy.GetParameterAsText() or “P” in Model Builder
• If you have to use a “hard coded” data path, build it dynamically- Utilize os.path.join(“root directory”, “file_name”) so the tool works on any OS- Use sys.path.append(“server’s path to the module”) if needed
• Write intermediate/temporary output data to memory- Keep everything running fast, and lighten the load on your Data Store- Use os.path.join(“in_memory”, “your output name”) or Intermediate Data
![Page 8: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/8.jpg)
Pre-publishing considerations 1 - Input mode • The way the users provide input in web tool
• User Defined Value: allows the end user to interactively add data• Use non-layer object as input
• Choice list: allows the end user to select from a list of layers on the server• Use layer object for each input
• Constant value: hard codes the parameter, user cannot see it• Provide the tool and parameter name and set the value in constant list
parameter of
arcpy.CreateGPSDDraft (……, constantValues = [toolName.parameterName, ..])
![Page 9: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/9.jpg)
Pre-publishing Considerations 2 – Data Reference and Validation • For all the project data or input data as layer or constant
- If data source is not registered on Server Data Store, data is recursively found in any directory, then consolidated and copied to server
- If data source is registered on Server Data Store, data is referenced from the server, not consolidated
- If the data is large, try reference
• Tool Validation script will be published, and executed by SubmitJob()
- The validation occurs server-side, and should act the same, but test it!
![Page 10: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/10.jpg)
Functions and Demos for publishing Web Tool and GP ServicePublishing Functions
![Page 11: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/11.jpg)
• Run tool to get result file in python
• Login from ArcGIS Pro or arcpy.SigninToPortal (PortalURL, Username, Password) function
• Use arcpy.CreateGPSDDraft (result, out_sddraft, service_name, server_type (user MY_HOSTED_SERVICES here)) to obtain a service definition draft
• Use arcpy.StageService_server (sddraft, sd) to create a service definition file
• Use arcpy.UploadServiceDefinition_server (sd, ServerURL) to upload the service definition file to server
Publishing Functions for Web Tool
![Page 12: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/12.jpg)
Demo 1Publish Web Tool
![Page 13: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/13.jpg)
• Run Desktop tool to get result object in python • Use arcpy.CreateGPSDDraft (result, out_sddraft, service_name,
server_type (use ARCGIS_SERVER here)) to obtain a service definition draft.
• Use arcpy.StageService_server (sddraft, sd) to create a service definition file.
• Use arcpy.UploadServiceDefinition_server (sd, Server Connection File) to upload the service definition file to server.
Publishing Functions for GP Service
![Page 14: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/14.jpg)
Demo 2Publish GP Service
![Page 15: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/15.jpg)
Functions and Demo for consuming Web Tool and GP ServiceConsuming Functions
![Page 16: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/16.jpg)
Consuming a Web Tool and GP Service
• Use ArcPy Functions - Call ImportToolbox or AddToolbox function
arcpy.ImportToolbox ( “Https://ServerName/WebAdaptorName/Services; Web tool or Service name; Username; Password”)
- Run like Desktop tool arcpy.WebToolName.TaskName(<Parameters>)
- If consuming a web tool, you can write the output to a feature service by setting the service name for the output parameter esri_out_feature_service_name
• Use REST API for automation and testinng‒Use "requests" and "json“ modules
![Page 17: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/17.jpg)
Demo 3Consume Web Tool and GP Service
![Page 18: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/18.jpg)
3rd-party Libraries, Sharing from ArcMap and Notebook, Frequent Publishing
Advanced Considerations
![Page 19: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/19.jpg)
1. Login Server Machine command prompt as an Admin2. Clone the server's default Python environment with a new
environment name, such as newenvname, using Condaclone command
3. Activate the Clone Environment by running proswapnewenvname
4. Install the third-party Python packages by running condainstall
5. Restart the ArcGIS Server service on the Windows Task Manager
Third Party Libraries Deployment
![Page 20: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/20.jpg)
• Sharing from ArcMap- Publish with the same way as stand-alone server from Pro
• Publishing and consuming from NoteBook- Use Python API. Can only publish using service definition file.
• If you publish the same service frequently in Pro- Save the service definition file and publish from
arcpy.UploadServiceDefinition_server directly
ArcMap, Notebook and Frequent Publishing Considerations
![Page 21: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/21.jpg)
New Features and Doc linksNew Features and Resources
![Page 22: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/22.jpg)
• ArcGIS Pro 2.3 2.4 and Enterprise 10.7 , 10.7.1- Output feature service- Publish to stand-alone server Using script (Pro 2.3.1), from GUI (Pro 2.4)- Deploy custom python packages for services published from Pro- Deploy R for ArcGIS- Support new data types – Filters, Field- Move jobs directory to Azure
• ArcGIS Pro 2.5 and Enterprise 10.8- Specify Environmental Variables from the client- Provide image service URL for raster input
Major Web Tool New Features
![Page 23: Creating and Using Web Tools and Geoprocessing Services€¦ · •Software -ArcGIS Pro 1.4 and above for web tool-ArcGIS Pro 2.3.1 and above for gp service -Enterprise 10.6 and above•](https://reader030.fdocuments.us/reader030/viewer/2022011921/602b2c5c9bd2180a40534d45/html5/thumbnails/23.jpg)
Useful Links• Session scripts, models, and data http://bit.ly/2Wqdjys• Sharing web tool with python https://bit.ly/3ausYRm• Quick tour of sharing web tool https://bit.ly/2wrfHdw• Quick tour of sharing GP service https://bit.ly/32Ocq48• Deploy 3rd party python packages https://bit.ly/38o1Rpt• Accessing web tool from Notebook https://bit.ly/2vG1fy7• Sign in Portal https://bit.ly/38lAbBx• CreateGPSDDraft https://bit.ly/39viDVi• Stage https://bit.ly/3axcfwv• Upload Service Definition https://bit.ly/3au5Oua