Arcgis for Server download from service workaround

02-09-2015 01:39 AM
New Contributor II

     As Arcgis for server has not a built in download shapefile(or any other format) functionality the "clip and ship" geoprocessing example is being suggested by many users and developers. However I find it quite limiting. As far as I understand, the "Extract Data" tool requires first to be run with a pre-defined set of Layers as a "Parameter" just like the "Zion" example.

     What I (and many other developers) need is a script/service that takes an Arcgis Server service as an input (or a relevant js object like featureset) and returns a shapefile (or any other format) as an output. Of course I am referring to a client web application. I am using the Javascript API but if I am not mistaken Flex developers face the same issue. Thanks.

12 Replies
New Contributor II

I too am looking for a way to export a layer.  The clip and ship is not a solution when it comes to a user picking a layer from the list to export.  Unless someone knows of a way to modify the geoprocessing service to take an the proper variables.

Occasional Contributor III

i tried this example but it does not work:

ArcGIS API for JavaScript Sandbox

how do i create the geoprocessing service?

0 Kudos
MVP Esteemed Contributor


   As you probably notice, sample server 4 does not have the GP service available anymore. Here is the help doc link for creating your own clip and ship GP service:

ArcGIS Server Help - Clip and Ship

Occasional Contributor III

Thanks. The link you sent only takes me to:

ArcGIS Server Help

I dint see the example. I will search for it.

0 Kudos
MVP Esteemed Contributor


   Sorry I thought they fixed that link issue. Here is the link as plain text (don't click the link, just copy the text and paste it into your browsers address bar):


0 Kudos
New Contributor II

Hi all,

As I wrote in original post, the limitation of the above solutions is that you have to predefine the layers to clip/download. What I did to work around this limitation was to write a small script on the server, I used C# but anything will work, that provides a single service. That service takes a WFS link as an input and builds a shapefile using the GDAL library. Then wraps it up in a zip file, puts it on the server and returns a link to the file...

Not the most efficient way to do it and might time-out for large datasets but I haven't found anything better.

To avoid the timeouts you can instead of returning a link to the file, send an email with the link to the user when the zip file is ready.

I have tested libraries in js that build the shapefile on the client but they were slower and time-out a lot more.

It would be great (and surely easy to develop) if this could be done with a build in GP service.


0 Kudos
Occasional Contributor III

i found this link in the forums:

Could Not Add The Specified Data Object to the Map

and made this work:

<!DOCTYPE html>



    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <!--The viewport meta tag is used to improve the presentation and behavior of the samples

      on iOS devices-->

    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">

    <title>Extract Data</title>

    <link rel="stylesheet" href="">

    <link rel="stylesheet" href="">


      html, body {

        height: 100%;

        width: 100%;

        margin: 0;

        padding: 0;  

        visibility: hidden;

        font-family: sans-serif;


      .claro .dijitBorderContainer-child {

        border: none;


      .claro .dijitBorderContainer-dijitContentPane, .claro .dijitContentPane {

        padding: 0;


      .claro .dijitTitlePaneContentInner {

        line-height: 1.4em;


      #controls {



         width:auto !important;

         height:auto !important;



      #loading {

        display: none;

        vertical-align: middle;


      .freehandIcon { background-image:url(./images/i_draw_freepoly.png); width:20px; height:20px; }

      .polyIcon { background-image:url(./images/i_draw_poly.png); width:20px; height:20px;}


    <script src=""></script>


      var gp, map;

      var selectionToolbar;


        "esri/map", "esri/config",


        "esri/tasks/Geoprocessor", "esri/tasks/FeatureSet", "esri/toolbars/draw",

        "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol",



        "dojo/dom", "dojo/dom-style", "dojo/query", "dojo/parser",


        "dijit/layout/BorderContainer", "dijit/layout/ContentPane",

        "dijit/TitlePane", "dijit/form/CheckBox", "dijit/form/ComboBox",


      ], function(

        Map, esriConfig,


        Geoprocessor, FeatureSet, Draw,

        SimpleFillSymbol, SimpleLineSymbol,



        dom, domStyle, query, parser,


      ) {

        // Create all dijits.


        // Prevent flash of unstyled content(FOUC).

        domStyle.set(query("body")[0], "visibility", "visible");

        // Specify where the location of the proxy to use to communicate with the extract GP service. = "/proxy/";

        // Keep a reference to the loading icon DOM node.

        var loading = dom.byId("loading");

        map = new Map("map", {

          basemap: "streets",

          center: [-104.946372, 43.433484],

                    zoom: 7,


        map.on("load", initSelectionToolbar);


        var homelandSecurity = new ArcGISDynamicMapServiceLayer("");



        gp = new Geoprocessor("");


        registry.byId("polygon").on("click", function() {



        registry.byId("freehandpolygon").on("click", function() {



        registry.byId("extract").on("click", extractData);

        function initSelectionToolbar() {


          selectionToolbar = new Draw(map);

          selectionToolbar.on("draw-end", function(e) {


            var symbol = new SimpleFillSymbol(


              new SimpleLineSymbol("dash", new Color([255,0,0]), 2),

              new Color([255,255,0,0.25])


            var graphic = new Graphic(e.geometry, symbol);




        function activateTool(tool) {


          // The draw.activate expects a string like "polygon" or "freehand_polygon".




        function extractData(){

          //get clip layers

          var clipLayers = [];

          if ( registry.byId("layer3").get("checked") ) { clipLayers.push("Bedrock Geology"); }

          if ( clipLayers.length === 0 || === 0 ) {

            alert("Select layers to extract and draw an area of interest.");



          var featureSet = new FeatureSet();

          var features = [];


          featureSet.features = features;

          var params = {

            "Layers_to_Clip": clipLayers,

            "Area_of_Interest": featureSet,

            "Feature_Format": registry.byId("formatBox").get("value")


          domStyle.set(loading, "display", "inline-block");

          gp.submitJob(params, completeCallback , statusCallback, function(error){


            domStyle.set(loading, "display", "none");



        function completeCallback(jobInfo){

          if ( jobInfo.jobStatus !== "esriJobFailed" ) {

            gp.getResultData(jobInfo.jobId, "Output_Zip_File", downloadFile);



        function statusCallback(jobInfo) {

          var status = jobInfo.jobStatus;

          if ( status === "esriJobFailed" ) {


            domStyle.set("loading", "display", "none");


          else if (status === "esriJobSucceeded"){

            domStyle.set("loading", "display", "none");



        function downloadFile(outputFile){


          var theurl = outputFile.value.url; 

          window.location = theurl;





  <body class="claro">

    <div data-dojo-type="dijit/layout/BorderContainer"


         style="width: 100%; height: 100%;margin:0;">

      <div id="map"




        <div data-dojo-type="dijit/TitlePane"  data-dojo-props="title:'Extract Data'" id="controls">

          1.Select area of interest


          <button id="polygon"


            data-dojo-props="iconClass:'polyIcon', showLabel:false">



          <button id="freehandpolygon"


            data-dojo-props="iconClass:'freehandIcon', showLabel:false">




          2.Select Layers to extract data from


          <input id="layer3" data-dojo-type="dijit/form/CheckBox" checked="checked" type="checkbox"/>

          <label for="layer3">Incident Area</label>


          3.Specify download format


          <select data-dojo-type="dijit/form/ComboBox" id="formatBox">

            <option>Shapefile - SHP - .shp</option>

            <option>File Geodatabase - GDB - .gdb</option>

            <option>Autodesk AutoCAD - DXF_R2007 - .dxf</option>

            <option>Autodesk AutoCAD - DWG_R2007 - .dwg</option>

            <option>Bentley Microstation Design (V8) - DGN_V8 - .dgn</option>           



          <button id="extract" data-dojo-type="dijit/form/Button">Extract Data</button>

          <img id="loading" src="images/loading.gif">







0 Kudos
Occasional Contributor III

One problem i am having with the tutorial is that it wont let me do this:

  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.

I get the error object could not be added to the map.

0 Kudos
Regular Contributor III

You must be using the 10.0 version of the tutorial. Try the 10.1+ version here:   Geoprocessing service example: Clip And Ship—Sharing geoprocessing workflows | ArcGIS for Desktop

(The steps you mention are telling you to make a "tool layer", a concept that does not exist in 10.1+)