Input and output data types
As described in Key concepts for geoprocessing services, only certain data types can be used as input and output parameters for geoprocessing services.
Since processes within your published model or script execute on the server where all data types are available, you can use any data type for model or script processes. It is only the input and output parameter data types that are limited.
There are four levels of data type support:
- Fully supported across all clients.
- Supported for ArcGIS Desktop clients only.
- Not allowed on any client. Some data types, such as TIN, are not allowed for input parameters, and the model will not publish. You will receive an error when publishing, as illustrated below.
- The data type is transformed to a String data type. For example, an Areal Unit data type will become a String data type in the published task.
Models and scripts that work on ArcGIS Desktop may have to be modified to only use supported input and output data types before they can be published to ArcGIS Server.
Input data types
The following table summarizes key input parameter data types for the three clients.
Input parameter data type |
Supported on ArcGIS Desktop clients? |
Supported on ArcGIS Explorer client? |
Supported on Web application clients? |
---|---|---|---|
Feature Set |
Yes |
Yes |
Yes |
Record Set |
Yes |
Yes |
Yes |
Feature Class |
No (But Feature Class input is supported indirectly with the Feature Set data type.) |
No |
No |
Table |
No (But Table input is supported indirectly with the Record Set data type.) |
No |
No |
Raster |
Yes |
No |
No |
Standard types (such as Long, Double, Boolean, Date, String) and Linear Unit (for example, "1000 meters") |
Yes |
Yes |
Yes |
File (such as a .zip or .xml file) |
Yes |
Yes |
Yes |
Layer (any type of layer; for example, Feature Layer, Raster Layer, Network Analyst Layer) |
Only those layers found in result map service or source map document |
Only those layers found in result map service or source map document |
Only those layers found in result map service or source map document |
For any input data type not in the above list, one of two things will occur when you publish your model or script:
- The tool will be published, but the data type will be converted to a string data type containing the string representation of the data.
- The tool will not publish, and you'll receive an error. Data types that result in publishing errors are
- Any geodataset (such as Feature Class) or table, except for raster
- Data Element
- Value Table/Multivalue
- Model variables that are Lists
Feature classes and tables
Feature Class and Table data types are not supported as input parameters because they rely on large software libraries that cannot be installed with lightweight clients, such as ArcGIS Explorer and Web applications. Because of this, geoprocessing contains two lightweight data types, Feature Set and Record Set, that you can substitute for Feature Class and Table data types.
Feature Sets allow all Web clients to interactively digitize features on a map. In ArcGIS Desktop, the Feature Set data type additionally allows you to input an existing feature class, as illustrated below. Feature classes are allowed on ArcGIS Desktop because the required software libraries are available. Similarly, Record Sets allow all clients to interactively create table records, and in ArcGIS Desktop, you can additionally specify an existing table.
Raster datasets
Geoprocessing services that have Raster dataset inputs only work on ArcGIS Desktop clients. On an ArcGIS Explorer client, the service cannot be added as a task. In Web applications, the service will return an error.
Output data types
The following table summarizes key output parameter data types for the three clients. Following this table are notes about each data type.
Output parameter data type |
Supported on ArcGIS Desktop clients? |
Supported on ArcGIS Explorer client? |
Supported on Web application clients? |
---|---|---|---|
Feature Class |
Yes |
Yes |
Yes |
Feature Layer |
Yes |
Yes |
Yes |
Raster |
Yes |
No; can only be displayed using a result map service |
No; can only be displayed using a result map service |
Raster Layer |
Yes |
No |
No |
Geodataset (other than feature class or raster) |
No; can only be displayed using a result map service |
No; can only be displayed using a result map service |
No; can only be displayed using a result map service |
Table |
Yes |
No (Services that have a table data type as an output parameter will not be shown in the list of available tasks.) |
Yes |
Standard types (such as Long, Double, Boolean, Date, String) and Linear Unit (for example, "1000 meters") |
Yes (viewed in the service result found in the Results window) |
Yes (viewed in the Task Result window) |
Yes |
File |
Yes |
Yes |
Yes |
For any data type not in the above list, one of two things will occur when you publish your model or script:
- The tool will be published, but the data type will be converted to a string data type containing the string representation of the data.
- The tool will not publish, and you'll receive an error.
If you are using a result map service to draw your output data, your task can output any geodataset, since the result map service will draw the geodataset and send a map back to the client (rather than the dataset itself).
Feature Class
The Feature Class data type is supported as an output data type. When you publish a model or script, your tool is scanned, and if an output Feature Class is found, it is turned into an output Feature Set, which is transported back to the client. This transformation occurs behind the scenes; your model or script is unchanged. It only occurs with output feature classes because the transformation occurs on the server, which has all the necessary software libraries needed to perform the transformation. So, technically speaking, Feature Classes are not supported for output; they are allowed because ArcGIS Server knows how to transform them to the supported Feature Set data type.
Feature layers
A Feature layer references a feature class on disk and supports a set of selected features that result from an attribute or spatial query. You create feature layers using the Make Feature Layer tool and perform queries using the Select Layer By Attribute and Select Layer By Location tools. It is not uncommon for geoprocessing tasks to output feature layers containing selections.
When ArcGIS Server encounters an output feature layer, the selected features are converted to a feature class, and only the selected features are transported back to the client.
Output feature layers do not work in result map services.
When you use result map services, it's important to realize that there are two services—the geoprocessing service and the result map service. These two services execute independently of each other. When the task executes, ArcGIS Server executes the geoprocessing task first, then executes the result map service to draw the output of the geoprocessing service. Feature layers are transient objects held in memory for the duration of task execution. Once the task completes, these in-memory feature layers disappear. If the result map service references the same feature class found in the layer, all information about the selected features (that is, the result of your task) will be gone when the map service draws, and the result map service draws all features. If you need a map service to draw selected features in a layer, you must first save these selected features to a feature class using the Copy Features tool using your feature layer as input. Copy Features will only copy the selected features in the layer. You can then draw the copied features with a result map service.
Raster datasets
Raster datasets are supported as output only on ArcGIS Desktop clients.
Raster layers
Like feature layers, you can output a raster layer only on ArcGIS Desktop clients. When ArcGIS Server encounters an output raster layer, the raster is transported back to the client. Output raster layers do not work in result map services for the same reason that feature layers do not work, as noted above.
Other layers
Only feature layers and raster layers are supported for output (and, as mentioned, raster layers are only supported for ArcGIS Desktop clients). All other kinds of layers, such as NetCDF layers, Network Analysis layers, and Geostatistical Analysis layers, are not supported.
Other geodatasets
Output geodataset data types besides Feature Class or Raster (such as TIN or Terrain) cannot have their data transferred back to the client. However, your geoprocessing service can have a result map service to display the data, and the result of your geoprocessing service will be a map service layer that can be drawn on any client.
Table
The Table data type, like the Feature Class data type, is also supported; it is transformed into a Record Set for transport back to the client.
Strategies for unsupported data types
If the model or script you want to publish has unsupported input or output data types, or the data type is converted to a string, you must modify your model or script so that it only uses the supported input and output data types. There are two general strategies you can employ:
- Use the string representation.
- Convert data to a file.
Using the string representation
Every data type has a string representation. For more information on data string representations, see Data types for geoprocessing tool parameters.
If an input to your model is one of the data types that is converted to a string when published to ArcGIS Server, you can modify your model to accept string input, then convert the string to your desired data type. The following demonstration shows you how to do this conversion. This example first shows converting a data type's value to a string, which is the opposite of what you need to do for your model, but demonstrates an important concept: all data types have a string representation. The second part of the example shows how to convert a string to a data type value—the method you would use in your service.
The data type used for demonstration is Areal Unit.
The first part of this demonstration determines the string format of an Areal Unit.
- Create a new model.
- Create a variable with an Areal Unit data type and rename it Input AU.
- Add the Calculate Value tool.
- Double-click Calculate Value to open its dialog box. For the Expression parameter, enter %Input AU%. This instructs Calculate Value to read the contents of the variable Input AU. For the Data type parameter, choose String, as illustrated below.
- Optionally, you can make the Input AU variable a precondition to Calculate Value. A precondition means that the variable must contain a value before the tool executes. Precondition connectors are shown as dashed lines, as illustrated below.
- Double-click the Input AU variable and set its value to 1000 Square Meters.
- Click OK.
- Run the model in ModelBuilder. Double-click output_value and examine its value. The value is the string representation of the Areal Unit, as illustrated below. Note how the string representation does not contain a space between Square and Meters.
As demonstrated above, all data type values have a string representation. You can use Calculate Value to view the string representation of any data type. For example, you could input a Spatial Reference variable into Calculate Value to view its string representation.
The following steps show you how to convert a string variable into another data type. The steps are the same as above, except the input variable is a String and the output is an Areal Unit.
- Create a new model.
- Create a variable with a String data type and rename it Input AU String, as illustrated below.
- Add the Calculate Value tool.
- Double-click Calculate Value to open its dialog box. For the Expression parameter, enter %Input AU String%. This instructs Calculate Value to read the contents of the variable Input AU String.
For the Data type parameter, choose Areal Unit, as illustrated below.
- Optionally, you can make the Input AU String variable a precondition to Calculate Value. A precondition means that the variable must contain a value before the tool executes. Precondition connectors are shown as dashed lines, as illustrated below.
- Double-click the Input AU String variable and set its value to 1000 squaremeters.
- Click OK.
- Run the model in ModelBuilder. Double-click output_value and examine its value. The value is an Areal Unit, as illustrated below. The data type of output_value is actually Any value, not Areal Unit. A data type of Any value is a generic data type that can be connected to any tool parameter.
This conversion technique is also demonstrated in the Select Layer By Area model found in GP Service example: Selecting data.
The illustration below shows a model that uses the Simplify Building tool, which takes an Areal Unit as input. Because Areal Unit is not a supported input parameter data type for geoprocessing services, the model's input parameter Minimum Area is a String that is converted to an Areal Unit using the above method. The variable output_value is connected to the Minimum Area parameter of Simplify Building using ModelBuilder's Add Connection tool ().
Using this technique requires that the user of your tool enter the correct string. For example, if 1000 square meters (instead of 1000 squaremeters) is input to Calculate Value, the resulting Areal Unit will be empty. Capitalization does not matter—that is, SquareMETERS and squareMeters are equivalent.
If you want to provide more error checking in the process of converting a string to a data type, you can write a script tool to do data type conversion and add error checking to the script. The Python code below shows the basic idea.
import arcpy # Get the string and call SetParameterAsText on the output # in_string = arcpy.GetParameterAsText(0) # Do error checking/conversion here, converting "meters squared" # to "squaremeters" for example # Set the output parameter # arcpy.SetParameterAsText(1, in_string)
As illustrated below, the input data type of the tool would be String, and the output data type would be your target data type (such as Areal Unit). The output parameter Type is Derived.
Converting data to a file
A technique you can use for folder-based workspaces (file geodatabase, coverages, and shapefiles) is to instruct your user to use the ZIP compression utility to make a .zip file out of a workspace, then input the .zip file to your tool. Within your geoprocessing service, you can use the unzip script (see below) to unzip the file into a workspace and proceed from there. The same is true for outputs—you can create a .zip file of a workspace and use that for output.
Below are links to two Python scripts, zip.py and unzip.py.
- The zip.py script takes an input workspace (file geodatabase, a folder containing coverages, or a folder containing shapefiles—everything but a personal or enterprise geodatabase) and an output file name and creates a compressed ZIP file. You should add the .zip suffix to the output file name—the script doesn't automatically add the suffix.
The parameter properties are as follows:
Zip.py parametersLabel
Data Type
Type
Direction
Input workspace
Workspace
Required
Input
Output file
File
Required
Output
- The unzip.py script takes a .zip file, an output location (an existing folder), and an output name (which becomes a new folder) and writes the contents to the new folder. If the .zip file contains a file geodatabase, append .gdb to the output name.
Label |
Data Type |
Type |
Direction |
---|---|---|---|
Input ZIP file |
File |
Required |
Input |
Output Location |
Workspace |
Required |
Input |
Output Name |
String |
Required |
Input |
Output Path |
Workspace |
Derived |
Output |
For an example of using these ZIP utilities, see GP Service example: Clip and ship and GP Service example: Data on demand.