Python scripts to zip and unzip data

The topic Input and output data types discusses the use of file data types for input and output parameters in geoprocessing services. A technique you can use for folder-based workspaces (file geodatabase, coverages, and shapefiles) is to use the Zip compression utility to make a .zip file out of a workspace, then use the resultant .zip file as input to the model. Within the model, 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.

For an example of using the zip script, see GP service example: Clip and ship and GP service example: Data on demand.

You can create your own script tools to zip and unzip using the code described below. You can also check Model and Script tool gallery on the geoprocessing resouce center for tools to zip and unzip data.

Related Topics


4/15/2011