Skip to content

Commit dc6631f

Browse files
committed
Create a stact.py file for the land subsidence
1 parent 065712b commit dc6631f

File tree

2 files changed

+558
-2
lines changed

2 files changed

+558
-2
lines changed

STAC/data/notebooks/10_Land_subsidence_prediction_maps_updated.ipynb

+13-2
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,19 @@
464464
"2050\n",
465465
"2100\n",
466466
"mild\n",
467-
"2050\n"
467+
"2050\n",
468+
"2100\n"
468469
]
470+
},
471+
{
472+
"data": {
473+
"application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 44;\n var nbb_unformatted_code = \"## Loop over variables, scenarios and years:\\n\\nfor var in VARIABLE:\\n print(var)\\n\\n # create output folder:\\n cogs_dir = processed_data_dir.joinpath(var, \\\"cogs\\\")\\n cogs_dir.mkdir(parents=True, exist_ok=True)\\n\\n # read metadata:\\n metadata_path = processed_data_dir.joinpath(var, f\\\"metadata_{var}.json\\\")\\n # NetCDF attribute alterations by means of metadata template\\n f_global = open(metadata_path)\\n meta_global = json.load(f_global)\\n\\n for scen in SCENARIO:\\n print(scen)\\n for time in TIME:\\n print(time)\\n\\n ## Remove the band dimension and add the crs\\n ds = dataset[f'ds_{scen}_2020_{time}'].isel(band=0).drop('band')\\n ds.rio.write_crs(\\\"EPSG:28992\\\")\\n\\n # add all attributes (again)\\n for attr_name, attr_val in meta_global.items():\\n if attr_name == 'PROVIDERS':\\n attr_val = json.dumps(attr_val)\\n if attr_name == \\\"MEDIA_TYPE\\\": # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\n ds.attrs['Conventions'] = \\\"CF-1.8\\\"\\n\\n # Saving\\n output_dir = cogs_dir.joinpath(scen) # if 1x run, use cog dir, if multiple, use cogs dir\\n output_dir.mkdir(parents=True, exist_ok=True)\\n\\n fname = f\\\"{time}.GeoTiff\\\"\\n\\n out_path = output_dir.joinpath(fname)\\n\\n ds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_formatted_code = \"## Loop over variables, scenarios and years:\\n\\nfor var in VARIABLE:\\n print(var)\\n\\n # create output folder:\\n cogs_dir = processed_data_dir.joinpath(var, \\\"cogs\\\")\\n cogs_dir.mkdir(parents=True, exist_ok=True)\\n\\n # read metadata:\\n metadata_path = processed_data_dir.joinpath(var, f\\\"metadata_{var}.json\\\")\\n # NetCDF attribute alterations by means of metadata template\\n f_global = open(metadata_path)\\n meta_global = json.load(f_global)\\n\\n for scen in SCENARIO:\\n print(scen)\\n for time in TIME:\\n print(time)\\n\\n ## Remove the band dimension and add the crs\\n ds = dataset[f\\\"ds_{scen}_2020_{time}\\\"].isel(band=0).drop(\\\"band\\\")\\n ds.rio.write_crs(\\\"EPSG:28992\\\")\\n\\n # add all attributes (again)\\n for attr_name, attr_val in meta_global.items():\\n if attr_name == \\\"PROVIDERS\\\":\\n attr_val = json.dumps(attr_val)\\n if (\\n attr_name == \\\"MEDIA_TYPE\\\"\\n ): # change media type to tiff, leave the rest as is\\n attr_val = \\\"IMAGE/TIFF\\\"\\n ds.attrs[attr_name] = attr_val\\n\\n ds.attrs[\\\"Conventions\\\"] = \\\"CF-1.8\\\"\\n\\n # Saving\\n output_dir = cogs_dir.joinpath(\\n scen\\n ) # if 1x run, use cog dir, if multiple, use cogs dir\\n output_dir.mkdir(parents=True, exist_ok=True)\\n\\n fname = f\\\"{time}.GeoTiff\\\"\\n\\n out_path = output_dir.joinpath(fname)\\n\\n ds.rio.to_raster(out_path, compress=\\\"DEFLATE\\\", driver=\\\"COG\\\")\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ",
474+
"text/plain": [
475+
"<IPython.core.display.Javascript object>"
476+
]
477+
},
478+
"metadata": {},
479+
"output_type": "display_data"
469480
}
470481
],
471482
"source": [
@@ -507,7 +518,7 @@
507518
" output_dir = cogs_dir.joinpath(scen) # if 1x run, use cog dir, if multiple, use cogs dir\n",
508519
" output_dir.mkdir(parents=True, exist_ok=True)\n",
509520
"\n",
510-
" fname = f\"{time}.GeoTiff\"\n",
521+
" fname = f\"{time}.tiff\"\n",
511522
"\n",
512523
" out_path = output_dir.joinpath(fname)\n",
513524
"\n",

0 commit comments

Comments
 (0)