# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # BatchProjectRasters.py # Created on: 2016-09-08 10:57:56.00000 # (generated by ArcGIS/ModelBuilder) # Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy # Load required toolboxes arcpy.ImportToolbox("Model Functions") # Local variables: Output_Coordinate_System = "PROJCS['WGS_1984_UTM_zone_33S',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['false_easting',500000.0],PARAMETER['false_northing',10000000.0],PARAMETER['central_meridian',15.0],PARAMETER['scale_factor',0.9996],PARAMETER['latitude_of_origin',0.0],UNIT['Meter',1.0]]" Downloads = "C:\\Users\\jymutua\\Downloads" Hansen_GFC2015_treecover2000_10S_010E_tif = "C:\\Users\\jymutua\\Downloads\\Hansen_GFC2015_treecover2000_20S_020E.tif" v_Name_ = "D:\\Trash\\%Name%" # Process: Iterate Rasters arcpy.IterateRasters_mb(Downloads, "", "TIF", "NOT_RECURSIVE") # Process: Project Raster arcpy.ProjectRaster_management(Hansen_GFC2015_treecover2000_10S_010E_tif, v_Name_, Output_Coordinate_System, "NEAREST", "28.6824804653631 28.6824804653631", "", "", "")
# Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy # Check out any necessary licenses arcpy.CheckOutExtension("spatial") # Load required toolboxes arcpy.ImportToolbox("Model Functions") # Local variables: Wen_basin = "Wen_basin" NARR = "D:\\OneDrive\\work\\research\\CHaMP\\CHaMP_data\\Wenatchee\\NARR" Temp = "D:\\OneDrive\\work\\GIS\\NARR\\2002\\Temp" Temp__2_ = "D:\\OneDrive\\work\\GIS\\NARR\\2002\\Temp" narrmon-a_221_20020101_0000_000_grb-var74-t0_flt = "D:\\OneDrive\\work\\GIS\\NARR\\2002\\Temp\\narrmon-a_221_20020101_0000_000.grb-var74-t0.flt" v_Name__dbf = "D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf" # Process: Iterate Rasters arcpy.IterateRasters_mb(Temp, "", "", "NOT_RECURSIVE") # Process: Zonal Statistics as Table arcpy.gp.ZonalStatisticsAsTable_sa(Wen_basin, "Id", narrmon-a_221_20020101_0000_000_grb-var74-t0_flt, v_Name__dbf, "DATA", "ALL") # Process: Table to Table arcpy.TableToTable_conversion(v_Name__dbf, Temp__2_, "%Name%_t.dbf", "", "Id \"Id\" true true false 0 Long 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Id,-1,-1;Count \"Count\" true true false 0 Long 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Count,-1,-1;Area \"Area\" true true false 0 Double 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Area,-1,-1;Min \"Min\" true true false 0 Long 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Min,-1,-1;Max \"Max\" true true false 0 Long 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Max,-1,-1;Range \"Range\" true true false 0 Long 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Range,-1,-1;Variety \"Variety\" true true false 0 Long 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Variety,-1,-1;Majority \"Majority\" true true false 0 Long 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Majority,-1,-1;Minority \"Minority\" true true false 0 Long 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Minority,-1,-1;Median \"Median\" true true false 0 Long 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Median,-1,-1;Mean \"Mean\" true true false 0 Double 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Mean,-1,-1;Std \"Std\" true true false 0 Double 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Std,-1,-1;Sum \"Sum\" true true false 0 Double 0 0 ,First,#,D:\\OneDrive\\work\\GIS\\NARR\\2002\\%Name%.dbf,Sum,-1,-1", "")
if cum_viewshed_gdb == '#' or not cum_viewshed_gdb: cum_viewshed_gdb = "C:\\datatemp\\cum_viewshed.gdb" # provide a default value if unspecified cum_viewshed_final = arcpy.GetParameterAsText(1) if cum_viewshed_final == '#' or not cum_viewshed_final: cum_viewshed_final = "c:\\\\datatemp\\cum_viewshed.gdb\\cum_viewshed_final" # provide a default value if unspecified # Local variables: Name = "cum_viewshed_final" viewshed1 = "C:\\datatemp\\cum_viewshed.gdb\\cum_viewshed_final" cum_viewshed_final__2_ = "C:\\datatemp\\cum_viewshed.gdb\\cum_viewshed_final" Plus_Raster1 = "C:\\datatemp\\cum_viewshed.gdb\\Plus_Raster1" Delete_succeeded = "true" # Process: Iterate Rasters arcpy.IterateRasters_mb(cum_viewshed_gdb, "", "", "NOT_RECURSIVE") # Process: Plus arcpy.gp.Plus_sa(viewshed1, cum_viewshed_final__2_, Plus_Raster1) # Process: Delete arcpy.Delete_management(cum_viewshed_final__2_, "RasterDataset") # Process: Copy arcpy.Copy_management(Plus_Raster1, cum_viewshed_final, "RasterDataset") #Step 4: get OPs for sites # Script arguments site_layer = arcpy.GetParameterAsText(0) if site_layer == '#' or not site_layer:
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", "")
>>> # -*- coding: utf-8 -*- ... # --------------------------------------------------------------------------- ... # Clip Multiple Raster Datasets.py ... # Created on: 2017-05-06 09:26:31.00000 ... # Author: Dariush Ameli (Originally generated by ArcGIS/ModelBuilder) ... # Description: ... # --------------------------------------------------------------------------- ... ... # Import arcpy module ... import arcpy ... ... # Load required toolboxes ... arcpy.ImportToolbox("Model Functions") ... ... # Local variables: ... ... # All the raster inputs must be in a FOLDER ... RastFolder = "C:\\Azz\\RastFolder" ... Name = "Topo.tif" ... cbd_tif = "C:\\Azz\\RastFolder\\Topo.tif" ... StateBorder = "StateBorder" ... # To avoid overwrite outputs, the Name of generated files include their input name ... Clip__Name_ = "C:\\Azz\\Clip_%Name%" ... # Process: Iterate Rasters ... arcpy.IterateRasters_mb(RastFolder, "", "", "RECURSIVE") ... ... # Process: Clip ... arcpy.Clip_management(cbd_tif, "37106.4361103842 3380834.79606917 781570.283481221 4180992.8201444", Clip__Name_, StateBorder, "255", "ClippingGeometry", "MAINTAIN_EXTENT") ... ...
Zone_field = arcpy.GetParameterAsText(0) if Zone_field == '#' or not Zone_field: Zone_field = "ID" # provide a default value if unspecified v_Name_ = arcpy.GetParameterAsText(1) if v_Name_ == '#' or not v_Name_: v_Name_ = "C:\\GIS\\PRISM\\Table\\%Name%" # provide a default value if unspecified Wildcard = arcpy.GetParameterAsText(2) if Wildcard == '#' or not Wildcard: Wildcard = "a30*" # provide a default value if unspecified HUCS = arcpy.GetParameterAsText(3) if HUCS == '#' or not HUCS: HUCS = "U:\\GWP\\Groundwater\\PowderMt\\Powder_Mtn.gdb\\Watershed" # provide a default value if unspecified Downsampled = arcpy.GetParameterAsText(4) if Downsampled == '#' or not Downsampled: Downsampled = "C:\\GIS\\PRISM\\Downsampled" # provide a default value if unspecified # Local variables: Raster = Downsampled Name = Downsampled # Process: Iterate Rasters arcpy.IterateRasters_mb(Downsampled, Wildcard, "", "NOT_RECURSIVE") # Process: Zonal Statistics as Table arcpy.gp.ZonalStatisticsAsTable_sa(HUCS, Zone_field, Raster, v_Name_, "DATA", "ALL")
# --------------------------------------------------------------------------- # Raster_It.py # Created on: 2012-07-25 08:43:00.00000 # (generated by ArcGIS/ModelBuilder) # Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy # Load required toolboxes arcpy.ImportToolbox("Model Functions") # Local variables: v1890-1920 = "C:\\CHANG\\PRISM\\ppt\\PACE_Rasters\\1890-1920" v1890-1920__2_ = "C:\\CHANG\\PRISM\\ppt\\PACE_Rasters\\1890-1920" # Process: Iterate Rasters arcpy.IterateRasters_mb(v1890-1920, "", "IMG", "RECURSIVE") # Process: Mosaic To New Raster arcpy.MosaicToNewRaster_management("C:\\CHANG\\PRISM\\ppt\\PACE_Rasters\\1890-1920\\us_ppt_1895.04.img", v1890-1920__2_, "1890-1920ppt", "", "8_BIT_UNSIGNED", "", "1", "MEAN", "FIRST")
"C:/saga-6.4.0_x64/ArcSAGA Toolboxes/Terrain Analysis - Lighting, Visibility.pyt" ) # Local variables: GeoTiffDEM_32 = "I:\\GeoTiffDEM_32" Name = "MN_000_077_dem" Input = "I:\GeoTiffDEM_32" MN_000_077_dem_tif = "I:\\GeoTiffDEM_32\\MN_000_077_dem.tif" v_NAME__POS_tif = "I:\\Openness\\Temp\\%NAME%_POS.tif" v_NAME__NEG_tif = "I:\\Openness\\Temp\\%NAME%_NEG.tif" v_NAME__PminusN_tif = "I:\\Openness\\Temp\\%NAME%_PminusN.tif" Input_raster_or_constant_value_2 = "2" v_NAME__Open_tif = "I:\\Openness\\Final_output\\%NAME%_Open.tif" # Process: Iterate Rasters arcpy.IterateRasters_mb(GeoTiffDEM_32, "", "TIF", "NOT_RECURSIVE") # Process: Topographic Openness arcpy.gp.toolbox = "C:/saga-6.4.0_x64/ArcSAGA Toolboxes/Terrain Analysis - Lighting, Visibility.pyt" # Warning: the toolbox C:/saga-6.4.0_x64/ArcSAGA Toolboxes/Terrain Analysis - Lighting, Visibility.pyt DOES NOT have an alias. # Please assign this toolbox an alias to avoid tool name collisions # And replace arcpy.gp.tool_5(...) with arcpy.tool_5_ALIAS(...) arcpy.gp.tool_5(MN_000_077_dem_tif, v_NAME__POS_tif, v_NAME__NEG_tif, "50", "sectors", "3", "8") # Process: Minus arcpy.Minus_3d(v_NAME__POS_tif, v_NAME__NEG_tif, v_NAME__PminusN_tif) # Process: Divide arcpy.Divide_3d(v_NAME__PminusN_tif, Input_raster_or_constant_value_2, v_NAME__Open_tif)