#!/usr/bin/env python # coding: utf-8 # In[1]: import geopandas as gpd import numpy as np import rasterio import rasterio.mask # In[2]: def crop_gee_output(city, raster_name): with rasterio.open(city + '/output/' + raster_name + '.tif') as src: array = src.read(1) out_meta = src.meta.copy() out_meta.update({'nodata': 'nan'}) with rasterio.open(city + '/output/' + raster_name + '.tif', 'w', **out_meta) as dest: dest.write(array, 1) # In[3]: city = 'Pristina' city_lower = city.lower() # In[7]: crop_gee_output(city, city_lower + '_Summer') # In[4]: crop_gee_output(city, city_lower + '_VIIRS_soc_14_21') crop_gee_output(city, city_lower + '_VIIRS_sol_14_21')