Пример #1
0
def idw_ga(input_shp_file, output_file_path, mask_file, z_field):
    inPointFeatures = input_shp_file
    zField = z_field
    cellSize = 0.02
    power = 2
    arcpy.CheckOutExtension("GeoStats")
#    outLayer = os.path.split(input_shp_file)[-1][:-4] os.path.split(input_shp_file)[-1][:-4]
    outLayer = "ignored_file"
    file_name = os.path.split(input_shp_file)[-1]
    year_str_list = [str(year) for year in range(2000, 2014)]
    name = None
    for year_str in year_str_list:
        if file_name.find(year_str) >= 0:
            name = int(year_str)
            break
    if  name == None:
         print("shp file can't find year")

    name = "tempto" + str(name)
    print name
    out_raster = os.path.join(output_file_path, name)
    arcpy.IDW_ga(inPointFeatures, zField,outLayer, out_raster, cellSize, power)
    print("we have idw_ga %s" % inPointFeatures)

    #Extract by mask the whole states
    inRaster = out_raster
    inMaskData = mask_file
    arcpy.CheckOutExtension("Spatial")
    outExtractByMask = ExtractByMask(inRaster, inMaskData)
    outExtractByMask.save(os.path.join(output_file_path, "es" + name ))
    print("we have produce")
Пример #2
0
def idw(inPointFeatures, zField, out_raster, in_Mask):
    if os.path.exists(out_raster):
        return
    cellSize = 0.02
    power = 2
    total_raster = os.path.join(os.path.dirname(out_raster),
                                os.path.basename(out_raster) + "IDW")
    arcpy.CheckOutExtension("GeoStats")
    arcpy.IDW_ga(inPointFeatures, zField, "", total_raster, cellSize, power)
    outExtractByMask = ExtractByMask(total_raster, in_Mask)
    outExtractByMask.save(out_raster)
    arcpy.BuildPyramids_management(out_raster)
    arcpy.Delete_management(total_raster)
Пример #3
0
def idw(input_layer, z_field):
    """Performs the IDW analysis. Returns the output layer."""
    output = z_field + '_idw'
    arcpy.IDW_ga(input_layer, z_field, output)
    return output
Пример #4
0
 arcpy.env.mask = ""
 tempEnvironment43 = arcpy.env.spatialGrid3
 arcpy.env.spatialGrid3 = "0"
 tempEnvironment44 = arcpy.env.maintainSpatialIndex
 arcpy.env.maintainSpatialIndex = "false"
 tempEnvironment45 = arcpy.env.workspace
 arcpy.env.workspace = "C:\\caio\\Curva_Permanencia\\Vazao.gdb"
 tempEnvironment46 = arcpy.env.MResolution
 arcpy.env.MResolution = ""
 tempEnvironment47 = arcpy.env.derivedPrecision
 arcpy.env.derivedPrecision = "HIGHEST"
 tempEnvironment48 = arcpy.env.ZTolerance
 arcpy.env.ZTolerance = ""
 arcpy.IDW_ga(
     fc, "StageDW_SFG_StgEstacaoCurvaPermanencia_Features_MdaiDRE_LT", "",
     OutIDW, "0,156020628", "2",
     "NBRTYPE=Smooth S_MAJOR=11,7367757908039 S_MINOR=11,7367757908039 ANGLE=0 SMOOTH_FACTOR=0,4",
     "")
 arcpy.env.newPrecision = tempEnvironment0
 arcpy.env.autoCommit = tempEnvironment1
 arcpy.env.XYResolution = tempEnvironment2
 arcpy.env.processingServerUser = tempEnvironment3
 arcpy.env.XYDomain = tempEnvironment4
 arcpy.env.processingServerPassword = tempEnvironment5
 arcpy.env.scratchWorkspace = tempEnvironment6
 arcpy.env.cartographicPartitions = tempEnvironment7
 arcpy.env.terrainMemoryUsage = tempEnvironment8
 arcpy.env.MTolerance = tempEnvironment9
 arcpy.env.compression = tempEnvironment10
 arcpy.env.coincidentPoints = tempEnvironment11
 arcpy.env.randomGenerator = tempEnvironment12
Пример #5
0
    #arcpy.DeleteField_management(saved_shp,["Field10","Field11","min_1"])
    # with arcpy.da.UpdateCursor(out_path + site + str(year) + ".dbf", "Region") as cursor:
    #    for row in cursor:
    #       if row[0] == "Unknown":
    #          cursor.deleteRow()
    #print "event " + str(year)

    # IDW
    inPointFeatures = out_path + site + str(year) + ".shp"
    zField = "ozone"
    cellSize = 0.02
    power = 2
    arcpy.CheckOutExtension("GeoStats")
    outLayer = "outIDW" + str(year)
    out_raster = out_path + "IDW" + str(year)
    arcpy.IDW_ga(inPointFeatures, zField, outLayer, out_raster, cellSize,
                 power)
    print "IDW " + str(year)

    #Extract by mask the whole states
    inRaster = out_path + "IDW" + str(year)
    inMaskData = mask_path + "newstates" + ".shp"
    arcpy.CheckOutExtension("Spatial")
    outExtractByMask = ExtractByMask(inRaster, inMaskData)
    outExtractByMask.save(out_path + "allIDW" + str(year))
    arcpy.Delete_management(out_raster)
    print "states " + str(year)

    #Build pyramid from raster
    inras = out_path + "allIDW" + str(year)
    arcpy.BuildPyramids_management(inras)
    print "Build pyramid" + str(year)
Пример #6
0
    searchNeighbourhood = arcpy.SearchNeighborhoodStandard(majSemiaxis, minSemiaxis, angle, maxNeighbors, minNeighbors,
                                                           sectorType)
    desc = arcpy.Describe(samp)
    baseName = desc.basename
    if "Bottom" in baseName:
        depth = "Bottom"
    else:
        depth = "Top"
    newSampName = baseName[:4] + "_" + depth
    env.extent = maskDic[baseName[:4]]
    env.mask = maskDic[baseName[:4]]

    for metal in ["Zinc", "Steel", "Copper"]:
        out_idw_model_Lyr = newSampName + "_ModelLyr_" + metal + ".lyr"
        # get optimized  parameters for IDW
        arcpy.IDW_ga(in_features=samp, z_field=metal, out_ga_layer=out_idw_model_Lyr, cell_size="5",
                     search_neighborhood=searchNeighbourhood)
        optimized_out_idw_model_Xml = os.path.join(optimizedOutModel,
                                                   newSampName + "_OptimizedModelLyr_" + metal + ".xml")
        arcpy.GASetModelParameter_ga(out_idw_model_Lyr,
                                     "/model[@name='IDW']/value[@name='Power']/@auto; /model[@name='IDW']/model[@name='NeighbourSearch']/value[@name='MajorSemiaxis']/@auto; /model[@name='IDW']/model[@name='NeighbourSearch']/value[@name='MinorSemiaxis']/@auto",
                                     in_param_value="true;true;true", out_ga_model=optimized_out_idw_model_Xml)

# important: no space should appear in the name of input featureclass
        #idw_dataset = samp + " " + "X=Shape Y=Shape F1=" + str(metal)
        #print "idw input dataset: ", type(idw_dataset),idw_dataset
        geo_dataset_idw = arcpy.GeostatisticalDatasets(optimized_out_idw_model_Xml)
        geo_dataset_idw.dataset1 = samp
        geo_dataset_idw.dataset1Field = metal
        outLayer_idw_optimized = os.path.join(optimizedOutLyr, newSampName + "_optimizedLyr" + metal + ".lyr")

        arcpy.GACreateGeostatisticalLayer_ga(in_ga_model_source=optimized_out_idw_model_Xml,in_datasets=geo_dataset_idw, out_layer=outLayer_idw_optimized)
Пример #7
0
def idw(p):
    arcpy.IDW_ga(inPointFeatures, zField, outLayer, outRaster, cellSize, p)