示例#1
0
Feature_Zone = arcpy.GetParameterAsText(2)
if Feature_Zone == '#' or not Feature_Zone:
    Feature_Zone = "S:\\Saudi_GRACE\\Recharge\\shapefiles\\arabian_peninsula_anomalies.shp" # provide a default value if unspecified

# Local variables:
Zone_field = "Id"
Raster_Format = "TIF"
Name = Raster_Format
month001_tif = "C:\\Test_2\\images\\TWS_mass_CSR_month_NDS_200km_001.tif"
Statistics_type = "ALL"
Value = Name
AddField = Output_Table
calcOut = Output_Table

# Process: Iterate Rasters
arcpy.IterateRasters_mb(Input_Raster_Data, "", Raster_Format, "RECURSIVE")

# Process: Parse Path
arcpy.ParsePath_mb(Name, "NAME")

# Process: Zonal Statistics as Table
arcpy.gp.ZonalStatisticsAsTable_sa(Feature_Zone, Zone_field, month001_tif, Output_Table, "DATA", Statistics_type)

# Process: Add Field
arcpy.AddField_management(Output_Table, "fileName", "TEXT", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "")

# Process: Calculate Field
arcpy.CalculateField_management(Output_Table, "filename", "\"%Value%\"", "PYTHON", "")

示例#2
0
# Process: Merge
arcpy.Merge_management(
    "140117\\H140117_EYTBWMEL_bf_L3;140117\\H140117_EYTBWEH_bf_L3", L_merge,
    "Name \"Name\" true true false 254 Text 0 0 ,First,#,140117\\H140117_EYTBWMEL_bf_L3,Name,-1,-1,140117\\H140117_EYTBWEH_bf_L3,Name,-1,-1;environm \"environm\" true true false 20 Text 0 0 ,First,#,140117\\H140117_EYTBWMEL_bf_L3,environm,-1,-1"
)

# Process: Zonal Statistics as Table
arcpy.gp.ZonalStatisticsAsTable_sa(L_merge, Zone_field_and_join_Field, Raster,
                                   L_Stats_table, "DATA", "MEAN")

# Process: Add Join
arcpy.AddJoin_management(Grid, Zone_field_and_join_Field, L_Stats_table,
                         Zone_field_and_join_Field, "KEEP_ALL")

# Process: parse_table_name
arcpy.ParsePath_mb(L_Stats_table, "NAME")

# Process: Parse_grid_name
arcpy.ParsePath_mb(Grid, "NAME")

# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(BW_AB_join_result, "NEW_SELECTION",
                                        Expression_Select_layer)

# Process: Calculate Field
arcpy.CalculateField_management(BW_AB_selection_result,
                                Field_Name_Calculate_field,
                                Expression_Calculate_field, "VB", "")

# Process: Remove Join
arcpy.RemoveJoin_management(BW_AB_calculateField_result, "")
示例#3
0
# Local variables:
Basin_gSSURGO_Raster = State_gSSURGO_Raster
Joined_Raster = Basin_gSSURGO_Raster
v_Value__gssurgo = Joined_Raster
Model_Output_gdb = "P:\\NWS\\GIS\\Models\\Model_Output.gdb"
Basin_Boundary__shp_File = Folder_with_Basin__shp_Files
Value = Basin_Boundary__shp_File
Name = Folder_with_Basin__shp_Files

# Process: Iterate Feature Classes
arcpy.IterateFeatureClasses_mb(Folder_with_Basin__shp_Files, "", "POLYGON",
                               "NOT_RECURSIVE")

# Process: Parse Path
arcpy.ParsePath_mb(Basin_Boundary__shp_File, "NAME")

# Process: Extract by Mask
arcpy.gp.ExtractByMask_sa(State_gSSURGO_Raster, Basin_Boundary__shp_File,
                          Basin_gSSURGO_Raster)

# Process: Join Field
arcpy.JoinField_management(Basin_gSSURGO_Raster, "MUKEY", State_gSSURGO_Raster,
                           "hydgrpdcd", "")

# Process: Table to Table
arcpy.TableToTable_conversion(
    Joined_Raster, Model_Output_gdb, "%Value%_gssurgo", "",
    "VALUE \"VALUE\" false true true 0 Long 0 0 ,First,#,,VALUE,-1,-1,,Value,-1,-1;COUNT \"COUNT\" false true true 0 Long 0 0 ,First,#,,COUNT,-1,-1,,Count,-1,-1;MUKEY \"MUKEY\" true true false 30 Text 0 0 ,First,#,,MUKEY,-1,-1;hydgrpdcd \"Hydrologic Group - Dominant Conditions\" true true false 254 Text 0 0 ,First,#,,hydgrpdcd,-1,-1",
    "")
arcpy.ImportToolbox("Model Functions")

# Script arguments
Input_Contour_lines = arcpy.GetParameterAsText(0)

# Local variables:
Data = Input_Contour_lines
Path = "FILE"
Value = "1"
output_1 = "%Path%\\%Name%_polygon_temp_%Value%.shp"
alter_1 = output_1
alter_2 = alter_1
Name = "FILE"

# Process: Parse Path
arcpy.ParsePath_mb(Input_Contour_lines, "PATH")

# Process: Iterate Feature Selection
arcpy.IterateFeatureSelection_mb(Input_Contour_lines, "CONTOUR #", "false")

# Process: Feature To Polygon
tempEnvironment0 = arcpy.env.outputMFlag
arcpy.env.outputMFlag = "Same As Input"
arcpy.FeatureToPolygon_management("''", output_1, "", "NO_ATTRIBUTES", "")
arcpy.env.outputMFlag = tempEnvironment0

# Process: Add Field
arcpy.AddField_management(output_1, "Contour", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")

# Process: Calculate Field
arcpy.CalculateField_management(alter_1, "Contour", "%Value%", "VB", "")