{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "9011276b-57b1-4744-8c70-418f93e4541b", "metadata": {}, "outputs": [], "source": [ "import geopandas as gpd\n", "import numpy as np\n", "import rasterio\n", "import rasterio.mask" ] }, { "cell_type": "code", "execution_count": 2, "id": "02451558-f152-4b44-9f52-4da2454d901f", "metadata": {}, "outputs": [], "source": [ "def crop_gee_output(city, raster_name):\n", " with rasterio.open(city + '/output/' + raster_name + '.tif') as src:\n", " array = src.read(1)\n", " out_meta = src.meta.copy()\n", " out_meta.update({'nodata': 'nan'})\n", " with rasterio.open(city + '/output/' + raster_name + '.tif', 'w', **out_meta) as dest:\n", " dest.write(array, 1)" ] }, { "cell_type": "code", "execution_count": 3, "id": "8b66b744-2aad-4483-a8e6-d03d4f69aea9", "metadata": {}, "outputs": [], "source": [ "city = 'Pristina'\n", "city_lower = city.lower()" ] }, { "cell_type": "code", "execution_count": 7, "id": "f27f13be-1dad-4699-ace4-53a68a3caa1b", "metadata": {}, "outputs": [], "source": [ "crop_gee_output(city, city_lower + '_Summer')" ] }, { "cell_type": "code", "execution_count": 4, "id": "daa6493b-3d72-4173-8cb8-f75bcc81a705", "metadata": {}, "outputs": [], "source": [ "crop_gee_output(city, city_lower + '_VIIRS_soc_14_21')\n", "crop_gee_output(city, city_lower + '_VIIRS_sol_14_21')" ] } ], "metadata": { "kernelspec": { "display_name": "crp", "language": "python", "name": "crp" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 5 }