Skip to content

Commit

Permalink
Merge branch 'SciTools:main' into skipped-license-test
Browse files Browse the repository at this point in the history
  • Loading branch information
lgolston authored Dec 6, 2023
2 parents 483eeca + 234a077 commit c921c41
Show file tree
Hide file tree
Showing 32 changed files with 202 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'
id: minimum-packages
run: |
pip install cython==0.29.24 matplotlib==3.5.3 numpy==1.21 owslib==0.24.1 pyproj==3.1 scipy==1.6.3 shapely==1.7.1
pip install cython==0.29.24 matplotlib==3.5.3 numpy==1.21 owslib==0.24.1 pyproj==3.1 scipy==1.6.3 shapely==1.7.1 pyshp==2.3.1
- name: Coverage packages
id: coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ jobs:
path: dist

- name: Publish Package
uses: pypa/[email protected].10
uses: pypa/[email protected].11
13 changes: 4 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ repos:
- id: no-commit-to-branch
# Trims trailing whitespace
- id: trailing-whitespace
- repo: https://github.com/pycqa/flake8
rev: "6.1.0"
hooks:
- id: flake8
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
Expand All @@ -40,9 +36,8 @@ repos:
hooks:
- id: sort-all
types: [file, python]
- repo: https://github.com/PyCQA/isort
rev: "5.12.0"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.5'
hooks:
- id: isort
types: [file, python]
args: [--filter-files]
- id: ruff
args: [--fix]
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Further information about the required dependencies can be found here:
**Shapely** 1.7.1 or later (https://github.com/shapely/shapely)
Python package for the manipulation and analysis of planar geometric objects.

**pyshp** 2.1 or later (https://pypi.python.org/pypi/pyshp)
**pyshp** 2.3 or later (https://pypi.python.org/pypi/pyshp)
Pure Python read/write support for ESRI Shapefile format.

**pyproj** 3.1.0 or later (https://github.com/pyproj4/pyproj/)
Expand Down
1 change: 0 additions & 1 deletion docs/doc-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sphinx
sphinx-gallery
beautifulsoup4
pydata-sphinx-theme
6 changes: 0 additions & 6 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@
sphinx_gallery_conf = {
'capture_repr': (),
'examples_dirs': ['../../examples'],
# NASA wmts servers are returning bad content metadata
"expected_failing_examples": [
'../../examples/web_services/reprojected_wmts.py',
'../../examples/web_services/wmts.py',
'../../examples/web_services/wmts_time.py',
],
'filename_pattern': '^((?!sgskip).)*$',
'gallery_dirs': ['gallery'],
'within_subsection_order': ExampleTitleSortKey,
Expand Down
1 change: 1 addition & 0 deletions docs/source/reference/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ automatically load the proper tile and resolution depending on the desired domai
MapboxTiles
OrdnanceSurvey
QuadtreeTiles
StadiaMapsTiles
Stamen

Open Geospatial Consortium (OGC)
Expand Down
5 changes: 2 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- cython>=0.29.24
- numpy>=1.21
- shapely>=1.7.1
- pyshp>=2.1
- pyshp>=2.3
- pyproj>=3.1.0
# The testing label has the proper version of freetype included
- conda-forge/label/testing::matplotlib-base>=3.4
Expand All @@ -27,12 +27,11 @@ dependencies:
- pytest-mpl
- pytest-xdist
# Documentation
- beautifulsoup4
- pydata-sphinx-theme
- sphinx
- sphinx-gallery
# Extras
- flake8
- pre-commit
- pykdtree
- ruff
- setuptools_scm
8 changes: 5 additions & 3 deletions examples/lines_and_polygons/feature_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def main():
# Put a background image on for nice sea rendering.
ax.stock_img()

# Create a feature for States/Admin 1 regions at 1:50m from Natural Earth
# Create a feature for States/Admin 1 regions at 1:50m from Natural Earth.
states_provinces = cfeature.NaturalEarthFeature(
category='cultural',
name='admin_1_states_provinces_lines',
Expand All @@ -38,9 +38,11 @@ def main():
SOURCE = 'Natural Earth'
LICENSE = 'public domain'

ax.add_feature(cfeature.LAND)
ax.add_feature(cfeature.COASTLINE)
# Add our states feature.
ax.add_feature(states_provinces, edgecolor='gray')
# Add land feature, overriding the default negative zorder so it shows
# above the background image.
ax.add_feature(cfeature.LAND, zorder=1, edgecolor='k')

# Add a text annotation for the license information to the
# the bottom right corner.
Expand Down
2 changes: 1 addition & 1 deletion examples/miscellanea/eccentric_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from io import BytesIO
from urllib.request import urlopen

from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image

import cartopy.crs as ccrs

Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ def __init__(self, central_longitude=-96.0, central_latitude=39.0,
lons[1:-1] = np.linspace(central_longitude - 180 + 0.001,
central_longitude + 180 - 0.001, n)

points = self.transform_points(PlateCarree(), lons, lats)
points = self.transform_points(PlateCarree(globe=globe), lons, lats)

self._boundary = sgeom.LinearRing(points)
mins = np.min(points, axis=0)
Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/feature/nightshade.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import numpy as np
import shapely.geometry as sgeom

from . import ShapelyFeature
from .. import crs as ccrs
from . import ShapelyFeature


class Nightshade(ShapelyFeature):
Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/io/img_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import collections
from pathlib import Path

from PIL import Image
import numpy as np
from PIL import Image
import shapely.geometry as sgeom


Expand Down
69 changes: 66 additions & 3 deletions lib/cartopy/io/img_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from pathlib import Path
import warnings

from PIL import Image
import numpy as np
from PIL import Image
import shapely.geometry as sgeom

import cartopy
Expand Down Expand Up @@ -320,6 +320,66 @@ def _image_url(self, tile):
return f'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'


class StadiaMapsTiles(GoogleWTS):
"""
Retrieves tiles from stadiamaps.com.
For a full reference on the styles available please see
https://docs.stadiamaps.com/themes/. A few of the specific styles
that are made available are ``alidade_smooth``, ``stamen_terrain`` and
``osm_bright``.
Using the Stadia Maps API requires including an attribution. Please see
https://docs.stadiamaps.com/attribution/ for details.
For most styles that means including the following attribution:
`© Stadia Maps <https://www.stadiamaps.com/>`_
`© OpenMapTiles <https://openmaptiles.org/>`_
`© OpenStreetMap contributors <https://www.openstreetmap.org/about/>`_
with Stamen styles *additionally* requiring the following attribution:
`© Stamen Design <https://stamen.com/>`_
Parameters
----------
apikey : str, required
The authentication key provided by Stadia Maps to query their APIs
style : str, optional
Name of the desired style. Defaults to ``alidade_smooth``.
See https://docs.stadiamaps.com/themes/ for a full list of styles.
resolution : str, optional
Resolution of the images to return. Defaults to an empty string,
standard resolution (256x256). You can also specify "@2x" for high
resolution (512x512) tiles.
cache : bool or str, optional
If True, the default cache directory is used. If False, no cache is
used. If a string, the string is used as the path to the cache.
"""

def __init__(self,
apikey,
style="alidade_smooth",
resolution="",
cache=False):
super().__init__(cache=cache, desired_tile_form="RGBA")
self.apikey = apikey
self.style = style
self.resolution = resolution
if style == "stamen_watercolor":
# Known style that has the jpg extension
self.extension = "jpg"
else:
self.extension = "png"

def _image_url(self, tile):
x, y, z = tile
return ("http://tiles.stadiamaps.com/tiles/"
f"{self.style}/{z}/{x}/{y}{self.resolution}.{self.extension}"
f"?api_key={self.apikey}")


class Stamen(GoogleWTS):
"""
Retrieves tiles from maps.stamen.com. Styles include
Expand Down Expand Up @@ -351,6 +411,9 @@ class Stamen(GoogleWTS):

def __init__(self, style='toner',
desired_tile_form=None, cache=False):
warnings.warn("The Stamen styles are no longer served by Stamen and "
"are now served by Stadia Maps. Please use the "
"StadiaMapsTiles class instead.")

# preset layer configuration
layer_config = {
Expand Down Expand Up @@ -688,12 +751,12 @@ def __init__(self, subscription_key, tileset_id="microsoft.imagery",
A valid Azure Maps subscription key.
tileset_id
A tileset ID for a map. See
https://docs.microsoft.com/en-us/rest/api/maps/renderv2/getmaptilepreview#tilesetid # noqa: E501
https://docs.microsoft.com/en-us/rest/api/maps/renderv2/getmaptilepreview#tilesetid
for details.
api_version
API version to use. Defaults to 2.0 as recommended by Microsoft.
"""
""" # noqa: E501
super().__init__(desired_tile_form=desired_tile_form, cache=cache)
self.subscription_key = subscription_key
self.tileset_id = tileset_id
Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/io/ogc_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import weakref
from xml.etree import ElementTree

from PIL import Image
import numpy as np
from PIL import Image
import shapely.geometry as sgeom


Expand Down
3 changes: 0 additions & 3 deletions lib/cartopy/mpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@


_MPL_VERSION = packaging.version.parse(matplotlib.__version__)
_MPL_35 = _MPL_VERSION.release[:2] >= (3, 5)
_MPL_36 = _MPL_VERSION.release[:2] >= (3, 6)
_MPL_38 = _MPL_VERSION.release[:2] >= (3, 8)

assert _MPL_35, 'Cartopy is only supported with Matplotlib 3.5 or greater.'
2 changes: 1 addition & 1 deletion lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ def gridlines(self, crs=None, draw_labels=False,
the Y axis.
"""
if crs is None:
crs = ccrs.PlateCarree()
crs = ccrs.PlateCarree(globe=self.projection.globe)
from cartopy.mpl.gridliner import Gridliner
gl = Gridliner(
self, crs=crs, draw_labels=draw_labels, xlocator=xlocs,
Expand Down
56 changes: 6 additions & 50 deletions lib/cartopy/mpl/gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@

import cartopy
from cartopy.crs import PlateCarree, Projection, _RectangularProjection
from cartopy.mpl.ticker import (LatitudeFormatter, LatitudeLocator, LongitudeFormatter,
LongitudeLocator)
from cartopy.mpl.ticker import (
LatitudeFormatter,
LatitudeLocator,
LongitudeFormatter,
LongitudeLocator,
)


degree_locator = mticker.MaxNLocator(nbins=9, steps=[1, 1.5, 1.8, 2, 3, 6, 10])
Expand Down Expand Up @@ -443,54 +447,6 @@ def __init__(self, axes, crs, draw_labels=False, xlocator=None,
self._drawn = False
self._auto_update = auto_update

@property
def xlabels_top(self):
warnings.warn('The .xlabels_top attribute is deprecated. Please '
'use .top_labels to toggle visibility instead.')
return self.top_labels

@xlabels_top.setter
def xlabels_top(self, value):
warnings.warn('The .xlabels_top attribute is deprecated. Please '
'use .top_labels to toggle visibility instead.')
self.top_labels = value

@property
def xlabels_bottom(self):
warnings.warn('The .xlabels_bottom attribute is deprecated. Please '
'use .bottom_labels to toggle visibility instead.')
return self.bottom_labels

@xlabels_bottom.setter
def xlabels_bottom(self, value):
warnings.warn('The .xlabels_bottom attribute is deprecated. Please '
'use .bottom_labels to toggle visibility instead.')
self.bottom_labels = value

@property
def ylabels_left(self):
warnings.warn('The .ylabels_left attribute is deprecated. Please '
'use .left_labels to toggle visibility instead.')
return self.left_labels

@ylabels_left.setter
def ylabels_left(self, value):
warnings.warn('The .ylabels_left attribute is deprecated. Please '
'use .left_labels to toggle visibility instead.')
self.left_labels = value

@property
def ylabels_right(self):
warnings.warn('The .ylabels_right attribute is deprecated. Please '
'use .right_labels to toggle visibility instead.')
return self.right_labels

@ylabels_right.setter
def ylabels_right(self, value):
warnings.warn('The .ylabels_right attribute is deprecated. Please '
'use .right_labels to toggle visibility instead.')
self.right_labels = value

def has_labels(self):
return len(self._labels) != 0

Expand Down
Loading

0 comments on commit c921c41

Please sign in to comment.