From 3b626927c873d2c82d14e891f0be0c5c9c3ac23f Mon Sep 17 00:00:00 2001 From: giumas Date: Sat, 31 Aug 2024 22:03:02 +0200 Subject: [PATCH] added support for compound CRS --- hyo2/bag/__init__.py | 2 +- hyo2/bag/bag.py | 12 ++++++++++++ hyo2/bag/density.py | 2 ++ hyo2/bag/elevation.py | 2 ++ hyo2/bag/uncertainty.py | 2 ++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hyo2/bag/__init__.py b/hyo2/bag/__init__.py index e815338..78484c4 100644 --- a/hyo2/bag/__init__.py +++ b/hyo2/bag/__init__.py @@ -4,7 +4,7 @@ """ name = 'BAG' -__version__ = '1.2.8' +__version__ = '1.2.9' __author__ = 'gmasetti@ccom.unh.edu' __license__ = 'LGPLv3 license' __copyright__ = 'Copyright (c) 2024, University of New Hampshire, Center for Coastal and Ocean Mapping' diff --git a/hyo2/bag/bag.py b/hyo2/bag/bag.py index aa79a70..0cc8c52 100644 --- a/hyo2/bag/bag.py +++ b/hyo2/bag/bag.py @@ -296,6 +296,8 @@ def uncertainty_greater_than(self, th: float) -> list[list[int | float]]: in_srs = osr.SpatialReference() in_srs.ImportFromWkt(self.meta.wkt_srs) + if in_srs.IsCompound(): + in_srs.StripVertical() out_srs = osr.SpatialReference() out_srs.ImportFromEPSG(4326) out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) @@ -342,6 +344,8 @@ def uncertainty_has_depth(self) -> list[list[int | float]]: in_srs = osr.SpatialReference() in_srs.ImportFromWkt(self.meta.wkt_srs) + if in_srs.IsCompound(): + in_srs.StripVertical() out_srs = osr.SpatialReference() out_srs.ImportFromEPSG(4326) out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) @@ -394,6 +398,8 @@ def depth_has_uncertainty(self) -> list[list[int | float]]: in_srs = osr.SpatialReference() in_srs.ImportFromWkt(self.meta.wkt_srs) + if in_srs.IsCompound(): + in_srs.StripVertical() out_srs = osr.SpatialReference() out_srs.ImportFromEPSG(4326) out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) @@ -458,6 +464,8 @@ def vr_uncertainty_greater_than(self, th: float) -> list[list[int | float]]: in_srs = osr.SpatialReference() in_srs.ImportFromWkt(self.meta.wkt_srs) + if in_srs.IsCompound(): + in_srs.StripVertical() out_srs = osr.SpatialReference() out_srs.ImportFromEPSG(4326) out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) @@ -515,6 +523,8 @@ def vr_depth_has_uncertainty(self) -> list[list[int | float]]: in_srs = osr.SpatialReference() in_srs.ImportFromWkt(self.meta.wkt_srs) + if in_srs.IsCompound(): + in_srs.StripVertical() out_srs = osr.SpatialReference() out_srs.ImportFromEPSG(4326) out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) @@ -576,6 +586,8 @@ def vr_uncertainty_has_depth(self) -> list[list[int | float]]: in_srs = osr.SpatialReference() in_srs.ImportFromWkt(self.meta.wkt_srs) + if in_srs.IsCompound(): + in_srs.StripVertical() out_srs = osr.SpatialReference() out_srs.ImportFromEPSG(4326) out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) diff --git a/hyo2/bag/density.py b/hyo2/bag/density.py index 4a5a13e..56e978c 100644 --- a/hyo2/bag/density.py +++ b/hyo2/bag/density.py @@ -55,6 +55,8 @@ def __init__(self, bag_density: np.ndarray, bag_meta: Meta, fmt="geotiff", out_f self.srs.ImportFromWkt(self.bag_meta.wkt_srs) else: logger.warning("unable to recover valid spatial reference info") + if self.srs.IsCompound(): + self.srs.StripVertical() self.rst.SetProjection(self.srs.ExportToWkt()) self.bnd.FlushCache() diff --git a/hyo2/bag/elevation.py b/hyo2/bag/elevation.py index 826a423..6723268 100644 --- a/hyo2/bag/elevation.py +++ b/hyo2/bag/elevation.py @@ -56,6 +56,8 @@ def __init__(self, bag_elevation: np.ndarray, bag_meta: Meta, fmt="geotiff", out self.srs.ImportFromWkt(self.bag_meta.wkt_srs) else: logger.warning("unable to recover valid spatial reference info") + if self.srs.IsCompound(): + self.srs.StripVertical() self.rst.SetProjection(self.srs.ExportToWkt()) self.bnd.FlushCache() diff --git a/hyo2/bag/uncertainty.py b/hyo2/bag/uncertainty.py index 436ed94..0bbec12 100644 --- a/hyo2/bag/uncertainty.py +++ b/hyo2/bag/uncertainty.py @@ -56,6 +56,8 @@ def __init__(self, bag_uncertainty: np.ndarray, bag_meta: Meta, fmt="geotiff", o self.srs.ImportFromWkt(self.bag_meta.wkt_srs) else: logger.warning("unable to recover valid spatial reference info") + if self.srs.IsCompound(): + self.srs.StripVertical() self.rst.SetProjection(self.srs.ExportToWkt()) self.bnd.FlushCache()