Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecations #701

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion geoviews/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 1 addition & 41 deletions geoviews/element/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 0 additions & 8 deletions geoviews/tile_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
48 changes: 1 addition & 47 deletions geoviews/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

import numpy as np
import shapely
import shapely.geometry as sgeom
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down