Select to view content in your preferred language

Personalized Geopreocessing Service (Data extract) problem

2144
1
02-09-2012 11:07 PM
PauPérez_Puigcerver
Emerging Contributor
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
Tags (2)
0 Kudos
1 Reply
PauPérez_Puigcerver
Emerging Contributor
Problem solved. When I add a toolbox in ArcMap, it references to my local folder. When I publish the geoprocessing service in ArcGIS Server (another server) the toolbox points to the script in the server, that is the original.

I copied the script to the server and I reference it in the toolbox. That's all.

Regards!

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