0

I'm trying to interpolate temperature data that's in multiple fields of a shapefile automatically using ArcPy. It doesn't sound like a difficult task but I'm new to both ArcGIS and Python, so here's what I came up with :


    import arcpy, os
    from arcpy import env
    from arcpy.sa import *
    # set workspce
    env.workspace = "E:/stage_DMN/fiche_exl" 
    env.extent = "E:/bureau_deplace/0_resultats_stage/shape/zone_etude.shp" 
    outws = "E:/stage_DMN/resultat_krig" 
    inpointF= r"E:/stage_DMN/" # my shapfile
    #zFields = arcpy.ListFields("E:/stage_DMN/air_tem/temperture_air_15_18.shp",field_type="Double") # i tried to retrieve feilds from my shapefile this way but
    #it didn't work so i did it manually 
    zFields = ["tem_m15","tem_m16","tem_m17","tem_m18","tem_j15","tem_j16","tem_j17","tem_j18","tem_s15","tem_s16","tem_s17","tem_s18","tem_d15","tem_d16","tem_d17","tem_d18"]
    # variables
    cellSize = 0,00052
    outVarRaster = ""
    lagSize = int()
    majorRange = int()
    partialSill = int()
    nugget = int()
    kRadius = RadiusVariable(12,)
    mask = "E:/bureau_deplace/0_resultats_stage/shape/zone_etude.shp"


    for zField in zFields: 
        kModelOrdinary = KrigingModelOrdinary("SPHERICAL", lagSize, majorRange, partialSill, nugget)
        outKriging = Kriging(inpointF, zField.name, kModelOrdinary, cellSize,kRadius, outVarRaster)
        KrigMask = ExtractByMask(OutKriging, mask)
        outraster = os.path.join(outws, str(zField) + ".img")
        outKriging.save(outraster)

When I execute it I get the following error:

Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "e:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\sa\Functions.py", line 2724, in Kriging
    out_variance_prediction_raster)
  File "e:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\sa\Utils.py", line 53, in swapper
    result = wrapper(*args, **kwargs)
  File "e:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\sa\Functions.py", line 2716, in Wrapper
    out_variance_prediction_raster)
  File "e:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\geoprocessing\_base.py", line 510, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.