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 #1897

Merged
merged 7 commits into from
Oct 8, 2021
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
6 changes: 1 addition & 5 deletions docs/source/reference/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ automatically load the proper tile and resolution depending on the desired domai
img_tiles.OrdnanceSurvey
img_tiles.QuadtreeTiles
img_tiles.Stamen
img_tiles.StamenTerrain


Open Geospatial Consortium (OGC)
Expand All @@ -82,18 +81,15 @@ using classes and functions defined below.

.. autosummary::
:toctree: generated/
:recursive:

srtm.SRTM1Source
srtm.SRTM3Source
srtm.SRTMDownloader
srtm.SRTM3_retrieve
srtm.read_SRTM
srtm.read_SRTM1
srtm.read_SRTM3
srtm.srtm
srtm.srtm_composite
srtm.add_shading
srtm.fill_gaps


Base classes and functions
Expand Down
4 changes: 2 additions & 2 deletions docs/source/whatsnew/v0.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ Deprecations
methods have therefore been deprecated and will be removed in future
releases. The function :func:`cartopy.io.srtm.srtm` has been replaced with
the :meth:`cartopy.io.srtm.SRTM3Source.single_tile` method. Similarly,
:func:`cartopy.io.srtm.srtm_composite` and
:func:`cartopy.io.srtm.SRTM3_retrieve` have been replaced with the
``cartopy.io.srtm.srtm_composite`` and
``cartopy.io.srtm.SRTM3_retrieve`` have been replaced with the
:meth:`cartopy.io.srtm.SRTM3Source.combined` and
:meth:`cartopy.io.srtm.SRTM3Source.srtm_fname` methods respectively.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/whatsnew/v0.17.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ Features

Deprecations
------------
* :func:`cartopy.mpl.clip_path.clip_path` has been deprecated. It is a simple
* ``cartopy.mpl.clip_path.clip_path`` has been deprecated. It is a simple
wrapper for Matplotlib's path clipping, so use that instead. You can replace
``clip_path(subject, clip_bbox)`` by ``subject.clip_to_bbox(clip_bbox)``.

* :class:`cartopy.io.img_tiles.StamenTerrain` has been deprecated. Use
* ``cartopy.io.img_tiles.StamenTerrain`` has been deprecated. Use
``Stamen('terrain-background')`` instead.

* In CartoPy 0.18, the default value for the ``origin`` argument to
Expand Down
2 changes: 1 addition & 1 deletion docs/source/whatsnew/v0.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ A summary of the main features added with version 0.5:

Deprecations
------------
* The method :meth:`Axes.natural_earth_shp()` has been replaced by the
* The method ``Axes.natural_earth_shp()`` has been replaced by the
method :meth:`Axes.add_feature()` and the :mod:`cartopy.feature`
module.
18 changes: 1 addition & 17 deletions lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ class LambertConformal(Projection):

def __init__(self, central_longitude=-96.0, central_latitude=39.0,
false_easting=0.0, false_northing=0.0,
secant_latitudes=None, standard_parallels=None,
standard_parallels=(33, 45),
globe=None, cutoff=-30):
"""
Parameters
Expand All @@ -1720,9 +1720,6 @@ def __init__(self, central_longitude=-96.0, central_latitude=39.0,
X offset from planar origin in metres. Defaults to 0.
false_northing: optional
Y offset from planar origin in metres. Defaults to 0.
secant_latitudes: optional
Secant latitudes. This keyword is deprecated in v0.12 and directly
replaced by ``standard parallels``. Defaults to None.
standard_parallels: optional
Standard parallel latitude(s). Defaults to (33, 45).
globe: optional
Expand All @@ -1740,19 +1737,6 @@ def __init__(self, central_longitude=-96.0, central_latitude=39.0,
('lat_0', central_latitude),
('x_0', false_easting),
('y_0', false_northing)]
if secant_latitudes and standard_parallels:
raise TypeError('standard_parallels replaces secant_latitudes.')
elif secant_latitudes is not None:
warnings.warn('secant_latitudes has been deprecated in v0.12. '
'The standard_parallels keyword can be used as a '
'direct replacement.',
DeprecationWarning,
stacklevel=2)
standard_parallels = secant_latitudes
elif standard_parallels is None:
# The default. Put this as a keyword arg default once
# secant_latitudes is removed completely.
standard_parallels = (33, 45)

n_parallels = len(standard_parallels)

Expand Down
47 changes: 8 additions & 39 deletions lib/cartopy/io/img_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ class Stamen(GoogleWTS):
Please see the attribution notice at http://maps.stamen.com on how to
attribute this imagery.

References
----------

* http://mike.teczno.com/notes/osm-us-terrain-layer/background.html
* http://maps.stamen.com/
* https://wiki.openstreetmap.org/wiki/List_of_OSM_based_Services
* https://github.com/migurski/DEM-Tools

"""
def __init__(self, style='toner',
desired_tile_form='RGB', cache=False):
Expand All @@ -358,45 +366,6 @@ def _image_url(self, tile):
return f'http://tile.stamen.com/{self.style}/{z}/{x}/{y}.png'


class StamenTerrain(Stamen):
"""
**DEPRECATED:** This class is deprecated. Please use
``Stamen('terrain-background')`` instead.

Terrain tiles defined for the continental United States, and include land
color and shaded hills. The land colors are a custom palette developed by
Gem Spear for the National Atlas 1km land cover data set, which defines
twenty-four land classifications including five kinds of forest,
combinations of shrubs, grasses and crops, and a few tundras and wetlands.
The colors are at their highest contrast when fully zoomed-out to the
whole U.S., and they slowly fade out to pale off-white as you zoom in to
leave room for foreground data and break up the weirdness of large areas
of flat, dark green.

References
----------

* http://mike.teczno.com/notes/osm-us-terrain-layer/background.html
* http://maps.stamen.com/
* https://wiki.openstreetmap.org/wiki/List_of_OSM_based_Services
* https://github.com/migurski/DEM-Tools


"""
def __init__(self, cache=False):
warnings.warn(
"The StamenTerrain class was deprecated in v0.17. "
"Please use Stamen('terrain-background') instead.",
DeprecationWarning,
stacklevel=2)

# NOTE: This subclass of Stamen exists for legacy reasons.
# No further Stamen subclasses will be accepted as
# they can easily be created in user code with Stamen(style_name).
return super().__init__(style='terrain-background',
cache=cache)


class MapboxTiles(GoogleWTS):
"""
Implement web tile retrieval from Mapbox.
Expand Down
6 changes: 3 additions & 3 deletions lib/cartopy/io/ogc_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
_URN_TO_CRS = collections.OrderedDict(
[('urn:ogc:def:crs:OGC:1.3:CRS84', ccrs.PlateCarree()),
('urn:ogc:def:crs:EPSG::4326', ccrs.PlateCarree()),
('urn:ogc:def:crs:EPSG::900913', ccrs.GOOGLE_MERCATOR),
('urn:ogc:def:crs:EPSG::900913', ccrs.Mercator.GOOGLE),
('urn:ogc:def:crs:EPSG::27700', ccrs.OSGB(approx=True)),
('urn:ogc:def:crs:EPSG::3031', ccrs.Stereographic(
central_latitude=-90,
Expand All @@ -80,8 +80,8 @@
central_longitude=-45,
central_latitude=90,
true_scale_latitude=70)),
('urn:ogc:def:crs:EPSG::3857', ccrs.GOOGLE_MERCATOR),
('urn:ogc:def:crs:EPSG:6.18.3:3857', ccrs.GOOGLE_MERCATOR)
('urn:ogc:def:crs:EPSG::3857', ccrs.Mercator.GOOGLE),
('urn:ogc:def:crs:EPSG:6.18.3:3857', ccrs.Mercator.GOOGLE)
])

# XML namespace definitions
Expand Down
76 changes: 0 additions & 76 deletions lib/cartopy/io/srtm.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,6 @@ def __init__(self, downloader=None, max_nx=3, max_ny=3):
max_nx=max_nx, max_ny=max_ny)


def srtm(lon, lat):
"""
Return (elevation, crs, extent) for the given longitude latitude.
Elevation is in meters.
"""
warnings.warn("This method has been deprecated. "
"See the \"What's new\" section for v0.12.",
DeprecationWarning,
stacklevel=2)
return SRTM3Source().single_tile(lon, lat)


def add_shading(elevation, azimuth, altitude):
"""Add shading to SRTM elevation data, using azimuth and altitude
of the sun.
Expand Down Expand Up @@ -259,55 +247,6 @@ def add_shading(elevation, azimuth, altitude):
return shaded


def fill_gaps(elevation, max_distance=10):
"""Fill gaps in SRTM elevation data for which the distance from
missing pixel to nearest existing one is smaller than `max_distance`.

This function requires osgeo/gdal to work.

Parameters
----------
elevation
SRTM elevation data (in meters)
max_distance
Maximal distance (in pixels) between a missing point
and the nearest valid one.

Returns
-------
elevation
SRTM elevation data with filled gaps.

"""
warnings.warn("The fill_gaps function has been deprecated. "
"See the \"What's new\" section for v0.14.",
DeprecationWarning,
stacklevel=2)
# Lazily import osgeo - it is only an optional dependency for cartopy.
from osgeo import gdal
from osgeo import gdal_array

src_ds = gdal_array.OpenArray(elevation)
srcband = src_ds.GetRasterBand(1)
dstband = srcband
maskband = srcband
smoothing_iterations = 0
options = []
gdal.FillNodata(dstband, maskband,
max_distance, smoothing_iterations, options,
callback=None)
elevation = dstband.ReadAsArray()
return elevation


def srtm_composite(lon_min, lat_min, nx, ny):
warnings.warn("This method has been deprecated. "
"See the \"What's new\" section for v0.12.",
DeprecationWarning,
stacklevel=2)
return SRTM3Source().combined(lon_min, lat_min, nx, ny)


def read_SRTM(fh):
"""
Read the array of (y, x) elevation data from the given named file-handle.
Expand Down Expand Up @@ -363,21 +302,6 @@ def read_SRTM(fh):
read_SRTM1 = read_SRTM


def SRTM3_retrieve(lon, lat):
"""
Return the path of a .hgt file for the given SRTM location.

If no such .hgt file exists (because it is over the ocean)
None will be returned.

"""
warnings.warn("This method has been deprecated. "
"See the \"What's new\" section for v0.12.",
DeprecationWarning,
stacklevel=2)
return SRTM3Source().srtm_fname(lon, lat)


class SRTMDownloader(Downloader):
"""
Provide a SRTM download mechanism.
Expand Down
20 changes: 0 additions & 20 deletions lib/cartopy/mpl/clip_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# This file is part of Cartopy and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.

import warnings

import matplotlib.path as mpath
import numpy as np

Expand Down Expand Up @@ -38,23 +35,6 @@ def intersection_point(p0, p1, p2, p3):
return x, y


# Provide a clip_path function which clips the given path to the given Bbox.
# There is inbuilt mpl functionality with v1.2.1 and beyond, but we provide
# a shim here for older mpl versions.
def clip_path(subject, clip_bbox):
"""
Clip the given path to the given bounding box.

"""
warnings.warn("This method has been deprecated. "
"You can replace ``clip_path(subject, clip_bbox)`` by "
"``subject.clip_to_bbox(clip_bbox)``. "
"See the \"What's new\" section for v0.17.",
DeprecationWarning,
stacklevel=2)
return subject.clip_to_bbox(clip_bbox)


def lines_intersect(p0, p1, p2, p3):
"""
Returns
Expand Down
Loading