From 33d64785c9c75a9131b997514673a7d562b3acb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dav=C3=ADd=20Brakenhoff?= Date: Thu, 24 Aug 2023 17:48:15 +0200 Subject: [PATCH] fix Projection issue in backgroundmaps #240 - add custom crs definition string --- nlmod/dims/base.py | 3 ++- nlmod/epsg28992.py | 7 +++++++ nlmod/plot/plotutil.py | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 nlmod/epsg28992.py diff --git a/nlmod/dims/base.py b/nlmod/dims/base.py index f65796ff..4f475036 100644 --- a/nlmod/dims/base.py +++ b/nlmod/dims/base.py @@ -7,6 +7,7 @@ from scipy.spatial import cKDTree from .. import util +from ..epsg28992 import EPSG_28992 from . import resample from .layers import fill_nan_top_botm_kh_kv, set_idomain @@ -490,7 +491,7 @@ def get_ds( botm=None, kh=10.0, kv=1.0, - crs=28992, + crs=EPSG_28992, xorigin=0.0, yorigin=0.0, angrot=0.0, diff --git a/nlmod/epsg28992.py b/nlmod/epsg28992.py new file mode 100644 index 00000000..9514b6ff --- /dev/null +++ b/nlmod/epsg28992.py @@ -0,0 +1,7 @@ +# NOTE: this is the correct epsg:28992 definition for plotting backgroundmaps in RD +EPSG_28992 = ( + "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 " + "+x_0=155000 +y_0=463000 +ellps=bessel " + "+towgs84=565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725 +units=m " + "+no_defs" +) diff --git a/nlmod/plot/plotutil.py b/nlmod/plot/plotutil.py index dffb6970..49af4704 100644 --- a/nlmod/plot/plotutil.py +++ b/nlmod/plot/plotutil.py @@ -4,7 +4,7 @@ from matplotlib.ticker import FuncFormatter, MultipleLocator from ..dims.resample import get_affine_mod_to_world - +from ..epsg28992 import EPSG_28992 def get_patches(ds, rotated=False): """Get the matplotlib patches for a vertex grid.""" @@ -87,7 +87,7 @@ def get_map( fmt="{:.0f}", sharex=False, sharey=True, - crs=28992, + crs=EPSG_28992, background=False, alpha=0.5, tight_layout=True,