paupepui

Personalized Geopreocessing Service (Data extract) problem

Discussion created by paupepui on Feb 9, 2012
Latest reply on Feb 16, 2012 by paupepui
Hello,

I would like to make a Geoprocessiong Service in ArcGIS Server thats extracts data with a polygon. I have a copy of Extract Data Task and I personalized it.
Instead of make a clip as does the original, I have a SelectByLocation and after a CopyFeatures function. I don't want to clip but to extract features that intersects by the polygon. This is the function I modified (original clip function is commented):

def clipFeatures(lyr, aoi, featureFormat, zipFolderPath, scratchFolderPath, convertFeaturesDuringClip):
    global haveDataInterop
    try:
##        if not convertFeaturesDuringClip and not haveDataInterop:
##            raise "LicenseError"

        # get the path and a validated name for the output
        layerName, outputpath = makeOutputPath(False, lyr, convertFeaturesDuringClip, featureFormat, zipFolderPath, scratchFolderPath)

        # do the clip
        #gp.clip_analysis(lyr, aoi, outputpath)
        gp.SelectLayerByLocation_management(lyr, 'intersect', aoi)
        gp.CopyFeatures_management(lyr, outputpath)
        #Message "  clipped %s..."
        gp.AddMessage(gp.GetIDMessage(86135) % lyr)

        # if format needs data interop, convert with data interop
        if not convertFeaturesDuringClip:
            # get path to zip
            outputinzip = os.path.join(zipFolderPath, layerName + featureFormat[2])
            if featureFormat[2].lower() in [".dxf", ".dwg", ".dgn"]:
                gp.AddWarning(gp.GetIDMessage(86139))# "..using export to cad.."
                gp.ExportCAD_conversion(outputpath, featureFormat[1], outputinzip)
            else:
                if not haveDataInterop:
                    raise "LicenseError"
                diFormatString = "%s,%s" % (featureFormat[1], outputinzip)
                # run quick export
                gp.quickexport_interop(outputpath, diFormatString)

    except "LicenseError":
        #Message "  failed to export to %s.  The requested formats require the Data Interoperability extension.  This extension is currently unavailable."
        gp.AddWarning(gp.GetIDMessage(86140) % featureFormat[1])
        pass

    except:
        errorstring = gp.GetMessages(2)
        if errorstring.lower().find("failed to execute (quickexport)") > -1:
            #Message "  failed to export layer %s with Quick Export.  Please verify that the format you have specified is valid."
            gp.AddWarning(gp.GetIDMessage(86141) % lyr)
        elif errorstring.lower().find("failed to execute (clip)") > -1:
            #Message "  failed to clip layer %s...
            gp.AddWarning( gp.GetIDMessage(86142) % lyr)
        else:
            gp.AddWarning(gp.GetIDMessage(86142) % lyr)
            gp.AddWarning(gp.GetMessages(2))
        pass


When I executed the function in ArcMap with the dialog, the task works fine. The layers are not clipped. The problem comes when I publish the same service with the Geoprocessing Service. When I test it in ArcGIS Service Directory page, the resulting zip contains layers clipped, when the function I personalized is the same.

I don't understand this, when the task is the same in the Toolbox and the task published as a geoprocessing service.

Does anyone know what happens?

Thanks

Pau Pérez Puigcerver
Conselleria de Infraestructuras, Territorio y Medio Ambiente
http://cartoweb.cma.gva.es

Outcomes