matplotlib-map-utils 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- matplotlib_map_utils/__init__.py +4 -0
- matplotlib_map_utils/defaults.py +416 -0
- matplotlib_map_utils/north_arrow.py +458 -0
- matplotlib_map_utils/scratch/map_utils.py +412 -0
- matplotlib_map_utils/scratch/north_arrow_old_classes.py +1185 -0
- matplotlib_map_utils/validation.py +332 -0
- matplotlib_map_utils-1.0.0.dist-info/LICENSE +674 -0
- matplotlib_map_utils-1.0.0.dist-info/METADATA +131 -0
- matplotlib_map_utils-1.0.0.dist-info/RECORD +11 -0
- matplotlib_map_utils-1.0.0.dist-info/WHEEL +5 -0
- matplotlib_map_utils-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,131 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: matplotlib-map-utils
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: A suite of tools for creating maps in matplotlib
|
5
|
+
Author-email: David Moss <davidmoss1221@gmail.com>
|
6
|
+
Project-URL: Homepage, https://github.com/moss-xyz/matplotlib-map-utils/
|
7
|
+
Project-URL: Bug Tracker, https://github.com/moss-xyz/matplotlib-map-utils/issues
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Requires-Python: >=3.9
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
License-File: LICENSE
|
14
|
+
Requires-Dist: matplotlib >=3.9.0
|
15
|
+
Requires-Dist: cartopy >=0.23.0
|
16
|
+
|
17
|
+
# matplotlib-map-utils
|
18
|
+
|
19
|
+
---
|
20
|
+
|
21
|
+
**Documentation**: See `docs` folder
|
22
|
+
|
23
|
+
**Source Code**: Find the project on GitHub
|
24
|
+
|
25
|
+
---
|
26
|
+
|
27
|
+
### Introduction
|
28
|
+
|
29
|
+
`matplotlib_map_utils` is intended to be a package that provides various functions and objects that assist with the the creation of maps using [`matplotlib`](https://matplotlib.org/stable/).
|
30
|
+
|
31
|
+
As of `v1.x` (the current version), this only includes a single additional tool: `north_arrow.py`, which applies a high quality, context-aware north arrow to a given plot. Future releases (if the project is continued) might provide similar tools for creating scale bars or inset maps, or functions that I have created myself that give more control in the formatting of maps.
|
32
|
+
|
33
|
+
---
|
34
|
+
|
35
|
+
### Installation
|
36
|
+
|
37
|
+
This package is available on PyPi, and can be installed like so:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
pip install matplotlib-map-utils
|
41
|
+
```
|
42
|
+
|
43
|
+
The requirements for this package are:
|
44
|
+
|
45
|
+
* python >= 3.9.0 (due to the dictionary-concatenation method utilized)
|
46
|
+
|
47
|
+
* matplotlib >= 3.9.0 (might work with lower versions but not guaranteed)
|
48
|
+
|
49
|
+
* cartopy >= 0.23.0 (due to earlier bug with calling `copy()` on `CRS` objects)
|
50
|
+
|
51
|
+
---
|
52
|
+
|
53
|
+
### North Arrow
|
54
|
+
|
55
|
+
#### Quick Start
|
56
|
+
|
57
|
+
The quickest way to add a single north arrow to a single plot is to use the `north_arrow` function:
|
58
|
+
|
59
|
+
```python
|
60
|
+
# Setting up a plot
|
61
|
+
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(10,10), dpi=300)
|
62
|
+
# Adding a north arrow to the upper-right corner of the axis, without any rotation (see Rotation under Formatting Components for details)
|
63
|
+
north_arrow.north_arrow(ax=ax, location="upper right", rotation={"degrees":0})
|
64
|
+
```
|
65
|
+
|
66
|
+
An object-oriented approach is also supported:
|
67
|
+
|
68
|
+
```python
|
69
|
+
# Setting up a plot
|
70
|
+
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(10,10), dpi=300)
|
71
|
+
# Creating a north arrow for the upper-right corner of the axis, without any rotation (see Rotation under Formatting Components for details)
|
72
|
+
na = north_arrow.NorthArrow(ax=ax, location="upper right", rotation={"degrees":0})
|
73
|
+
# Adding the artist to the plot
|
74
|
+
ax.add_artist(na)
|
75
|
+
```
|
76
|
+
|
77
|
+
#### Customization
|
78
|
+
|
79
|
+
Both the object-oriented and functional approaches can be customized to allow for fine-grained control over formatting:
|
80
|
+
|
81
|
+
```python
|
82
|
+
north_arrow(
|
83
|
+
ax,
|
84
|
+
location = "upper right", # accepts a valid string from the list of locations
|
85
|
+
scale = 0.5, # accepts a valid positive float or integer
|
86
|
+
# each of the follow accepts arguments from a customized style dictionary
|
87
|
+
base = {"facecolor":"green"},
|
88
|
+
fancy = False,
|
89
|
+
label = {"text":"North"},
|
90
|
+
shadow = {"alpha":0.8},
|
91
|
+
pack = {"sep":6},
|
92
|
+
aob = {"pad":2},
|
93
|
+
rotation = {"degrees": 35}
|
94
|
+
)
|
95
|
+
```
|
96
|
+
|
97
|
+
Refer to `docs\howto_north_arrow` for details on how to customize each facet of the north arrow.
|
98
|
+
|
99
|
+
---
|
100
|
+
|
101
|
+
### Development Notes
|
102
|
+
|
103
|
+
#### Inspiration and Thanks
|
104
|
+
|
105
|
+
This project was heavily inspired by [`matplotlib-scalebar`](https://github.com/ppinard/matplotlib-scalebar/), and much of the code is either directly copied or a derivative of that project, since it uses the same "artist"-based approach.
|
106
|
+
|
107
|
+
Two more projects assisted with the creation of this script:
|
108
|
+
|
109
|
+
* [`EOmaps`](https://github.com/raphaelquast/EOmaps/discussions/231) provided code for calculating the rotation required to point to "true north" for an arbitrary point and CRS for the north arrow.
|
110
|
+
|
111
|
+
* [`Cartopy`](https://github.com/SciTools/cartopy/issues/2361) fixed an issue inherent to calling `.copy()` on `CRS` objects.
|
112
|
+
|
113
|
+
#### Future Roadmap
|
114
|
+
|
115
|
+
As stated in the intro, I am hoping this project will encompass more than just the north arrow object it currently does. In particular, I want `v2` to tackle making properly-formatted "map-style" scale bar objects, a la ArcGIS and QGIS.
|
116
|
+
|
117
|
+
If that goes well, `v3` can either create a tool for generating inset maps (which `matplotlib` has *some* support for), or the various functions that I have created in the past that assist with formatting a map "properly", such as centering on a given object.
|
118
|
+
|
119
|
+
I am also open to ideas for other extensions to create!
|
120
|
+
|
121
|
+
#### Support and Contributions
|
122
|
+
|
123
|
+
If you notice something is not working as intended or if you'd like to add a feature yourself, I welcome PRs - just be sure to be descriptive as to what you are changing and why, including code examples!
|
124
|
+
|
125
|
+
If you are having issues using this script, feel free to leave a post explaining your issue, and I will try and assist, though I have no guaranteed SLAs as this is just a hobby project.
|
126
|
+
|
127
|
+
---
|
128
|
+
|
129
|
+
### License
|
130
|
+
|
131
|
+
I know nothing about licensing, so I went with the GPL license. If that is incompatible with any of the dependencies, please let me know.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
matplotlib_map_utils/__init__.py,sha256=5Ld1USbPBkUPbWw0TxS1-CElJH_WliBFhp5tW_wz66M,187
|
2
|
+
matplotlib_map_utils/defaults.py,sha256=fWtFiYnzaTAemnsTUuOHTm7oc-sC-gFdBlqciEdHI9U,8543
|
3
|
+
matplotlib_map_utils/north_arrow.py,sha256=9Ll4CMVQzNesZ0vVkNspTj34mIaW7XsKwPXPSy063j0,23042
|
4
|
+
matplotlib_map_utils/validation.py,sha256=U2D38FZS2hPGTJluaiN3uBUYoSuZ-UqVzYfOV1y2lsM,18565
|
5
|
+
matplotlib_map_utils/scratch/map_utils.py,sha256=j8dOX9uuotl9rRCAXapFLHycUwVE4nzIrqWYOGG2Lgg,19653
|
6
|
+
matplotlib_map_utils/scratch/north_arrow_old_classes.py,sha256=1xKQ6yUghX4BWzIv8GsGBHDDPJ8B0Na7ixdw2jgtTqw,50993
|
7
|
+
matplotlib_map_utils-1.0.0.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
8
|
+
matplotlib_map_utils-1.0.0.dist-info/METADATA,sha256=7eTyBRJnClUGM7BhYmQ7Akz6Y-3E3jJ_P2CNu3bs9cw,5297
|
9
|
+
matplotlib_map_utils-1.0.0.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
|
10
|
+
matplotlib_map_utils-1.0.0.dist-info/top_level.txt,sha256=6UyDpxsnMhSOd9a-abQe0lLJveybJyYtUHMdX7zXgKA,21
|
11
|
+
matplotlib_map_utils-1.0.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
matplotlib_map_utils
|