Skip to content

Commit

Permalink
Experiment with creating contours from GEBCO grid
Browse files Browse the repository at this point in the history
  • Loading branch information
trey-stafford committed Jun 26, 2023
1 parent cb00aa8 commit 8d7c906
Showing 1 changed file with 59 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from qgreenland.config.datasets.bathymetric_chart import gebco_bathymetric_chart
from qgreenland.config.helpers.layers.geological_map import make_layer
from qgreenland.config.helpers.steps.compress_and_add_overviews import (
compress_and_add_overviews,
)
from qgreenland.config.helpers.steps.decompress import decompress_step
from qgreenland.config.helpers.steps.warp_and_cut import warp_and_cut
from qgreenland.config.project import project
from qgreenland.models.config.layer import Layer, LayerInput
from qgreenland.models.config.step import CommandStep

_background_boundary = project.boundaries["background"]
_background_bbox = _background_boundary.bbox
Expand All @@ -16,6 +16,9 @@
description=(
"""Bathymetric elevation in meters.
Negative values represent bathymetric depths and positive values are
topographic heights.
Elevations can be assumed to be relative to mean sea level. However, in
some shallow water areas, the grids include data from sources having a
vertical datum other than mean sea level. We are working to understand
Expand Down Expand Up @@ -49,21 +52,61 @@
],
)

gebco_bathymetric_contours = Layer(
id="gebco_bathymetric_contours",
title="Depth contours",
description=(
"""Bathymetric elevation contours in meters.
bathymetric_contours_params = {
"id": "bathymetric_contours",
"title": "Depth contours",
"description": (
"""This dataset includes linear features that represent
bathymetric contours recorded in metres,
derived from the International Bathymetric Chart of the Arctic Ocean."""
),
"style": "bathymetry",
"input_filepath": "data/shape/base/bathymetry",
"fn_mask": "bathymetry.*",
}
Contour interval is 100m and was derived from the "Depth (400m)" layer.
bathymetric_contours = make_layer(
layer_id=bathymetric_contours_params["id"],
layer_params=bathymetric_contours_params,
Elevations can be assumed to be relative to mean sea level. However, in
some shallow water areas, the grids include data from sources having a
vertical datum other than mean sea level. We are working to understand
how best to fully assimilate these data."""
),
tags=[],
style="bathymetry",
input=LayerInput(
dataset=gebco_bathymetric_chart,
asset=gebco_bathymetric_chart.assets["only"],
),
steps=[
decompress_step(input_file="{input_dir}/gebco_2023.zip"),
*warp_and_cut(
input_file="NETCDF:{input_dir}/GEBCO_2023.nc:elevation",
output_file="{output_dir}/bathymetric_chart.tif",
reproject_args=(
"-te",
f"{_background_bbox.min_x} {_background_bbox.min_y} {_background_bbox.max_x} {_background_bbox.max_y}",
"-tr",
"400",
"400",
),
cut_file=project.boundaries["background"].filepath,
),
CommandStep(
args=[
"gdal_calc.py",
'--calc="where(A < 0, absolute(A), nan)"',
"--A_band=1",
"-A",
"{input_dir}/bathymetric_chart.tif",
"--outfile={output_dir}/positive_depths.tif",
],
),
CommandStep(
args=[
"gdal_contour",
"-a",
"DEPTH",
"-i",
"500",
"-nln",
"bathymetry",
"{input_dir}/positive_depths.tif",
"{output_dir}/bathymetric_chart.gpkg",
],
),
],
)

0 comments on commit 8d7c906

Please sign in to comment.