Newer
Older
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Converting NetCDF into COGs\n",
"Copying the data from the network drive using a wildcard to get SWE maps. \\\n",
"Then using a function defined in utils.py to convert the NetCDF files into COGs. "
"from utils import copy_netcdf_data\n",
"from conversion import netcdf_to_cog, process_multiple_datasets\n",
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Find and copy the SWE data to the data folder\n",
"netcdf_path = \"/mnt/CEPH_PROJECTS/PROSNOW/SENTINEL-2/Daily_SCA/Venosta/*_swe.nc\"\n",
"output = \"./data\"\n",
"copy_netcdf_data(netcdf_path, output)"
"# Convert single NetCDF into a folder of COGs\n",
"cogs = netcdf_to_cog(\n",
" netcdf_path=\"./data/venosta_hy2021_swe.nc\",\n",
" cog_dir=\"./output_cog/venosta_2021_cog/\",\n",
")"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Convert a list of NetCDF files into their respective output COG folders\n",
" \"./data/venosta_hy1718_swe.nc\",\n",
" \"./data/venosta_hy1819_swe.nc\",\n",
" \"./data/venosta_hy1920_swe.nc\",\n",
" \"./data/venosta_hy2021_swe.nc\",\n",
" \"./data/venosta_hy2122_swe.nc\",\n",
" \"./output_cog/venosta_1819_cog/\",\n",
" \"./output_cog/venosta_1819_cog/\",\n",
" \"./output_cog/venosta_1920_cog/\",\n",
" \"./output_cog/venosta_2021_cog/\",\n",
" \"./output_cog/venosta_2122_cog/\",\n",
"]\n",
"\n",
"process_multiple_datasets(net_cdf_paths, cog_dirs)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# Transform the coordinates of the COGs to any EPSG\n",
"# In this case EPSG:3035\n",
"dirs = [\n",
" \"./output_cog/venosta_1718_cog\",\n",
" \"./output_cog/venosta_1819_cog\",\n",
" \"./output_cog/venosta_1920_cog\",\n",
" \"./output_cog/venosta_2021_cog\",\n",
" \"./output_cog/venosta_2122_cog\",\n",
"]\n",
"transform_cogs_in_dirs(dirs, \"EPSG:3035\")"
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"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": 2
}