diff --git a/geoviews/__init__.py b/geoviews/__init__.py index 01d11226..d5f8935e 100644 --- a/geoviews/__init__.py +++ b/geoviews/__init__.py @@ -13,7 +13,7 @@ Contours, Graph, TriMesh, Nodes, EdgePaths, QuadMesh, VectorField, HexTiles, Labels, Rectangles, Segments, WindBarbs ) -from .util import load_tiff, from_xarray # noqa (API import) +from .util import from_xarray # noqa (API import) from .operation import project # noqa (API import) from ._warnings import GeoviewsDeprecationWarning, GeoviewsUserWarning # noqa: F401 from . import data # noqa (API import) diff --git a/geoviews/element/geo.py b/geoviews/element/geo.py index eb00ff71..4968eec1 100644 --- a/geoviews/element/geo.py +++ b/geoviews/element/geo.py @@ -47,7 +47,7 @@ class HvImageStack: ... _IMAGESTACK_AVAILABLE = False from ..util import ( - path_to_geom_dicts, polygons_to_geom_dicts, load_tiff, from_xarray, + path_to_geom_dicts, polygons_to_geom_dicts, from_xarray, poly_types, expand_geoms, transform_shapely ) @@ -394,11 +394,6 @@ class Image(_Element, HvImage): group = param.String(default='Image') - @classmethod - def load_tiff(cls, filename, crs=None, apply_transform=False, - nan_nodata=False, **kwargs): - return load_tiff(filename, crs, apply_transform, **kwargs) - @classmethod def from_xarray(cls, da, crs=None, apply_transform=False, nan_nodata=False, **kwargs): @@ -466,11 +461,6 @@ class QuadMesh(_Element, HvQuadMesh): _binned = True - @classmethod - def load_tiff(cls, filename, crs=None, apply_transform=False, - nan_nodata=False, **kwargs): - return load_tiff(filename, crs, apply_transform, **kwargs) - @classmethod def from_xarray(cls, da, crs=None, apply_transform=False, nan_nodata=False, **kwargs): @@ -527,36 +517,6 @@ class RGB(_Element, HvRGB): If an alpha channel is supplied, the defined alpha_dimension is automatically appended to this list.""") - @classmethod - def load_tiff(cls, filename, crs=None, apply_transform=False, - nan_nodata=False, **kwargs): - """ - Returns an RGB or Image element loaded from a geotiff file. - - The data is loaded using xarray and rasterio. If a crs attribute - is present on the loaded data it will attempt to decode it into - a cartopy projection otherwise it will default to a non-geographic - HoloViews element. - - Parameters - ---------- - filename: string - Filename pointing to geotiff file to load - crs: Cartopy CRS or EPSG string (optional) - Overrides CRS inferred from the data - apply_transform: boolean - Whether to apply affine transform if defined on the data - nan_nodata: boolean - If data contains nodata values convert them to NaNs - **kwargs: - Keyword arguments passed to the HoloViews/GeoViews element - - Returns - ------- - element: Image/RGB/QuadMesh element - """ - return load_tiff(filename, crs, apply_transform, **kwargs) - @classmethod def from_xarray(cls, da, crs=None, apply_transform=False, nan_nodata=False, **kwargs): diff --git a/geoviews/tile_sources.py b/geoviews/tile_sources.py index dad2af56..7da31d67 100644 --- a/geoviews/tile_sources.py +++ b/geoviews/tile_sources.py @@ -185,14 +185,6 @@ OSM = WMTS('https://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png', name="OSM") OpenTopoMap = WMTS('https://a.tile.opentopomap.org/{Z}/{X}/{Y}.png', name="OpenTopoMap") -def __getattr__(name): - if name == "Wikipedia": - from ._warnings import deprecated - deprecated("1.11", "Wikipedia", "OSM") - return WMTS('https://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png', name="Wikipedia") - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") - - tile_sources = {k: v for k, v in locals().items() if isinstance(v, WMTS) and k != 'ESRI' and "Stamen" not in k} stamen_sources = [k for k, v in locals().items() if isinstance(v, WMTS) and "Stamen" in k] diff --git a/geoviews/util.py b/geoviews/util.py index a12dfd0d..68914d38 100644 --- a/geoviews/util.py +++ b/geoviews/util.py @@ -1,5 +1,3 @@ -import warnings - import numpy as np import shapely import shapely.geometry as sgeom @@ -14,7 +12,7 @@ from shapely.geometry.base import BaseMultipartGeometry from shapely.ops import transform -from ._warnings import deprecated, warn +from ._warnings import warn geom_types = (MultiLineString, LineString, MultiPolygon, Polygon, LinearRing, Point, MultiPoint) @@ -611,50 +609,6 @@ def process_crs(crs): raise ValueError("Projection must be defined as a EPSG code, proj4 string, cartopy CRS or pyproj.Proj.") from Exception(*errors) -def load_tiff(filename, crs=None, apply_transform=False, nan_nodata=False, **kwargs): - """ - Returns an RGB or Image element loaded from a geotiff file. - - The data is loaded using xarray and rasterio. If a crs attribute - is present on the loaded data it will attempt to decode it into - a cartopy projection otherwise it will default to a non-geographic - HoloViews element. - - Parameters - ---------- - filename: string - Filename pointing to geotiff file to load - crs: Cartopy CRS or EPSG string (optional) - Overrides CRS inferred from the data - apply_transform: boolean - Whether to apply affine transform if defined on the data - nan_nodata: boolean - If data contains nodata values convert them to NaNs - **kwargs: - Keyword arguments passed to the HoloViews/GeoViews element - - Returns - ------- - element: Image/RGB/QuadMesh element - """ - new = ( - "geoviews.util.from_xarray(rioxarray.open_rasterio(filename))" - ) - try: - import xarray as xr - except ImportError: - raise ImportError('Loading tiffs requires xarray to be installed') from None - try: - with warnings.catch_warnings(): - warnings.filterwarnings('ignore') - da = xr.open_rasterio(filename) - deprecated("1.11", "load_tiff(filename)", new) - return from_xarray(da, crs, apply_transform, nan_nodata, **kwargs) - except AttributeError as e: - raise ImportError( - f"'load_tiff' is not supported anymore. Use {new!r} instead." - ) from e - def from_xarray(da, crs=None, apply_transform=False, nan_nodata=False, **kwargs): """ Returns an RGB or Image element given an xarray DataArray