diff --git a/src/geoapis/vector.py b/src/geoapis/vector.py index 76ac87d..d99eb42 100644 --- a/src/geoapis/vector.py +++ b/src/geoapis/vector.py @@ -72,10 +72,21 @@ def __init__( def _set_up(self): """Ensure the bouding_polygon and CRS are in agreement.""" + error_message = "Either the crs or the bounding_polygon with a CRS mus be specified." + if self.crs is None and self.bounding_polygon is None: + logging.error(error_message) + raise ValueError(error_message) + # Set the crs from the bounding_polygon if it's not been set - if self.crs is None and self.bounding_polygon is not None: - self.crs = self.bounding_polygon.crs.to_epsg() - # Set the bounding_polygon crs from the crs if they differ + if self.bounding_polygon is not None: + if self.crs is None and self.bounding_polygon.crs is not None: + self.crs = self.bounding_polygon.crs.to_epsg() + elif self.crs is not None and self.bounding_polygon.crs is None: + self.bounding_polygon.set_crs(self.crs, inplace=True) + elif self.crs is None and self.bounding_polygon.crs is None: + logging.error(error_message) + raise ValueError(error_message) + # Convert the bounding_polygon crs from the crs if they differ if ( self.bounding_polygon is not None and self.crs != self.bounding_polygon.crs.to_epsg()