Created
December 3, 2019 14:42
-
-
Save OterLabb/ea7fcd7723467e39a25e170d793d6d4a to your computer and use it in GitHub Desktop.
Convert a folder with raster files to slope files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
arcpy.CheckOutExtension("Spatial") | |
from arcpy import env | |
from arcpy.sa import * | |
import os | |
maindir = r'G:\RasterFolder' | |
files = [x for x in os.listdir(maindir) if x.endswith(".tiff")] | |
outFolder = os.path.join(maindir, 'slope') | |
if not os.path.exists(outFolder): | |
os.makedirs(outFolder) | |
for file in files: | |
filepath = os.path.join(maindir, file) | |
#elevMINResult = arcpy.GetRasterProperties_management(filepath, "MINIMUM") | |
#elevMin = float(elevMINResult.getOutput(0)) | |
#print(elevMin) | |
#outMinus = Minus(filepath, elevMin) | |
# note the specification of a dataset name in the gdb below | |
filename = str(file)[:-4] + 'tif' | |
outSlope = Slope(filepath) | |
outname = os.path.join(outFolder, filename) | |
print(outname) | |
#logRaster = Log10(outMinus) | |
outSlope.save(outname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment