1
Upon the completion of this presentation you should be able to: Describe the geoprocessing service capabilities Define supported data types input and output of geoprocessing service Configure a geoprocessing model Publish a geoprocessing model as geoprocessing service Explain the two execution modes of geoprocessing service: asynchronous vs. synchronous Geoprocessing service is about exposing your GIS analysis to the web. You create or re-use an existing spatial analysis tool, execute and send it to the web. 2
Before learning how to publish a Geoprocessing Service (GP) using ArcGIS Server and share it to ArcGIS online, we shall first go over some basic geoprocessing service concepts. So far, you have been learning how to share your map through web services having following supported capabilities: Map service: serves map image on Internet Image service: serves raster data and allows to dynamically interact with the content of raster dataset Feature Service: serves vector data and allows users to interact with data content: display, download or create, delete, update, modify it Usually, GI analysis is performed by running a tool in a Desktop GIS. What about making GI analysis in an online environment? To do this, you need to expose your tool as web service called Geoprocessing Service (GP Service). GP service is a tool running on the server. If you are familiar with the spatial analysis available in the ArcGIS Desktop environment, it s not difficult to understand the Geoprocessing Service. The standard steps involved in a classic spatial analysis task are: Identify a problem and data needed to analyse the problem Choose the appropriate tools to analyse the problem Define the tools parameter: data input and output Execute the analysis and get results To have a GP service running on ArcGIS for Server, you execute a tool (or you chain several tools in ModelBuilder or customized scripting code) in ArcMap, get results and publish the results to the server. Why the results? Because the tool result is acting as GP service template. It contains: data (datatype) input, the output and the tool per se. Once the tool is running on the server, other clients can use it: JavaScript API, Flex API, Silverlight API, Mobile APIs etc. The clients send the input, the server executes the tool and returns the results to the clients. 3
Authoring To execute a GI analysis in a GIS Desktop environment (ArcGIS Desktop), you select an existing tool, or create your own spatial analysis workflow using ModelBuilder or Python Scripting, define the inputs and outputs parameters of your selected tool and execute the tools. The results created in the Results window are shared as geoprocessing service. What is the difference between geoprocessing task and geoprocessing service? A geoprocessing task provides a unique geoprocessing functionality, while a geoprocessing service can have more than one geoprocessing tasks (Source: Esri, 2014). Publishing To share a task/ GIS analytics as a geoprocessing service, connection to ArcGIS Server instance is required. The tool, its input data together with its characteristics (data type, attributes, attributes types, spatial reference system) are served to the server as geoprocessing service. Service Editor window prompts service publisher to define the GP Service properties and capabilities. As already said, a geoprocessing service can have more than one geoprocessing tasks. When publishing to ArcGIS for Server each task has a REST URL. The task has two parameters: the input parameters and the output parameters. The client send the input parameter, the server executes the task and sends back the output parameters. Using Geoprocessing services can be consumed by various client: web browsers, mobile applications etc. Primary clients used to consume geoprocessing services are web applications developed with JavaScript, Silverlight or Flex. Geoprocessing services published in ArcGIS for Server can be consumed also using the OGC Web Processing Service (WPS) specifications. 4
When publishing Geoprocessing Service from scratch, it is important you define the task precisely. You define your spatial analysis workflow and run it using run a tool created using: Python Scripting or the ModelBuilder: application you can use to create, edit and manage models. Models are workflows where the output of one tool becomes the input of another tool A simple ModelBuilder application is presented above. It consists of: Tool: buffer analysis Input: Cities Salzburg Land dataset Output: spatial analysis output Variable: distance The input and distance variable are defined as model parameters (they have a P next to them). These model parameters become the task arguments that clients of your task provide when they execute the task. (Source: Esri, 2014). If data input is not define as model parameters, the users cannot define its own data as input in the model. The developed spatial analysis workflow is executed and the results are used as the input for publishing the geoprocessing service. 5
After executing your tasks (by running the tool), the results created in Results window are shared as geoprocessing service. The results create the template for the service. If your tool does not run successfully, you ll not get results and you have nothing to be published as geoprocessing service. Coming back to the results, they contain all information ArcGIS needs to construct a task: Name and location of toolbox and tool Output generated by executing the tool Schema of both the input and output: feature types (point, line, polygon), spatial reference, attribute fields Symbology of the input and output Default values 6
The input parameters that can be parsed by ArcGIS for Server are outlined above. 7
The coordinate reference system of the processing s output can be set up either using the geoprocessing environment settings or by preserving the coordinate reference system of the input data. If geoprocessing environment is used to configure the coordinate reference system, then all computations are done using configured CRS, rather then the coordinate system of the input data. 8
In the GP Service Editor window, service s parameters and tasks' parameters have to be configured. We start our explanations with the file upload capabilities. As already said, files (photos,.txt files etc.), are among the input parameters that can be parsed by ArcGIS Server. When you want your client to give files as input parameter, you have to enable this capability. This capability can be enabled while publishing the service (From Service Editor window) or after publishing the service (e.g. go to ArcCatalog, connect to your ArcGIS for Server, right click published GP service, choose properties, enable Upload capabilities and save the new settings). 9
Executions modes define how the clients interact with the service when it execute. There are two execution modes: 1. Synchronous: this execution mode is appropriate when you have a fast geoprocessing service. The clients submit a job to the server and wait for the server to execute the task and then get the results (Esri, 2014). The server is doing its job (runs the tool), but it does not save data on the server. Thus, the results are send back to the client application. 1. Asynchronous: is appropriate for longer running geoprocessing services. The clients submit a job to the server and ask from time to time whether the server finished its job and then get the results. Meanwhile the client can do other work. The results can be saved on server. How long a data remains on the server depends on the clean-up schedule of the jobs folder. The GP service task has two kinds of operations: Execute task: for faster processes (execution mode: synchronous) Submit job: for long running processes (more than 10 seconds) with asynchronous execution 10
To get results from a Geoprocessing Service, two options are available: Download and draw results on the client side Draw the results as an image of the results: result map service. The clients display and download the results. The reason for viewing the results with a result map service (RMS) are (Source: Esri, 2014): better cartography than the client can support: you do not have to define the symbology at the client level helpful for larger dataset: imagine a web browser trying to draw 2000 features. It will be really slow. web application cannot draw raster data: if the output of your task is a raster, then the client cannot draw it. If you choose to view the results with a map service, the results must be saved on disk because the map service cannot reference data from memory. Could you answer this question: if you choose to draw the results as result map service, what execution mode should be selected? In the image presented above, you see a Geoprocessing Service that draw results as an map service: the map service is automatically generated when the service is published. 11
When publishing geoprocessing service, we need to make sure the server has access to the data used as input in the spatial analysis task. Suppose you have a 10 GB dataset that is used as input in the geoprocessing service. To make sure the server has access to data, we could copy data on the server. But we do not want to overload the server with such great data volume. Rather than copying data on the server, data file or geodatabase is registered with the server (create a data store). Data store is actually the reference to the data. It s telling the server where data is stored. You can also copy data files or database on the machine where ArcGIS for Server is running. If your data is however not registered with the server, data will be copied to the server when publishing it. Let s talk a little bit about the disadvantages of not registering data with the server. Imagine, the input of a task/tool shared as geoprocessing service is not raw data, but Feature Service serving this spatial data. It means that Feature service and Geoprocessing service is going to use the same datasets. If your data is not registered with the server, the same data will be double stored on the server and thus the server will be overloaded with a large data volume. 12
You cannot publish the geoprocessing without a minimum documentation. You share your GI analysis in order to be understood and consumed by different clients. Therefore, a brief service s documentation is mandatory. 13
Task parameter settings define how clients will access the service and the tasks/tool. In the Service Editor window, there are three options for setting the parameter/input data behaviour. These settings help you to decide how the client will define input values for each tool s parameters: 1. User define values: data comes from the client. This options is selected if you want to allow users to add features, upload authoritative data, enter text or number values 2. Choice list: a map product displays usually more than one data layer. By selecting choice list capability, the users can select which of rendered data layer to be used as input in the GP 3. Constant value: use the same value over and over again. If you want the clients to use only a particular input data, you have to select constant value. 14
Geoprocessing service published via ArcGIS Server can be configured to conform with the interoperable capabilities defined by OGC Web Processing Service (WPS) specification. How does Web Processing Service interacts with the clients? The Clients send the GetCapabilities and DescribeProcess request to the server. It gets a list of processes and details of each process (the tools, the models, supported datatypes etc.) and then sends execute request to the server (to perform the analysis). Once the requested analysis is done, the server sends back the results. The results can be vector or raster datasets published as WMS. Why raster results are published as Web Mapping Service (WMS)? To get the answer go back to slide 11. 15
From Service Editor window, you can share the geoprocessing service with members of your organization who have access to the content stored on your ArcGIS for organization instance. Before sharing it, please make sure that you documented published task adequately. It s really difficult to re-use a task published by others, if you are not given appropriate documentation about what the service is doing, what are the default parameters etc. Please remember, publishing Geoprocessing Service is not only a pushing the Share button action, but it is about setting up the appropriate capabilities, documenting and defining tags that make your service searchable and re You can share your geoprocessing service as a tool in ArcGIS Online portal while publishing it or by using the REST URL: http://servername/arcgis/rest/services/folder/servicename/gpserver -usable. 16
The clients access the tasks into four steps: Initialize the task Set up task parameters Run the task: submit job or execute operations Run the task Get the results To consume published geoprocessing service in ArcGIS for Desktop, you have to use this service URL: http://servername/arcgis/services/forlder/service_name/gpserver or you open the Catalog window, define a connection to the ArcGIS Server, go the folder where your services are stored, right click the tool and choose open. 17
You can add more than one task in your geoprocessing service. From GP Service Editor window, click Add Result. Give an example of scenario when more than one task can be shared in one GP Service. 18
Now, think about the questions stated on the slide - do you know the correct answers? 19
ESRI, 2012. Geoprocessing Service Help documentation. Available online at: http://resources.arcgis.com/en/help/main/10.2/index.html#//00570000005w000000 [accessed on 27.03.2015] 20