-
Notifications
You must be signed in to change notification settings - Fork 3
/
clip_land_use.py
30 lines (23 loc) · 1.01 KB
/
clip_land_use.py
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
"""
This script clips the 2009 ESA land cover map and reprojects it to EPSG 3395
Author : Celray James CHAWANDA
Email : [email protected]
Institution : VUB
Licence : MIT (Latest)
"""
import os, sys
from shutil import copyfile
if not os.path.isdir("../Data/"):
os.makedirs("../Data/")
copyfile("land_lookup.csv", "../Data/land_lookup.csv")
resolution = 300
epsg_code = 32637
# reprojecting the raster
input_tif = "ESACCI-LC-L4-LCCS-Map-300m-P1Y-2009-v2.0.7.tif"
output_tif = " ../Data/blue_nile_{0}_land_use.tif".format(str(resolution).replace(".", "_"))
print(" >> reprojecting raster {0} to EPSG:{1}".format(input_tif, str(epsg_code)))
# apply mask
mask_ = "{0}/mask/blue_nile_3395.shp".format(os.getcwd())
print(" and applying mask, {0}".format(mask_))
sys.stdout.write("\t ")
os.system("gdalwarp -r mode -t_srs EPSG:{0} -tr {1} -{1} -dstnodata -32768 -ot Int32 -of GTiff -cutline {2} -crop_to_cutline {3} {4} -overwrite".format(epsg_code, resolution, mask_, input_tif, output_tif))