ArcGIS Server Banner

GP Service example: Data on demand

GP Service example: Data on demand

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback
Note: This topic was updated for 9.3.1.


Folder DataOnDemand.
Purpose Using a polygon digitized by the user, clips datasets in a file geodatabase, outputting shapefiles; then creates a .zip file, which is e–mailed the user.
Services PortlandDataMapService (map service).

DataOnDemand (geoprocessing service).
Geoprocessing tasks ClipZipAndEmail.
Inputs Area of interest (polygon Feature Set) and an e–mail address to send the data.
Outputs aoizip.zip, a compressed file containing the data.
Data The example uses a small dataset of the city of Portland, Oregon.
Extensions None.
Of note This service is hosted on ESRIs sampleserver—see note below. This is a clip and ship service, as described in the clip and ship example.

Corresponding Folder

C:\arcgis\ArcTutor\GP Service Examples\DataOnDemand contains the tools and data.

About this example

This DataOnDemand service is another example of a clip and ship service. Before exploring this service, you should first read the clip and ship example since the features and capabilities of this service are compared with that service, as described briefly in the table below. If you are building your own clip and ship service, you may want to combine features and capabilities of both services into your service.


Clip and Ship example This example
User gets to choose which layers to download. A fixed set of data is downloaded.
The spatial reference of the output data can be specified. Spatial reference cannot be specified—it is set to the spatial reference the datasets being clipped.
Output is a file geodatabase. Shapefiles are output.
Uses models, scripts, and tool layers. The service is published using a map document. No models are used, only scripts. The toolbox is published rather than a map document.
Layers from the map document are clipped. Datasets are clipped. (Because there is no source map document containing layers, layers cannot be used, only datasets.)
Area of interest (the clip polygon the user digitizes) is not downloaded. Area of interest is downloaded.
Name of the e–mail server is a model parameter. E–mail server name is coded into the ClipZipAndEmail tool (source file is DataOnDemand/Scripts/zipandemail.py).

NOTE: In order to run this service, you must edit this script and provide an e–mail server name.

Other features of this service include

This service is hosted at ESRI

This service is hosted on ESRI's arcgisonline servers. You can try out this service as follows:

  1. Add http://sampleserver1.arcgisonline.com/arcgis/services as an ArcGIS server.
  2. Add http://sampleserver2.arcgisonline.com/arcgis/services as an ArcGIS server.
  3. In ArcMap, add the Portland_Portland_ESRI_LandBase_AGO map service from sampleserver1.
  4. Add ESRI_CadastralData_Portland geoprocessing service from sampleserver2 to ArcToolbox.
  5. Expand the ESRI_CadastralData_Portland toolbox and execute the ClipAndShip task.

The scripts and tools in the DataOnDemand folder are the same as those used by the ClipAndShip task in ESRI_CadastralData_Portland geoprocessing service. The data used for this example, found in DataOnDemand/ToolData/Portland.gdb, is a small subset of the data used in the Portland_Portland_ESRI_LandBase_AGO map service.

NOTE: The map and geoprocessing services found in sampleserver1 and sampleserver2 may change in the future. There is no guarantee that the services described above are always available.

Data

The data is of a small area in the city of Portland, Oregon, and is found in C:\arcgis\ArcTutor\GP Service Examples\DataOnDemand\ToolData\Portland.gdb.

The ClipZipAndEmail tool uses a Feature Set variable, which in turn needs a schema to define the feature types and fields. The schema can be found in C:\arcgis\ArcTutor\GP Service Examples\DataOnDemand\ToolData\Templates.gdb.

The ToolData folder also contains Mapofzip.mxd, which is included in the zip file and displays the clipped and shipped data.

Scripts

The DataOnDemandTools toolbox contains one script tool, ClipZipAndEmail. The source for this script tool is DataOnDemand/Scripts/zipandemail.py.

Before using the ClipZipAndEmail tool, you must edit the code and provide the name of your e–mail server. (You can either edit the Python source directly in an application like PythonWin, or, in ArcToolbox, right-click the script tool and click Edit.) Your system administrator should be able to supply you with the name of your e–mail server.

Some salient properties and features of this script are described below.

Publishing

PortlandDataMapService is published as a map service.

The DataOnDemandTools toolbox is published as a geoprocessing service.

Configuring the service

To configure this service for your data, you will need to edit the ClipZipAndEmail script tool. The source for this script tool is DataOnDemand/Scripts/zipandemail.py. You can either edit the Python source directly in an application like PythonWin, or, in ArcToolbox, right-click the script tool and click Edit.

You will need to change the location of data and the list of datasets. In the main routine

if __name__ == '__main__':

Locate the definition of the dataloc variable and change it to the following:

 global dataloc; dataloc = os.path.dirname(sys.path[0]) + g + "tooldata" + g + "portland.gdb" + g

The location of the data is relative to the location of the script.

Learn more about using the script location to build pathnames

Next, change the list of datasets to clip, found in this code snippet:

    ds = ["Streets" + g + "streets", \
            "Water" + g + "StreamRoute", "Water" + g + "floodplain", "Water" + g + "riv_fill", \
            "Transit" + g + "railroad", \
            "Census" + g + "blockgrp", \
            "Develop" + g + "Buildings", \
            "Land" + g + "zoning", "Land" + g + "Parks", \
            "Places" + g + "schools", "Places" + g + "hospital"]

Finally, you will need to provide the name of your e–mail server in the sendemail.py script. The code you need to modify is near the top of the script:

def send_mail(send_from, send_to, subject, text, f=""):
    assert type(send_to)==list

    # Provide the name of your email server below
    #
    server = "ouremailserver.somewhere.com"

See Also

  • Guide to the geoprocessing service examples
  • GP Service example: Clip and ship