matplotlib-map-utils 2.1.0__py3-none-any.whl → 3.0.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matplotlib-map-utils
3
- Version: 2.1.0
3
+ Version: 3.0.1
4
4
  Summary: A suite of tools for creating maps in matplotlib
5
5
  Author-email: David Moss <davidmoss1221@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/moss-xyz/matplotlib-map-utils/
@@ -8,6 +8,7 @@ Project-URL: Bug Tracker, https://github.com/moss-xyz/matplotlib-map-utils/issue
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: GNU General Public License (GPL)
10
10
  Classifier: Operating System :: OS Independent
11
+ Classifier: Framework :: Matplotlib
11
12
  Requires-Python: >=3.10
12
13
  Description-Content-Type: text/markdown
13
14
  License-File: LICENSE
@@ -16,13 +17,15 @@ Requires-Dist: cartopy>=0.23.0
16
17
  Requires-Dist: great-circle-calculator>=1.3.1
17
18
  Dynamic: license-file
18
19
 
19
- # matplotlib-map-utils
20
+ ![matplotlib_map_utils logo](matplotlib_map_utils/docs/assets/mmu_logo_w_elements.png)
20
21
 
21
22
  ---
22
23
 
23
- **Documentation**: See `docs` folder
24
+ **Documentation:** See `docs` folder
24
25
 
25
- **Source Code**: [Available on GitHub](https://github.com/moss-xyz/matplotlib-map-utils)
26
+ **Source Code:** [Available on GitHub](https://github.com/moss-xyz/matplotlib-map-utils)
27
+
28
+ **Feedback:** I welcome any and all feedback! See the *Development Notes* below for more details.
26
29
 
27
30
  ---
28
31
 
@@ -30,15 +33,23 @@ Dynamic: license-file
30
33
 
31
34
  `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/).
32
35
 
33
- As of `v2.x` (the current version), this includes two tools and one utility:
36
+ As of `v3.x` (the current version), this includes three-ish elements:
37
+
38
+ * `north_arrow.py`, for adding a north arrow to a given plot.
39
+
40
+ * `scale_bar.py`, for adding a scale bar to a given plot.
41
+
42
+ * `inset_map.py`, for adding inset maps and detail/extent indicators to a given plot.
34
43
 
35
- * `north_arrow.py`, which generates a high quality, context-aware north arrow for a given plot.
44
+ The three elements listed above are all intended to be high-resolution, easily modifiable, and context-aware, relative to your specific plot.
36
45
 
37
- * `scale_bar.py`, which generates a high quality, context-aware scale bar to a given plot.
46
+ This package also contains a single utility object:
38
47
 
39
48
  * `usa.py`, which contains a class that helps filter for states and territories within the USA based on given characteristics.
40
49
 
41
- Future releases (if the project is continued) might provide a similar tool inset maps, or other functions that I have created myself that give more control in the formatting of maps.
50
+ Together, these allow for the easy creation of a map such as the following:
51
+
52
+ ![Map with all common elements added](matplotlib_map_utils/docs/assets/readme_bigmap.png)
42
53
 
43
54
  ---
44
55
 
@@ -62,7 +73,8 @@ The requirements for this package are:
62
73
 
63
74
  ### Package Structure
64
75
 
65
- The package is arrayed in the following way:
76
+ <details>
77
+ <summary><i>The package is arrayed in the following way:</i></summary>
66
78
 
67
79
  ```bash
68
80
  package_name/
@@ -70,17 +82,20 @@ package_name/
70
82
 
71
83
  ├── core/
72
84
  │ ├── __init__.py
85
+ │ ├── inset_map.py
73
86
  │ ├── north_arrow.py
74
87
  │ ├── scale_bar.py
75
88
  ├── validation/
76
89
  │ ├── __init__.py
77
90
  │ ├── functions.py
91
+ │ └── inset_map.py
78
92
  │ ├── north_arrow.py
79
93
  │ └── scale_bar.py
80
94
  ├── defaults/
81
95
  │ ├── __init__.py
82
96
  │ ├── north_arrow.py
83
97
  │ └── scale_bar.py
98
+ │ └── inset_map.py
84
99
  ├── utils/
85
100
  │ ├── __init__.py
86
101
  │ ├── usa.py
@@ -95,9 +110,13 @@ Where:
95
110
 
96
111
  * `defaults` contains default settings for each object at different paper sizes
97
112
 
113
+ * `utils` contains utility functions and objects
114
+
115
+ </details>
116
+
98
117
  ---
99
118
 
100
- ### North Arrow
119
+ ### 🧭 North Arrow
101
120
 
102
121
  <details>
103
122
  <summary><i>Expand instructions</i></summary>
@@ -108,6 +127,8 @@ Importing the North Arrow functions and classes can be done like so:
108
127
 
109
128
  ```py
110
129
  from matplotlib_map_utils.core.north_arrow import NorthArrow, north_arrow
130
+ from matplotlib_map_utils.core import NorthArrow, north_arrow # also valid
131
+ from matplotlib_map_utils import NorthArrow, north_arrow # also valid
111
132
  ```
112
133
 
113
134
  The quickest way to add a single north arrow to a single plot is to use the `north_arrow` function:
@@ -171,7 +192,7 @@ Instructions for how to do so can be found in `docs\howto_north_arrow`.
171
192
 
172
193
  ---
173
194
 
174
- ### Scale Bar
195
+ ### 📏 Scale Bar
175
196
 
176
197
  <details>
177
198
  <summary><i>Expand instructions</i></summary>
@@ -182,12 +203,16 @@ Importing the Scale Bar functions and classes can be done like so:
182
203
 
183
204
  ```py
184
205
  from matplotlib_map_utils.core.scale_bar import ScaleBar, scale_bar
206
+ from matplotlib_map_utils.core import ScaleBar, scale_bar # also valid
207
+ from matplotlib_map_utils import ScaleBar, scale_bar # also valid
185
208
  ```
186
209
 
187
210
  There are two available styles for the scale bars: `boxes` and `ticks`. The quickest way to add one to a single plot is to use the `scale_bar` function:
188
211
 
189
212
  ```python
190
213
  # Setting up a plot
214
+ # NOTE: you MUST set the desired DPI here, when the subplots are created
215
+ # so that the scale_bar's DPI matches!
191
216
  fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
192
217
  # Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
193
218
  # Here, this scale bar will have the "boxes" style
@@ -198,10 +223,12 @@ An object-oriented approach is also supported:
198
223
 
199
224
  ```python
200
225
  # Setting up a plot
226
+ # NOTE: you MUST set the desired DPI here, when the subplots are created
227
+ # so that the scale_bar's DPI matches!
201
228
  fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
202
229
  # Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
203
230
  # Here, we change the boxes to "ticks"
204
- sb = ScaleBar(location="upper right", style="boxes", bar={"projection":3857})
231
+ sb = ScaleBar(location="upper right", style="ticks", bar={"projection":3857})
205
232
  # Adding the artist to the plot
206
233
  ax.add_artist(sb)
207
234
  ```
@@ -237,7 +264,67 @@ Refer to `docs\howto_scale_bar` for details on how to customize each facet of th
237
264
 
238
265
  ---
239
266
 
240
- ### Utilities
267
+ ### 🗺️ Inset Map
268
+
269
+ <details>
270
+ <summary><i>Expand instructions</i></summary>
271
+
272
+ #### Quick Start
273
+
274
+ Importing the Inset Map functions and classes can be done like so:
275
+
276
+ ```py
277
+ from matplotlib_map_utils.core.inset_map import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail
278
+ from matplotlib_map_utils.core import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail # also valid
279
+ from matplotlib_map_utils import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail # also valid
280
+ ```
281
+
282
+ The quickest way to add a single inset map to an existing plot is the `inset_map` function:
283
+
284
+ ```python
285
+ # Setting up a plot
286
+ fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
287
+ # Adding an inset map to the upper-right corner of the axis
288
+ iax = inset_map(ax=ax, location="upper right", size=0.75, pad=0, xticks=[], yticks=[])
289
+ # You can now plot additional data to iax as desired
290
+ ```
291
+
292
+ An object-oriented approach is also supported:
293
+
294
+ ```python
295
+ # Setting up a plot
296
+ fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
297
+ # Creating an object for the inset map
298
+ im = InsetMap(location="upper right", size=0.75, pad=0, xticks=[], yticks=[])
299
+ # Adding the inset map template to the plot
300
+ iax = im.create(ax=ax)
301
+ # You can now plot additional data to iax as desired
302
+ ```
303
+
304
+ Both of these will create an output like the following:
305
+
306
+ ![Example inset map](matplotlib_map_utils/docs/assets/readme_insetmap.png)
307
+
308
+ #### Extent and Detail Indicators
309
+
310
+ Inset maps can be paired with either an extent or detail indicator, to provide additional geographic context to the inset map
311
+
312
+ ```python
313
+ indicate_extent(inset_axis, parent_axis, inset_crs, parent_crs, ...)
314
+ indicate_detail(parent_axis, inset_axis, parent_crs, inset_crs, ...)
315
+ ```
316
+
317
+ This will create an output like the following (extent indicator on the left, detail indicator on the right):
318
+
319
+ ![Customized scale bar](matplotlib_map_utils/docs/assets/readme_indicators.png)
320
+
321
+ Refer to `docs\howto_inset_map` for details on how to customize the inset map and indicators to your liking.
322
+
323
+ </details>
324
+
325
+ ---
326
+
327
+ ### 🛠️ Utilities
241
328
 
242
329
  <details>
243
330
  <summary><i>Expand instructions</i></summary>
@@ -283,23 +370,33 @@ Two more projects assisted with the creation of this script:
283
370
 
284
371
  #### Releases
285
372
 
286
- - `v2.0.1`: Fixed a bug in the `dual_bars()` function that prevented empty dictionaries to be passed. Also added a warning when auto-calculated bar widths appear to be exceeding the dimension of the axis (usually occurs when the axis is <2 kilometeres or miles long, depending on the units selected).
373
+ - `v1.0.x`: Initial releases featuring the North Arrow element, along with some minor bug fixes.
374
+
375
+ - `v2.0.0`: Initial release of the Scale Bar element.
376
+
377
+ - `v2.0.1`: Fixed a bug in the `dual_bars()` function that prevented empty dictionaries to be passed. Also added a warning when auto-calculated bar widths appear to be exceeding the dimension of the axis (usually occurs when the axis is <2 kilometers or miles long, depending on the units selected).
287
378
 
288
379
  - `v2.0.2`: Changed f-string formatting to alternate double and single quotes, so as to maintain compatibility with versions of Python before 3.12 (see [here](https://github.com/moss-xyz/matplotlib-map-utils/issues/3)). However, this did reveal that another aspect of the code, namely concatenating `type` in function arguments, requires 3.10, and so the minimum python version was incremented.
289
380
 
290
381
  - `v2.1.0`: Added a utility class, `USA`, for filtering subsets of US states and territories based on FIPS code, name, abbreviation, region, division, and more. This is considered a beta release, and might be subject to change later on.
291
382
 
383
+ - `v3.0.0`: Release of inset map and extent and detail indicator classes and functions.
384
+
385
+ - `v3.0.1`: Fixed a bug that led to an incorrect Scale Bar being rendered when using the function method (`scale_bar()`) on a plot containing raster data (see [here](https://github.com/moss-xyz/matplotlib-map-utils/issues/10) for details).
386
+
292
387
  #### Future Roadmap
293
388
 
294
- With the release of `v2.x`, and the addition of **Scale Bar** tools, this project has achieved the two main objectives that I set out to.
389
+ With the release of `v3.x`, this project has achieved full coverage of the "main" map elements I think are necessary.
295
390
 
296
391
  If I continue development of this project, I will be looking to add or fix the following features:
297
392
 
393
+ * For all: switch to a system based on Pydantic for easier type validation
394
+
298
395
  * **North Arrow:**
299
396
 
300
397
  * Copy the image-rendering functionality of the Scale Bar to allow for rotation of the entire object, label and arrow together
301
398
 
302
- * Create more styles for the arrow, potentiallly including a compass rose and a line-only arrow
399
+ * Create more styles for the arrow, potentially including a compass rose and a line-only arrow
303
400
 
304
401
  * **Scale Bar:**
305
402
 
@@ -309,7 +406,13 @@ If I continue development of this project, I will be looking to add or fix the f
309
406
 
310
407
  * Clean up the variable naming scheme (consistency on `loc` vs `position`, `style` vs `type`, etc.)
311
408
 
312
- * Create more styles for the bar, potentiallly including dual boxes and a sawtooth bar
409
+ * Create more styles for the bar, potentially including dual boxes and a sawtooth bar
410
+
411
+ * **Inset Map:**
412
+
413
+ * Clean up the way that connectors are drawn for detail indicators
414
+
415
+ * New functionality for placing multiple inset maps at once (with context-aware positioning to prevent overlap with each other)
313
416
 
314
417
  * **Utils:**
315
418
 
@@ -319,9 +422,7 @@ If I continue development of this project, I will be looking to add or fix the f
319
422
 
320
423
  * (USA): Stronger typing options, so you don't have to recall which `region` or `division` types are available, etc.
321
424
 
322
- If that goes well, `v3` can then 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.
323
-
324
- I am also open to ideas for other extensions to create!
425
+ Future releases (if the project is continued) will probably focus on other functions that I have created myself that give more control in the formatting of maps. I am also open to ideas for other extensions to create!
325
426
 
326
427
  #### Support and Contributions
327
428
 
@@ -0,0 +1,24 @@
1
+ matplotlib_map_utils/__init__.py,sha256=2mL2sZOjfxC--EthFMTMuYh1uvozz-9PzM4EDprDicU,949
2
+ matplotlib_map_utils/core/__init__.py,sha256=mIn7x-LZlvNaYMcmjZXwnKNTirv3Vv2lAJodwRg_AdU,471
3
+ matplotlib_map_utils/core/inset_map.py,sha256=-lZxiORndgYQAZzAerPaMlH95zrRsBspdwxIzHcn_2Q,40880
4
+ matplotlib_map_utils/core/north_arrow.py,sha256=BXagxPdy0uCWpGTFvw-qnaZZKZlXsINTha0sqaBRK-M,22415
5
+ matplotlib_map_utils/core/scale_bar.py,sha256=wku3KZEaTzmB0MBHVTj6orXH0Q36X0CJHvIzkCeC6s0,62996
6
+ matplotlib_map_utils/defaults/__init__.py,sha256=_pegE5kv_sb0ansSF4XpWBRwboaP4zUjWY1KIGbK-TE,119
7
+ matplotlib_map_utils/defaults/inset_map.py,sha256=RNwaZqWjDjdNwPgmqx_cN9lQQ6DW_Db61peaeMRCPlc,1569
8
+ matplotlib_map_utils/defaults/north_arrow.py,sha256=uZb1RsUWxFTHywm8HATj_9iPF_GjCs_Z2HOn0JchjTY,8571
9
+ matplotlib_map_utils/defaults/scale_bar.py,sha256=GpXiWUHcOsv43G1HOfpqw-dzDPQQzQB7RNdtIf0e7Bc,8225
10
+ matplotlib_map_utils/scratch/map_utils.py,sha256=j8dOX9uuotl9rRCAXapFLHycUwVE4nzIrqWYOGG2Lgg,19653
11
+ matplotlib_map_utils/scratch/north_arrow_old_classes.py,sha256=1xKQ6yUghX4BWzIv8GsGBHDDPJ8B0Na7ixdw2jgtTqw,50993
12
+ matplotlib_map_utils/utils/__init__.py,sha256=uUy0kUMMGrDpvo88J_OLk2dQI-UwCXclccaEyk8x5R0,41
13
+ matplotlib_map_utils/utils/usa.json,sha256=kLB9JXNSWf8VU-9XwXuMRAPKO-zA4aluQUEln7Ktc_s,26563
14
+ matplotlib_map_utils/utils/usa.py,sha256=7SlUdxtCan5PFNIoLe-HfOC5r2cxJAF-9QKhNIK71EI,16853
15
+ matplotlib_map_utils/validation/__init__.py,sha256=0fL3N63jxjRwTU44b7-6ZYZJfOT_0ac7dx7M6Gpu_5M,52
16
+ matplotlib_map_utils/validation/functions.py,sha256=gh3d6Gj1klL8jb0nOwavIe3b9KFpOOCgQx1dYv-XMTw,13173
17
+ matplotlib_map_utils/validation/inset_map.py,sha256=g5YQByVnQBtRb_PI8xqghkJ0IGdBtYvwNwQz_-ddQ4U,5791
18
+ matplotlib_map_utils/validation/north_arrow.py,sha256=Vs9ljD0PbxBI7-4J8PkzC8SRI-LCgZDnIrL1xA6h77E,10366
19
+ matplotlib_map_utils/validation/scale_bar.py,sha256=XrnGoAXwJFUTOnvoei1pqVJKu-BxcAaih27H6a4CXgk,17625
20
+ matplotlib_map_utils-3.0.1.dist-info/licenses/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
21
+ matplotlib_map_utils-3.0.1.dist-info/METADATA,sha256=9Rc1YXQ0bc3rY8jfi5DHGdJaGLsMBnVyMGOC8oVKCQI,16825
22
+ matplotlib_map_utils-3.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ matplotlib_map_utils-3.0.1.dist-info/top_level.txt,sha256=6UyDpxsnMhSOd9a-abQe0lLJveybJyYtUHMdX7zXgKA,21
24
+ matplotlib_map_utils-3.0.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,21 +0,0 @@
1
- matplotlib_map_utils/__init__.py,sha256=X6lN1yfP4ckb6l-ej20YqFvIHUNLZQxRWnvvyWBlJEY,305
2
- matplotlib_map_utils/core/__init__.py,sha256=G4fxPpfE77EhZr7yGZCjppP7zvwRthl8yHM0b2KgrFs,184
3
- matplotlib_map_utils/core/north_arrow.py,sha256=vikwYtSP2-sPRF_SQBALezB3uEY_PHA9dglm503hkvU,22531
4
- matplotlib_map_utils/core/scale_bar.py,sha256=l2tS35xa_pv40lag4Y00hT6FEGhQ-wOb07ipxDUYCNw,62248
5
- matplotlib_map_utils/defaults/__init__.py,sha256=_pegE5kv_sb0ansSF4XpWBRwboaP4zUjWY1KIGbK-TE,119
6
- matplotlib_map_utils/defaults/north_arrow.py,sha256=uZb1RsUWxFTHywm8HATj_9iPF_GjCs_Z2HOn0JchjTY,8571
7
- matplotlib_map_utils/defaults/scale_bar.py,sha256=GpXiWUHcOsv43G1HOfpqw-dzDPQQzQB7RNdtIf0e7Bc,8225
8
- matplotlib_map_utils/scratch/map_utils.py,sha256=j8dOX9uuotl9rRCAXapFLHycUwVE4nzIrqWYOGG2Lgg,19653
9
- matplotlib_map_utils/scratch/north_arrow_old_classes.py,sha256=1xKQ6yUghX4BWzIv8GsGBHDDPJ8B0Na7ixdw2jgtTqw,50993
10
- matplotlib_map_utils/utils/__init__.py,sha256=uUy0kUMMGrDpvo88J_OLk2dQI-UwCXclccaEyk8x5R0,41
11
- matplotlib_map_utils/utils/usa.json,sha256=kLB9JXNSWf8VU-9XwXuMRAPKO-zA4aluQUEln7Ktc_s,26563
12
- matplotlib_map_utils/utils/usa.py,sha256=7SlUdxtCan5PFNIoLe-HfOC5r2cxJAF-9QKhNIK71EI,16853
13
- matplotlib_map_utils/validation/__init__.py,sha256=0fL3N63jxjRwTU44b7-6ZYZJfOT_0ac7dx7M6Gpu_5M,52
14
- matplotlib_map_utils/validation/functions.py,sha256=QpOHs-GQ1NUMXO0HxAtEZvAcrXwsIE2ekqUhYm-IKGg,11783
15
- matplotlib_map_utils/validation/north_arrow.py,sha256=dlWbcKit7dq93PJVrv1efE_865irT6zwBuqD6NYLYPg,10349
16
- matplotlib_map_utils/validation/scale_bar.py,sha256=7rYs7ei0rQ5iJfapcBWkn7s4P-CnSh9B441GpsGpFO4,17628
17
- matplotlib_map_utils-2.1.0.dist-info/licenses/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
18
- matplotlib_map_utils-2.1.0.dist-info/METADATA,sha256=KaD3ZBhrkgi25DYJV2xJXx0wjcTM9MgmNcNr58Z6UcE,12839
19
- matplotlib_map_utils-2.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
20
- matplotlib_map_utils-2.1.0.dist-info/top_level.txt,sha256=6UyDpxsnMhSOd9a-abQe0lLJveybJyYtUHMdX7zXgKA,21
21
- matplotlib_map_utils-2.1.0.dist-info/RECORD,,