GP Service example: Clip and ship

Complexity: Beginner Data Requirement: ArcGIS Tutorial Data Setup

Folder

ClipAndShip

Purpose

Using a polygon digitized by the user, this service clips layers from the study area into a file geodatabase, then creates a .zip file that can be downloaded by the user.

Services

Portland (Map service), ClipAndShip (Geoprocessing service).

Geoprocessing tasks

Extract Data Task.

Inputs

Layers to Clip, Area of Interest, Feature Format, Raster Format.

Outputs

A ZIP file containing the data.

Data

The example uses a number of datasets from the study area of Portland, Oregon.

Extensions

None.

Of note

Creates output.zip, a compressed file containing a file with the format specified. This file mimics the arrangement of the layers in the ArcMap document that is published as a geoprocessing service.

About this example

Corresponding Folder

C:\arcgis\ArcTutor\GP Service Examples\ClipAndShip contains the completed models and data.

About this example

This example shows the detail steps of publishing and using a map and a geoprocessing service. The geoprocessing task lets you select the layers you want, digitize a polygon (or multiple polygons) of the area of interest, and select the output feature and raster data format. Data in the map is clipped to the area of interest, then bundled and shipped to the user—hence the name "clip and ship".

Data

The study area for this example is a small area in the city of Portland, Oregon. Data includes places, transportation networks, hydrologic features, land records, and a hillshade raster of the study area. The data can be found in C:\arcgis\ArcTutor\GP Service Examples\ClipAndShip\ToolData\Portland.gdb.

Publishing

Steps:
    You need to have an administrative connection to an ArcGIS server to publish services. To create an administrative connection, in the Catalog window, go to GIS Servers > Add ArcGIS Server and check Manage GIS Services. On the General panel, enter the Server URL and Host Name, then click Finish. A server administrative connection with the host name will appear under GIS Servers.
  1. From the Catalog window, navigate to C:\arcgis\ArcTutor\GP Service Examples\ClipAndShip.
  2. Right-click Portland.mxd and select Publish to ArcGIS Server.
  3. In the first window, keep all defaults and click Next.
  4. in the next panel, deselect all check boxes except Mapping (always enabled). Click Next.
  5. Click Finish. The map service Portland will be published to the ArcGIS Server. You will use it as a basemap later.
  6. Open C:\arcgis\ArcTutor\GP Service Examples\ClipAndShip\Portland.mxd in ArcMap.
  7. In the Catalog window,
    1. Expand Toolboxes > System Toolboxes > Server Tools.tbx > Data Extraction > Extract Data Task.
    2. Drag the Extract Data Task tool to the ArcMap table of contents.

    The tool layer Extract Data Task appears in the table of contents.

  8. Save the map document containing the tool layer as ClipAndShip.mxd.
  9. In the Catalog window, right-click the connection to your ArcGIS Server and select Add New Service.
  10. In the Add GIS Service panel, type ClipAndShip as the service name and select Geoprocessing Service as the Type. Click Next.
  11. In the next panel, check A Map as your source file. Enter the path to the ClipAndShip.mxd map document that you created above and click Next.
  12. Add GIS Services
  13. For any remaining panels, leave the default value and click Next until the last panel, where you click Finish. You should see the service ClipAndShip under your ArcGIS Server connection.

Using

The following steps show how to use the map and geoprocessing services that you previously published.

Steps:
  1. Open a new ArcMap document.
  2. In the Catalog window,
    1. Navigate to your server connection under GIS Servers, select the map service Portland, and drag it into the ArcMap table of contents.
    2. Expand the Portland map service in the table of contents, and you will see all the layers belonging to the Portland map service.
  3. In the Catalog window, navigate to your server connection under GIS Servers, find the geoprocessing service ClipAndShip, and expand it. The task Extract Data Task appears.
  4. Double-click the task Extract Data Task to open the task dialog box.
  5. At the top of the task panel is a list of Layers to Clip. Note that the layer names in the check box are the same as the layers of the Portland map service in the table of contents. Check the box next to each layer that you want to be included in your download.
  6. Extract Data Task
  7. The next parameter of the Extract Data Task is the Area of Interest. This parameter is used to digitize an area of interest that will be used to clip each of the Layers to Clip. Click Add Feature, then digitize a polygon as an area of interest.
  8. Other input parameters, Feature Format and Raster Format, can be modified or left as default.
  9. Click OK to run the geoprocessing task.

    The output is returned from the server and written to the location set in your geoprocessing scratch workspace environment.

When the task completes, open the Results window to view the results of the task. Double-click output.zip to open the compressed file, then extract the data to a location of your choice.

Result

Customizing the GP Service source model

The previous example uses the model tool Extract Data Task from the Server toolbox. If you copy the model tool to a new custom toolbox, it can be opened in ModelBuilder and edited. The Extract Data Task model contains input variables Spatial Reference and Customized Spatial Reference Folder, which are not exposed as model parameters. Spatial Reference has a default value, Same as Input, which means the spatial reference of the output files is the same as the input layers. If you want to get a spatial reference for the output files that is different from that of the input files, you can set Spatial Reference as an input parameter so that when the model tool dialog box is opened, a different spatial reference can be specified. The variable Customized Spatial Reference Folder is an optional variable allowing you to specify a path that saves the custom and/or standard spatial reference.

In addition to the two Spatial Reference variables, which can be modified to customize the Extract Data Task, the existing model parameter Feature Format can also be modified to contain additional formats you need.

The following steps show how to customize the Extract Data Task by exposing the variable Spatial Reference as a parameter, adding a path for the custom spatial reference folder, and adding new output formats for the Feature Format parameter.

NoteNote:

A toolbox named ExtractPortlandTbx that contains a customized model ExtractPortlandData is saved under C:\arcgis\ArcTutor\GP Service Examples\ClipAndShip. The model is the finished product after performing the following steps.

Steps:
  1. The first step is to create a new toolbox and model. In the Catalog window, go to C:\arcgis\ArcTutor\GP Service Examples\ClipAndShip.
    1. Right-click the folder and select New > Toolbox.
    2. Rename the toolbox ExtractPortland.
  2. In the Catalog window,
    1. Expand Toolboxes > System Toolboxes > Server Tools.tbx > Data Extraction > Extract Data Task.
    2. Select the Extract Data Task, right-click the model, then select Copy.
    3. Go to ExtractPortland.tbx that is created in step 1b, right-click and select Paste.

      The model Extract Data Task is copied to the toolbox.

    4. Right-click the model, select Rename, then rename the model ExtractPortlandData.
  3. Right-click the model ExtractPortlandData and select Edit to open the model in ModelBuilder. In the model, right-click the variable Spatial Reference and select Model Parameter. The letter P appears on the upper right-hand corner of the variable so it is now a model parameter.
  4. ExtractPortlandData model
  5. Create a new folder where all the standard and custom coordinate system projection files will be saved.
    1. In Windows Explorer, go to C:\arcgis\ArcTutor\GP Service Examples\ClipAndShip. Right-click the folder and select New > Folder.
    2. Rename the new folder SpatialReference.
    3. Go to <ArcGISInstallDirectory>\Desktop10.0\Coordinate Systems\Projected Coordinate Systems, copy the State Plane folder.
    4. Paste it into the new SpatialReference folder.
  6. Right-click the model ExtractPortlandData and select Edit. Double-click the variable Custom Spatial Reference Folder and enter the path to the new SpatialReference folder (C:\arcgis\ArcTutor\GP Service Examples\ClipAndShip\SpatialReference), then click OK.
  7. With the ExtractPortlandData model still open in ModelBuilder,
    1. Go to the Model menu > Properties > Parameters tab.

      The parameter Spatial Reference appears at the bottom of the parameter list.

    2. Reorder the parameters so the output parameter is the last parameter. Highlight the parameter Output Zip Fileand click the Down button to move it to the bottom of the list.
  8. Still in the Parameters tab,
    1. Highlight the variable Spatial Reference, then change the Filter value to Value List.
    2. Enter the values Same As Input, NAD 1983 StatePlane Oregon South FIPS 3602 (US Feet), and WGS1984 to the value list.
    3. Click OK to close the Value List dialog box.
    4. Click OK to close the model Properties dialog box.
    5. Save the model and exit ModelBuilder.
  9. The Feature Format parameter can also be customized by adding more data types to the list of formats. Learn more about the different data formats supported by the Data Interoperability extension.
  10. Save the customized model and add it as a tool layer in a new ArcMap document that contains all the layers from Portland.mxd.
  11. Refer to the instruction in the Publishing and Using sections above to publish and use the customized model as a geoprocessing service.

Related Topics


11/18/2013