build_ship_raster: save reduced ship raster as tif file
This commit is contained in:
parent
691e0dbb9d
commit
6d7eae8ad2
@ -172,7 +172,7 @@ rule build_ship_raster:
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
output:
|
output:
|
||||||
RESOURCES + "shipdensity_raster.nc",
|
RESOURCES + "shipdensity_raster.tif",
|
||||||
log:
|
log:
|
||||||
LOGS + "build_ship_raster.log",
|
LOGS + "build_ship_raster.log",
|
||||||
resources:
|
resources:
|
||||||
@ -202,7 +202,7 @@ rule build_renewable_profiles:
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
ship_density=lambda w: (
|
ship_density=lambda w: (
|
||||||
RESOURCES + "shipdensity_raster.nc"
|
RESOURCES + "shipdensity_raster.tif"
|
||||||
if "ship_threshold" in config["renewable"][w.technology].keys()
|
if "ship_threshold" in config["renewable"][w.technology].keys()
|
||||||
else []
|
else []
|
||||||
),
|
),
|
||||||
|
@ -46,7 +46,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
import rioxarray as rio
|
import rioxarray
|
||||||
from _helpers import configure_logging
|
from _helpers import configure_logging
|
||||||
from build_natura_raster import determine_cutout_xXyY
|
from build_natura_raster import determine_cutout_xXyY
|
||||||
|
|
||||||
@ -64,10 +64,10 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
with zipfile.ZipFile(snakemake.input.ship_density) as zip_f:
|
with zipfile.ZipFile(snakemake.input.ship_density) as zip_f:
|
||||||
zip_f.extract("shipdensity_global.tif")
|
zip_f.extract("shipdensity_global.tif")
|
||||||
with rio.open_rasterio("shipdensity_global.tif") as ship_density:
|
with rioxarray.open_rasterio("shipdensity_global.tif") as ship_density:
|
||||||
ship_density = ship_density.drop(["band"]).sel(
|
ship_density = ship_density.drop(["band"]).sel(
|
||||||
x=slice(min(xs), max(Xs)), y=slice(max(Ys), min(ys))
|
x=slice(min(xs), max(Xs)), y=slice(max(Ys), min(ys))
|
||||||
)
|
)
|
||||||
ship_density.to_netcdf(snakemake.output[0])
|
ship_density.rio.to_raster(snakemake.output[0])
|
||||||
|
|
||||||
os.remove("shipdensity_global.tif")
|
os.remove("shipdensity_global.tif")
|
||||||
|
Loading…
Reference in New Issue
Block a user