-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectingRaster.py
More file actions
31 lines (25 loc) · 1.13 KB
/
Copy pathProjectingRaster.py
File metadata and controls
31 lines (25 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## This code is utilised to project raster data
## Required Libraries: os, arcpy
## Parameters: raster directory, output directory, Map Projection
## Author: Ayman Altoum
## Date:26. July. 2019
import os
import arcpy
from arcpy import env
# Defining Workspace:
env.overwrite = True
env.workspace = r"D:\GIS\Landsat"
# Obtaining a list of directories within the workspace
folders = arcpy.ListWorkspaces("*","Folder")
os.mkdir(r"D:\GIS\Landsat_Projected")
for folder in folders:
env.workspace = folder
rasterFolder = os.path.basename(folder) # Retrieving the Sub folders name
dirpath = r"D:\GIS\Landsat_Projected" + "/" + rasterFolder # Path for new Directory
createSubdir = os.mkdir(dirpath) # Creating the new directory
outFolder = r"D:\GIS\Landsat_Projected" + "/" + rasterFolder # Path for the output folder for each raster
a = arcpy.ListRasters()
## Projecting Rasters:
for b in a:
c = b.split(".")[0]
arcpy.ProjectRaster_management(b, outFolder + '/' + c + ".tif","3857") # Web mercator