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

Scalebar #1728

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f591656
first commit of the branch solely_scalebar. In this first comit, the …
PhilipeRLeal Dec 22, 2020
2f9bd86
scalebar_usage_examples.py has been updated in accordance to pep8 sta…
PhilipeRLeal Dec 22, 2020
abdb826
small changes in the comments from the scalebar_example
PhilipeRLeal Dec 22, 2020
c6e5343
This is a merge of the prior developers git branch and the new functi…
adrien-berchet Jul 16, 2020
88fadae
changes in the cartopy.mpl.gridliner class. It has methods for easily…
PhilipeRLeal Dec 16, 2020
37b9e11
There were changes in the LOGITUDE_FORMATTER and the LATITUDE_FORMATT…
PhilipeRLeal Dec 16, 2020
bd4779d
scalebar has been added, as well as its test suit
PhilipeRLeal Dec 16, 2020
d24b2d6
contributor list has been updated
PhilipeRLeal Dec 16, 2020
256fa6c
requirements documentation has been updated
PhilipeRLeal Dec 16, 2020
db2719d
an example of the scalebar functionality has been added
PhilipeRLeal Dec 16, 2020
2aad573
importation of the formatter module has been fixed
PhilipeRLeal Dec 16, 2020
720276a
formatters.py, gridliner.py, scalebar.py and scalebar_example.py have…
PhilipeRLeal Dec 16, 2020
6827366
changes to the scalebar_example.py
PhilipeRLeal Dec 16, 2020
01a0d78
the geopy requirement is no longer needed. Scalebar module is running ok
PhilipeRLeal Dec 16, 2020
c2f0cf6
scalebar example has been updated
PhilipeRLeal Dec 16, 2020
bbd68ea
the package can now create a scalebar for practically any cartopy's p…
PhilipeRLeal Dec 16, 2020
3f3b231
test suit for scalebar has been updated
PhilipeRLeal Dec 16, 2020
21b7d36
test suit has been updated
PhilipeRLeal Dec 16, 2020
6510719
scalebar can now be called directly from the geoaxes. Also, the test …
PhilipeRLeal Dec 17, 2020
170c2ca
The lib has been updated in accordance to PEP8 format. Besides, the s…
PhilipeRLeal Dec 17, 2020
e24e906
test_scalebar has been updated
PhilipeRLeal Dec 21, 2020
ee9a20b
formatters, scalebar and test_scalebar modules have had their copyrig…
PhilipeRLeal Dec 21, 2020
c34048a
There were changes in the formatter.py, gridliner.py, and the respect…
PhilipeRLeal Dec 22, 2020
c459a8b
first commit of the gridline ticklabel branch
PhilipeRLeal Dec 22, 2020
944f121
griliner test has been updated
PhilipeRLeal Dec 22, 2020
10dea03
there were updates in the LicenseHeaders of the tests and the example…
PhilipeRLeal Dec 22, 2020
8d18292
test_gridliner.py has been updated. Now, error messages are returned …
PhilipeRLeal Dec 27, 2020
55409e8
small changes in variables given long name problems from PEP8
PhilipeRLeal Dec 27, 2020
2129820
both branches have been properly merged. COnflict merging has been so…
PhilipeRLeal Jan 21, 2021
a15a7fc
The scalebar is now inserted to the geoaxes through the matplotlib's …
PhilipeRLeal Feb 2, 2021
403bee9
the scalebar test module has been updated
PhilipeRLeal Feb 2, 2021
3413f4e
stickler problems were solved
PhilipeRLeal Feb 2, 2021
609bde8
Merge branch 'scalebar' into master
PhilipeRLeal Feb 2, 2021
fd4d158
test_scalebar.py has been updated. The test was not passing beforehand
PhilipeRLeal Feb 3, 2021
aba434d
stickler hsa been solved
PhilipeRLeal Feb 3, 2021
80a0791
Update test_scalebar.py
PhilipeRLeal Feb 3, 2021
4d81ab3
Update test_scalebar.py
PhilipeRLeal Feb 3, 2021
2eef209
Merge branch 'master' of https://github.com/PhilipeRLeal/cartopy into…
PhilipeRLeal Feb 3, 2021
d9ea1ca
Merge branch 'solely_scalebar' of https://github.com/PhilipeRLeal/car…
PhilipeRLeal Feb 3, 2021
4ff5f8e
Merge branch 'master' into scalebar
PhilipeRLeal Feb 3, 2021
848aec4
scalebar is running OK. It can be plotted against several projections
PhilipeRLeal Feb 5, 2021
a2c3124
small updates in the ruler unit font formatter
PhilipeRLeal Feb 5, 2021
9d0c19e
PEP8 standardized
PhilipeRLeal Feb 5, 2021
2d2a8bd
Update test_scalebar.py
PhilipeRLeal Feb 6, 2021
a43ad7d
Create test_scalebar.py
PhilipeRLeal Feb 6, 2021
647982f
Update test_scalebar.py
PhilipeRLeal Feb 6, 2021
44b15a0
Update test_scalebar.py
PhilipeRLeal Feb 6, 2021
6dbb58b
Update scalebar.py
PhilipeRLeal May 7, 2021
2347fe3
Merge branch 'master' into scalebar
PhilipeRLeal Jul 8, 2021
4e98ac5
lint errors solved
PhilipeRLeal Aug 7, 2021
c3f04b0
Merge branch 'master' into scalebar
PhilipeRLeal Aug 7, 2021
a725517
Merge branch 'master' into scalebar
PhilipeRLeal Aug 10, 2021
35deefa
Merge branch 'master' into scalebar
PhilipeRLeal Sep 15, 2021
dd11be7
Update scalebar.py
PhilipeRLeal Sep 15, 2021
6f6ecb8
Update scalebar.py
PhilipeRLeal Sep 15, 2021
452c07e
Update scalebar.py
PhilipeRLeal Sep 15, 2021
e76ad0c
Update scalebar.py
PhilipeRLeal Sep 15, 2021
77633c5
Update test_gridliner.py
PhilipeRLeal Sep 15, 2021
e23e5c9
Update test_gridliner.py
PhilipeRLeal Sep 15, 2021
ada512d
Update scalebar.py
PhilipeRLeal Sep 15, 2021
2db0b83
Update scalebar.py
PhilipeRLeal Sep 15, 2021
3089d7b
Update test_gridliner.py
PhilipeRLeal Sep 15, 2021
017e709
Update gridliner.py
PhilipeRLeal Sep 15, 2021
2efb350
Delete gridliner.py
PhilipeRLeal Sep 15, 2021
a5f26f6
Create gridliner.py
PhilipeRLeal Sep 15, 2021
c421933
Delete formatters.py
PhilipeRLeal Sep 15, 2021
1a4d10a
Update gridliner.py
PhilipeRLeal Sep 15, 2021
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: 3 additions & 3 deletions docs/make_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def plate_carree_plot():
for i in range(0, nplots):
central_longitude = 0 if i == 0 else 180
ax = fig.add_subplot(
nplots, 1, i+1,
nplots, 1, i + 1,
projection=ccrs.PlateCarree(central_longitude=central_longitude))
ax.coastlines(resolution='110m')
ax.gridlines()
Expand Down Expand Up @@ -69,8 +69,8 @@ def utm_plot():
fig = plt.figure(figsize=(10, 3))

for i in range(0, nplots):
ax = fig.add_subplot(1, nplots, i+1,
projection=ccrs.UTM(zone=i+1,
ax = fig.add_subplot(1, nplots, i + 1,
projection=ccrs.UTM(zone=i + 1,
southern_hemisphere=True))
ax.coastlines(resolution='110m')
ax.gridlines()
Expand Down
47 changes: 23 additions & 24 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from datetime import datetime
import os
import sys

import cartopy
from distutils.version import LooseVersion
import matplotlib
Expand All @@ -31,7 +30,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

# -- General configuration -----------------------------------------------------
# -- General configuration -----------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '1.6'
Expand Down Expand Up @@ -130,7 +129,8 @@
# directories to ignore when looking for source files.
exclude_patterns = []

# The reST default role (used for this markup: `text`) to use for all documents.
# The reST default role (used for this markup: `text`) to use for all
# documents.
default_role = 'py:obj'

# Handle subclasses of Matplotlib using an :rc: context in documentation
Expand All @@ -156,7 +156,7 @@
# modindex_common_prefix = []


# -- Options for HTML output ---------------------------------------------------
# -- Options for HTML output ---------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
Expand Down Expand Up @@ -239,26 +239,26 @@
htmlhelp_basename = 'cartopydoc'


# -- Options for LaTeX output --------------------------------------------------
# -- Options for LaTeX output --------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'cartopy.tex', 'Cartopy Introduction',
'Philip Elson, Richard Hattersley', 'manual', False),
('introductory_examples/index', 'cartopy_examples.tex', 'Cartopy examples',
'Philip Elson, Richard Hattersley', 'manual', True)
('index', 'cartopy.tex', 'Cartopy Introduction',
'Philip Elson, Richard Hattersley', 'manual', False),
('introductory_examples/index', 'cartopy_examples.tex', 'Cartopy examples',
'Philip Elson, Richard Hattersley', 'manual', True)
]

# The name of an image file (relative to this directory) to place at the top of
Expand All @@ -282,7 +282,7 @@
# latex_domain_indices = True


# -- Options for manual page output --------------------------------------------
# -- Options for manual page output --------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
Expand All @@ -295,16 +295,16 @@
# man_show_urls = False


# -- Options for Texinfo output ------------------------------------------------
# -- Options for Texinfo output ------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'cartopy', 'cartopy Documentation',
'Philip Elson, Richard Hattersley', 'cartopy',
'One line description of project.',
'Miscellaneous'),
('index', 'cartopy', 'cartopy Documentation',
'Philip Elson, Richard Hattersley', 'cartopy',
'One line description of project.',
'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
Expand All @@ -317,7 +317,7 @@
# texinfo_show_urls = 'footnote'


# -- Options for Epub output ---------------------------------------------------
# -- Options for Epub output ---------------------------------------------

# Bibliographic Dublin Core info.
epub_title = 'cartopy'
Expand Down Expand Up @@ -371,13 +371,12 @@

############ extlinks extension ############
extlinks = {'issues': ('https://github.com/SciTools/cartopy/labels/%s',
'issues labeled with '),
'issues labeled with '),
'issue': ('https://github.com/SciTools/cartopy/issues/%s',
'Issue #'),
'pull': ('https://github.com/SciTools/cartopy/pull/%s', 'PR #'),
}


############ plot directive ##############

plot_html_show_formats = False
Expand Down
1 change: 1 addition & 0 deletions docs/source/contributors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ the package wouldn't be as rich or diverse as it is today:
* Greg Lucas
* Sadie Bartholomew
* Kacper Makuch
* Philipe Riskalla Leal
* Stephane Raynaud
* John Krasting

Expand Down
4 changes: 0 additions & 4 deletions examples/gridlines_and_labels/gridliner.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
"""
Gridlines and tick labels
-------------------------

These examples demonstrate how to quickly add longitude
and latitude gridlines and tick labels on a non-rectangular projection.

As you can see on the first example,
longitude labels may be drawn on left and right sides,
and latitude labels may be drawn on bottom and top sides.
Thanks to the ``dms`` keyword, minutes are used when appropriate
to display fractions of degree.

In the second example, labels are still drawn at the map edges
despite its complexity, and some others are also drawn within the map
boundary.

In the third example, labels are drawn only on the left and bottom sides.
"""
import cartopy.crs as ccrs
Expand Down
2 changes: 1 addition & 1 deletion examples/lines_and_polygons/always_circular_stereo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def main():
# Compute a circle in axes coordinates, which we can use as a boundary
# for the map. We can pan/zoom as much as we like - the boundary will be
# permanently circular.
theta = np.linspace(0, 2*np.pi, 100)
theta = np.linspace(0, 2 * np.pi, 100)
center, radius = [0.5, 0.5], 0.5
verts = np.vstack([np.sin(theta), np.cos(theta)]).T
circle = mpath.Path(verts * radius + center)
Expand Down
18 changes: 9 additions & 9 deletions examples/miscellanea/un_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def olive_path():

"""
olives_verts = np.array(
[[0, 2, 6, 9, 30, 55, 79, 94, 104, 117, 134, 157, 177,
188, 199, 207, 191, 167, 149, 129, 109, 87, 53, 22, 0, 663,
[[0, 2, 6, 9, 30, 55, 79, 94, 104, 117, 134, 157, 177,
188, 199, 207, 191, 167, 149, 129, 109, 87, 53, 22, 0, 663,
245, 223, 187, 158, 154, 150, 146, 149, 154, 158, 181, 184, 197,
181, 167, 153, 142, 129, 116, 119, 123, 127, 151, 178, 203, 220,
237, 245, 663, 280, 267, 232, 209, 205, 201, 196, 196, 201, 207,
Expand All @@ -47,14 +47,14 @@ def olive_path():
249, 242, 231, 214, 208, 208, 227, 244, 252, 258, 262, 262, 261,
262, 264, 265, 252, 663, 185, 197, 206, 215, 223, 233, 242, 237,
237, 230, 220, 202, 185, 663],
[8, 5, 3, 0, 22, 46, 46, 46, 35, 27, 16, 10, 18,
22, 28, 38, 27, 26, 33, 41, 52, 52, 52, 30, 8, 595,
77, 52, 61, 54, 53, 52, 53, 55, 55, 57, 65, 90, 106,
96, 81, 68, 58, 54, 51, 50, 51, 50, 44, 34, 43, 48,
61, 77, 595, 135, 104, 102, 83, 79, 76, 74, 74, 79, 84,
90, 109, 135, 156, 145, 133, 121, 100, 77, 62, 69, 67, 80,
[8, 5, 3, 0, 22, 46, 46, 46, 35, 27, 16, 10, 18,
22, 28, 38, 27, 26, 33, 41, 52, 52, 52, 30, 8, 595,
77, 52, 61, 54, 53, 52, 53, 55, 55, 57, 65, 90, 106,
96, 81, 68, 58, 54, 51, 50, 51, 50, 44, 34, 43, 48,
61, 77, 595, 135, 104, 102, 83, 79, 76, 74, 74, 79, 84,
90, 109, 135, 156, 145, 133, 121, 100, 77, 62, 69, 67, 80,
92, 113, 135, 595, 198, 171, 156, 134, 129, 124, 120, 123, 126,
129, 138, 149, 161, 175, 188, 202, 177, 144, 116, 110, 105, 99,
129, 138, 149, 161, 175, 188, 202, 177, 144, 116, 110, 105, 99,
108, 116, 126, 136, 147, 162, 173, 186, 198, 595, 249, 255, 261,
267, 241, 222, 200, 192, 183, 175, 175, 175, 175, 199, 221, 240,
245, 250, 256, 245, 233, 222, 207, 194, 180, 172, 162, 153, 154,
Expand Down
61 changes: 61 additions & 0 deletions examples/scalebar/scalebar_usage_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright Cartopy Contributors
#
# 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 matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.mpl.scalebar import fancy_scalebar


def scalebar_invoqued_as_an_independent_object_geoaxes():

fig, axes = plt.subplots(1, 2,
subplot_kw={'projection':
ccrs.Mercator()})

projections = [ccrs.Mercator(), ccrs.PlateCarree()]

axes = axes.ravel()

for proj, ax in zip(projections, axes):
ax.projection = proj
fancy_scalebar(ax,
location=(0.5, 0.2),
length=1000_000,
unit_name='km',
angle=0,
max_stripes=5,
fontsize=8,
dy=0.05)

ax.gridlines(draw_labels=True)
ax.stock_img()
ax.coastlines()


def scalebar_from_within_geoaxes():

fig, axes = plt.subplots(1, 2,
subplot_kw={'projection':
ccrs.Mercator()})

projections = [ccrs.Mercator(),
ccrs.PlateCarree()]

axes = axes.ravel()

for proj, ax in zip(projections, axes):
ax.projection = proj

ax.set_extent([-60, -35, -40, 10])
ax.gridlines(draw_labels=True)
ax.add_scalebar(location=(0.5, 0.5),
length=250_000,
dy=5,
max_stripes=3)
ax.stock_img()
ax.coastlines()

fig.show()
10 changes: 8 additions & 2 deletions lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ class RotatedGeodetic(CRS):
central_rotated_longitude value.

"""

def __init__(self, pole_longitude, pole_latitude,
central_rotated_longitude=0.0, globe=None):
"""
Expand Down Expand Up @@ -1289,6 +1290,7 @@ class _RectangularProjection(Projection, metaclass=ABCMeta):
is symmetric about the origin.

"""

def __init__(self, proj4_params, half_width, half_height, globe=None):
self._half_width = half_width
self._half_height = half_height
Expand Down Expand Up @@ -1427,6 +1429,7 @@ class TransverseMercator(Projection):
A Transverse Mercator projection.

"""

def __init__(self, central_longitude=0.0, central_latitude=0.0,
false_easting=0.0, false_northing=0.0,
scale_factor=1.0, globe=None, approx=None):
Expand Down Expand Up @@ -1556,6 +1559,7 @@ class UTM(Projection):
Universal Transverse Mercator projection.

"""

def __init__(self, zone, southern_hemisphere=False, globe=None):
"""
Parameters
Expand Down Expand Up @@ -1590,13 +1594,13 @@ def boundary(self):
def x_limits(self):
easting = 5e5
# allow 50% overflow
return (0 - easting/2, 2 * easting + easting/2)
return (0 - easting / 2, 2 * easting + easting / 2)

@property
def y_limits(self):
northing = 1e7
# allow 50% overflow
return (0 - northing, 2 * northing + northing/2)
return (0 - northing, 2 * northing + northing / 2)


class EuroPP(UTM):
Expand All @@ -1606,6 +1610,7 @@ class EuroPP(UTM):
Ellipsoid is International 1924, Datum is ED50.

"""

def __init__(self):
globe = Globe(ellipse='intl')
super().__init__(32, globe=globe)
Expand Down Expand Up @@ -2674,6 +2679,7 @@ class Geostationary(_Satellite):
the satellite.

"""

def __init__(self, central_longitude=0.0, satellite_height=35785831,
false_easting=0, false_northing=0, globe=None,
sweep_axis='y'):
Expand Down
6 changes: 6 additions & 0 deletions lib/cartopy/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class Scaler:
"""
General object for handling the scale of the geometries used in a Feature.
"""

def __init__(self, scale):
self._scale = scale

Expand Down Expand Up @@ -140,6 +141,7 @@ class AdaptiveScaler(Scaler):
"""
Automatically select scale of geometries based on extent of plotted axes.
"""

def __init__(self, default_scale, limits):
"""
Parameters
Expand Down Expand Up @@ -198,6 +200,7 @@ class ShapelyFeature(Feature):
shapely geometries.

"""

def __init__(self, geometries, crs, **kwargs):
"""
Parameters
Expand Down Expand Up @@ -227,6 +230,7 @@ class NaturalEarthFeature(Feature):
See https://www.naturalearthdata.com/

"""

def __init__(self, category, name, scale, **kwargs):
"""
Parameters
Expand Down Expand Up @@ -345,6 +349,7 @@ class GSHHSFeature(Feature):
instantiating multiple GSHHS artists, by reducing repeated file IO.

"""

def __init__(self, scale='auto', levels=None, **kwargs):
super().__init__(cartopy.crs.PlateCarree(), **kwargs)

Expand Down Expand Up @@ -424,6 +429,7 @@ class WFSFeature(Feature):
This feature requires additional dependencies. If installed via pip,
try ``pip install cartopy[ows]``.
"""

def __init__(self, wfs, features, **kwargs):
"""
Parameters
Expand Down
Loading