matplotlib-map-utils 2.1.0__tar.gz → 3.0.0__tar.gz
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-2.1.0 → matplotlib_map_utils-3.0.0}/PKG-INFO +115 -20
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/README.md +113 -19
- matplotlib_map_utils-3.0.0/matplotlib_map_utils/__init__.py +21 -0
- matplotlib_map_utils-3.0.0/matplotlib_map_utils/core/__init__.py +8 -0
- matplotlib_map_utils-3.0.0/matplotlib_map_utils/core/inset_map.py +952 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/core/north_arrow.py +0 -4
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/core/scale_bar.py +0 -6
- matplotlib_map_utils-3.0.0/matplotlib_map_utils/defaults/inset_map.py +67 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/validation/functions.py +51 -15
- matplotlib_map_utils-3.0.0/matplotlib_map_utils/validation/inset_map.py +88 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/validation/north_arrow.py +1 -1
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/validation/scale_bar.py +3 -5
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils.egg-info/PKG-INFO +115 -20
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils.egg-info/SOURCES.txt +3 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/pyproject.toml +2 -1
- matplotlib_map_utils-2.1.0/matplotlib_map_utils/__init__.py +0 -6
- matplotlib_map_utils-2.1.0/matplotlib_map_utils/core/__init__.py +0 -4
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/LICENSE +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/defaults/__init__.py +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/defaults/north_arrow.py +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/defaults/scale_bar.py +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/scratch/map_utils.py +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/scratch/north_arrow_old_classes.py +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/utils/__init__.py +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/utils/usa.json +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/utils/usa.py +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils/validation/__init__.py +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils.egg-info/dependency_links.txt +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils.egg-info/requires.txt +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/matplotlib_map_utils.egg-info/top_level.txt +0 -0
- {matplotlib_map_utils-2.1.0 → matplotlib_map_utils-3.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: matplotlib-map-utils
|
3
|
-
Version:
|
3
|
+
Version: 3.0.0
|
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
|
-
|
20
|
+

|
20
21
|
|
21
22
|
---
|
22
23
|
|
23
|
-
**Documentation
|
24
|
+
**Documentation:** See `docs` folder
|
24
25
|
|
25
|
-
**Source Code
|
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 `
|
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
|
-
|
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
|
-
|
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
|
-
|
50
|
+
Together, these allow for the easy creation of a map such as the following:
|
51
|
+
|
52
|
+

|
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
|
-
|
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,6 +203,8 @@ 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:
|
@@ -201,7 +224,7 @@ An object-oriented approach is also supported:
|
|
201
224
|
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
202
225
|
# Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
|
203
226
|
# Here, we change the boxes to "ticks"
|
204
|
-
sb = ScaleBar(location="upper right", style="
|
227
|
+
sb = ScaleBar(location="upper right", style="ticks", bar={"projection":3857})
|
205
228
|
# Adding the artist to the plot
|
206
229
|
ax.add_artist(sb)
|
207
230
|
```
|
@@ -237,7 +260,67 @@ Refer to `docs\howto_scale_bar` for details on how to customize each facet of th
|
|
237
260
|
|
238
261
|
---
|
239
262
|
|
240
|
-
###
|
263
|
+
### 🗺️ Inset Map
|
264
|
+
|
265
|
+
<details>
|
266
|
+
<summary><i>Expand instructions</i></summary>
|
267
|
+
|
268
|
+
#### Quick Start
|
269
|
+
|
270
|
+
Importing the Inset Map functions and classes can be done like so:
|
271
|
+
|
272
|
+
```py
|
273
|
+
from matplotlib_map_utils.core.inset_map import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail
|
274
|
+
from matplotlib_map_utils.core import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail # also valid
|
275
|
+
from matplotlib_map_utils import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail # also valid
|
276
|
+
```
|
277
|
+
|
278
|
+
The quickest way to add a single inset map to an existing plot is the `inset_map` function:
|
279
|
+
|
280
|
+
```python
|
281
|
+
# Setting up a plot
|
282
|
+
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
283
|
+
# Adding an inset map to the upper-right corner of the axis
|
284
|
+
iax = inset_map(ax=ax, location="upper right", size=0.75, pad=0, xticks=[], yticks=[])
|
285
|
+
# You can now plot additional data to iax as desired
|
286
|
+
```
|
287
|
+
|
288
|
+
An object-oriented approach is also supported:
|
289
|
+
|
290
|
+
```python
|
291
|
+
# Setting up a plot
|
292
|
+
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
293
|
+
# Creating an object for the inset map
|
294
|
+
im = InsetMap(location="upper right", size=0.75, pad=0, xticks=[], yticks=[])
|
295
|
+
# Adding the inset map template to the plot
|
296
|
+
iax = im.create(ax=ax)
|
297
|
+
# You can now plot additional data to iax as desired
|
298
|
+
```
|
299
|
+
|
300
|
+
Both of these will create an output like the following:
|
301
|
+
|
302
|
+

|
303
|
+
|
304
|
+
#### Extent and Detail Indicators
|
305
|
+
|
306
|
+
Inset maps can be paired with either an extent or detail indicator, to provide additional geographic context to the inset map
|
307
|
+
|
308
|
+
```python
|
309
|
+
indicate_extent(inset_axis, parent_axis, inset_crs, parent_crs, ...)
|
310
|
+
indicate_detail(parent_axis, inset_axis, parent_crs, inset_crs, ...)
|
311
|
+
```
|
312
|
+
|
313
|
+
This will create an output like the following (extent indicator on the left, detail indicator on the right):
|
314
|
+
|
315
|
+

|
316
|
+
|
317
|
+
Refer to `docs\howto_inset_map` for details on how to customize the inset map and indicators to your liking.
|
318
|
+
|
319
|
+
</details>
|
320
|
+
|
321
|
+
---
|
322
|
+
|
323
|
+
### 🛠️ Utilities
|
241
324
|
|
242
325
|
<details>
|
243
326
|
<summary><i>Expand instructions</i></summary>
|
@@ -283,23 +366,31 @@ Two more projects assisted with the creation of this script:
|
|
283
366
|
|
284
367
|
#### Releases
|
285
368
|
|
286
|
-
- `
|
369
|
+
- `v1.0.x`: Initial releases featuring the North Arrow element, along with some minor bug fixes.
|
370
|
+
|
371
|
+
- `v2.0.0`: Initial release of the Scale Bar element.
|
372
|
+
|
373
|
+
- `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
374
|
|
288
375
|
- `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
376
|
|
290
377
|
- `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
378
|
|
379
|
+
- `v3.0.0`: Release of inset map and extent and detail indicator classes and functions.
|
380
|
+
|
292
381
|
#### Future Roadmap
|
293
382
|
|
294
|
-
With the release of `
|
383
|
+
With the release of `v3.x`, this project has achieved full coverage of the "main" map elements I think are necessary.
|
295
384
|
|
296
385
|
If I continue development of this project, I will be looking to add or fix the following features:
|
297
386
|
|
387
|
+
* For all: switch to a system based on Pydantic for easier type validation
|
388
|
+
|
298
389
|
* **North Arrow:**
|
299
390
|
|
300
391
|
* Copy the image-rendering functionality of the Scale Bar to allow for rotation of the entire object, label and arrow together
|
301
392
|
|
302
|
-
* Create more styles for the arrow,
|
393
|
+
* Create more styles for the arrow, potentially including a compass rose and a line-only arrow
|
303
394
|
|
304
395
|
* **Scale Bar:**
|
305
396
|
|
@@ -309,7 +400,13 @@ If I continue development of this project, I will be looking to add or fix the f
|
|
309
400
|
|
310
401
|
* Clean up the variable naming scheme (consistency on `loc` vs `position`, `style` vs `type`, etc.)
|
311
402
|
|
312
|
-
* Create more styles for the bar,
|
403
|
+
* Create more styles for the bar, potentially including dual boxes and a sawtooth bar
|
404
|
+
|
405
|
+
* **Inset Map:**
|
406
|
+
|
407
|
+
* Clean up the way that connectors are drawn for detail indicators
|
408
|
+
|
409
|
+
* New functionality for placing multiple inset maps at once (with context-aware positioning to prevent overlap with each other)
|
313
410
|
|
314
411
|
* **Utils:**
|
315
412
|
|
@@ -319,9 +416,7 @@ If I continue development of this project, I will be looking to add or fix the f
|
|
319
416
|
|
320
417
|
* (USA): Stronger typing options, so you don't have to recall which `region` or `division` types are available, etc.
|
321
418
|
|
322
|
-
|
323
|
-
|
324
|
-
I am also open to ideas for other extensions to create!
|
419
|
+
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
420
|
|
326
421
|
#### Support and Contributions
|
327
422
|
|
@@ -1,10 +1,12 @@
|
|
1
|
-
|
1
|
+

|
2
2
|
|
3
3
|
---
|
4
4
|
|
5
|
-
**Documentation
|
5
|
+
**Documentation:** See `docs` folder
|
6
6
|
|
7
|
-
**Source Code
|
7
|
+
**Source Code:** [Available on GitHub](https://github.com/moss-xyz/matplotlib-map-utils)
|
8
|
+
|
9
|
+
**Feedback:** I welcome any and all feedback! See the *Development Notes* below for more details.
|
8
10
|
|
9
11
|
---
|
10
12
|
|
@@ -12,15 +14,23 @@
|
|
12
14
|
|
13
15
|
`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/).
|
14
16
|
|
15
|
-
As of `
|
17
|
+
As of `v3.x` (the current version), this includes three-ish elements:
|
18
|
+
|
19
|
+
* `north_arrow.py`, for adding a north arrow to a given plot.
|
20
|
+
|
21
|
+
* `scale_bar.py`, for adding a scale bar to a given plot.
|
22
|
+
|
23
|
+
* `inset_map.py`, for adding inset maps and detail/extent indicators to a given plot.
|
16
24
|
|
17
|
-
|
25
|
+
The three elements listed above are all intended to be high-resolution, easily modifiable, and context-aware, relative to your specific plot.
|
18
26
|
|
19
|
-
|
27
|
+
This package also contains a single utility object:
|
20
28
|
|
21
29
|
* `usa.py`, which contains a class that helps filter for states and territories within the USA based on given characteristics.
|
22
30
|
|
23
|
-
|
31
|
+
Together, these allow for the easy creation of a map such as the following:
|
32
|
+
|
33
|
+

|
24
34
|
|
25
35
|
---
|
26
36
|
|
@@ -44,7 +54,8 @@ The requirements for this package are:
|
|
44
54
|
|
45
55
|
### Package Structure
|
46
56
|
|
47
|
-
|
57
|
+
<details>
|
58
|
+
<summary><i>The package is arrayed in the following way:</i></summary>
|
48
59
|
|
49
60
|
```bash
|
50
61
|
package_name/
|
@@ -52,17 +63,20 @@ package_name/
|
|
52
63
|
│
|
53
64
|
├── core/
|
54
65
|
│ ├── __init__.py
|
66
|
+
│ ├── inset_map.py
|
55
67
|
│ ├── north_arrow.py
|
56
68
|
│ ├── scale_bar.py
|
57
69
|
├── validation/
|
58
70
|
│ ├── __init__.py
|
59
71
|
│ ├── functions.py
|
72
|
+
│ └── inset_map.py
|
60
73
|
│ ├── north_arrow.py
|
61
74
|
│ └── scale_bar.py
|
62
75
|
├── defaults/
|
63
76
|
│ ├── __init__.py
|
64
77
|
│ ├── north_arrow.py
|
65
78
|
│ └── scale_bar.py
|
79
|
+
│ └── inset_map.py
|
66
80
|
├── utils/
|
67
81
|
│ ├── __init__.py
|
68
82
|
│ ├── usa.py
|
@@ -77,9 +91,13 @@ Where:
|
|
77
91
|
|
78
92
|
* `defaults` contains default settings for each object at different paper sizes
|
79
93
|
|
94
|
+
* `utils` contains utility functions and objects
|
95
|
+
|
96
|
+
</details>
|
97
|
+
|
80
98
|
---
|
81
99
|
|
82
|
-
### North Arrow
|
100
|
+
### 🧭 North Arrow
|
83
101
|
|
84
102
|
<details>
|
85
103
|
<summary><i>Expand instructions</i></summary>
|
@@ -90,6 +108,8 @@ Importing the North Arrow functions and classes can be done like so:
|
|
90
108
|
|
91
109
|
```py
|
92
110
|
from matplotlib_map_utils.core.north_arrow import NorthArrow, north_arrow
|
111
|
+
from matplotlib_map_utils.core import NorthArrow, north_arrow # also valid
|
112
|
+
from matplotlib_map_utils import NorthArrow, north_arrow # also valid
|
93
113
|
```
|
94
114
|
|
95
115
|
The quickest way to add a single north arrow to a single plot is to use the `north_arrow` function:
|
@@ -153,7 +173,7 @@ Instructions for how to do so can be found in `docs\howto_north_arrow`.
|
|
153
173
|
|
154
174
|
---
|
155
175
|
|
156
|
-
### Scale Bar
|
176
|
+
### 📏 Scale Bar
|
157
177
|
|
158
178
|
<details>
|
159
179
|
<summary><i>Expand instructions</i></summary>
|
@@ -164,6 +184,8 @@ Importing the Scale Bar functions and classes can be done like so:
|
|
164
184
|
|
165
185
|
```py
|
166
186
|
from matplotlib_map_utils.core.scale_bar import ScaleBar, scale_bar
|
187
|
+
from matplotlib_map_utils.core import ScaleBar, scale_bar # also valid
|
188
|
+
from matplotlib_map_utils import ScaleBar, scale_bar # also valid
|
167
189
|
```
|
168
190
|
|
169
191
|
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:
|
@@ -183,7 +205,7 @@ An object-oriented approach is also supported:
|
|
183
205
|
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
184
206
|
# Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
|
185
207
|
# Here, we change the boxes to "ticks"
|
186
|
-
sb = ScaleBar(location="upper right", style="
|
208
|
+
sb = ScaleBar(location="upper right", style="ticks", bar={"projection":3857})
|
187
209
|
# Adding the artist to the plot
|
188
210
|
ax.add_artist(sb)
|
189
211
|
```
|
@@ -219,7 +241,67 @@ Refer to `docs\howto_scale_bar` for details on how to customize each facet of th
|
|
219
241
|
|
220
242
|
---
|
221
243
|
|
222
|
-
###
|
244
|
+
### 🗺️ Inset Map
|
245
|
+
|
246
|
+
<details>
|
247
|
+
<summary><i>Expand instructions</i></summary>
|
248
|
+
|
249
|
+
#### Quick Start
|
250
|
+
|
251
|
+
Importing the Inset Map functions and classes can be done like so:
|
252
|
+
|
253
|
+
```py
|
254
|
+
from matplotlib_map_utils.core.inset_map import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail
|
255
|
+
from matplotlib_map_utils.core import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail # also valid
|
256
|
+
from matplotlib_map_utils import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail # also valid
|
257
|
+
```
|
258
|
+
|
259
|
+
The quickest way to add a single inset map to an existing plot is the `inset_map` function:
|
260
|
+
|
261
|
+
```python
|
262
|
+
# Setting up a plot
|
263
|
+
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
264
|
+
# Adding an inset map to the upper-right corner of the axis
|
265
|
+
iax = inset_map(ax=ax, location="upper right", size=0.75, pad=0, xticks=[], yticks=[])
|
266
|
+
# You can now plot additional data to iax as desired
|
267
|
+
```
|
268
|
+
|
269
|
+
An object-oriented approach is also supported:
|
270
|
+
|
271
|
+
```python
|
272
|
+
# Setting up a plot
|
273
|
+
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
274
|
+
# Creating an object for the inset map
|
275
|
+
im = InsetMap(location="upper right", size=0.75, pad=0, xticks=[], yticks=[])
|
276
|
+
# Adding the inset map template to the plot
|
277
|
+
iax = im.create(ax=ax)
|
278
|
+
# You can now plot additional data to iax as desired
|
279
|
+
```
|
280
|
+
|
281
|
+
Both of these will create an output like the following:
|
282
|
+
|
283
|
+

|
284
|
+
|
285
|
+
#### Extent and Detail Indicators
|
286
|
+
|
287
|
+
Inset maps can be paired with either an extent or detail indicator, to provide additional geographic context to the inset map
|
288
|
+
|
289
|
+
```python
|
290
|
+
indicate_extent(inset_axis, parent_axis, inset_crs, parent_crs, ...)
|
291
|
+
indicate_detail(parent_axis, inset_axis, parent_crs, inset_crs, ...)
|
292
|
+
```
|
293
|
+
|
294
|
+
This will create an output like the following (extent indicator on the left, detail indicator on the right):
|
295
|
+
|
296
|
+

|
297
|
+
|
298
|
+
Refer to `docs\howto_inset_map` for details on how to customize the inset map and indicators to your liking.
|
299
|
+
|
300
|
+
</details>
|
301
|
+
|
302
|
+
---
|
303
|
+
|
304
|
+
### 🛠️ Utilities
|
223
305
|
|
224
306
|
<details>
|
225
307
|
<summary><i>Expand instructions</i></summary>
|
@@ -265,23 +347,31 @@ Two more projects assisted with the creation of this script:
|
|
265
347
|
|
266
348
|
#### Releases
|
267
349
|
|
268
|
-
- `
|
350
|
+
- `v1.0.x`: Initial releases featuring the North Arrow element, along with some minor bug fixes.
|
351
|
+
|
352
|
+
- `v2.0.0`: Initial release of the Scale Bar element.
|
353
|
+
|
354
|
+
- `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).
|
269
355
|
|
270
356
|
- `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.
|
271
357
|
|
272
358
|
- `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.
|
273
359
|
|
360
|
+
- `v3.0.0`: Release of inset map and extent and detail indicator classes and functions.
|
361
|
+
|
274
362
|
#### Future Roadmap
|
275
363
|
|
276
|
-
With the release of `
|
364
|
+
With the release of `v3.x`, this project has achieved full coverage of the "main" map elements I think are necessary.
|
277
365
|
|
278
366
|
If I continue development of this project, I will be looking to add or fix the following features:
|
279
367
|
|
368
|
+
* For all: switch to a system based on Pydantic for easier type validation
|
369
|
+
|
280
370
|
* **North Arrow:**
|
281
371
|
|
282
372
|
* Copy the image-rendering functionality of the Scale Bar to allow for rotation of the entire object, label and arrow together
|
283
373
|
|
284
|
-
* Create more styles for the arrow,
|
374
|
+
* Create more styles for the arrow, potentially including a compass rose and a line-only arrow
|
285
375
|
|
286
376
|
* **Scale Bar:**
|
287
377
|
|
@@ -291,7 +381,13 @@ If I continue development of this project, I will be looking to add or fix the f
|
|
291
381
|
|
292
382
|
* Clean up the variable naming scheme (consistency on `loc` vs `position`, `style` vs `type`, etc.)
|
293
383
|
|
294
|
-
* Create more styles for the bar,
|
384
|
+
* Create more styles for the bar, potentially including dual boxes and a sawtooth bar
|
385
|
+
|
386
|
+
* **Inset Map:**
|
387
|
+
|
388
|
+
* Clean up the way that connectors are drawn for detail indicators
|
389
|
+
|
390
|
+
* New functionality for placing multiple inset maps at once (with context-aware positioning to prevent overlap with each other)
|
295
391
|
|
296
392
|
* **Utils:**
|
297
393
|
|
@@ -301,9 +397,7 @@ If I continue development of this project, I will be looking to add or fix the f
|
|
301
397
|
|
302
398
|
* (USA): Stronger typing options, so you don't have to recall which `region` or `division` types are available, etc.
|
303
399
|
|
304
|
-
|
305
|
-
|
306
|
-
I am also open to ideas for other extensions to create!
|
400
|
+
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!
|
307
401
|
|
308
402
|
#### Support and Contributions
|
309
403
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This handles importing of all the functions and classes
|
2
|
+
from .core.north_arrow import NorthArrow, north_arrow
|
3
|
+
from .core.scale_bar import ScaleBar, scale_bar, dual_bars
|
4
|
+
from .core.inset_map import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail, inset_usa
|
5
|
+
from typing import Literal
|
6
|
+
|
7
|
+
# This defines what wildcard imports should import
|
8
|
+
__all__ = ["NorthArrow", "north_arrow",
|
9
|
+
"ScaleBar", "scale_bar", "dual_bars",
|
10
|
+
"InsetMap","inset_map", "ExtentIndicator","indicate_extent", "DetailIndicator","indicate_detail", "inset_usa",
|
11
|
+
"set_size"]
|
12
|
+
|
13
|
+
def set_size(size: Literal["xs","xsmall","x-small",
|
14
|
+
"sm","small",
|
15
|
+
"md","medium",
|
16
|
+
"lg","large",
|
17
|
+
"xl","xlarge","x-large"]):
|
18
|
+
|
19
|
+
NorthArrow.set_size(size)
|
20
|
+
ScaleBar.set_size(size)
|
21
|
+
InsetMap.set_size(size)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
from typing import Literal
|
2
|
+
from .north_arrow import NorthArrow, north_arrow
|
3
|
+
from .scale_bar import ScaleBar, scale_bar, dual_bars
|
4
|
+
from .inset_map import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail, inset_usa
|
5
|
+
|
6
|
+
__all__ = ["NorthArrow", "north_arrow",
|
7
|
+
"ScaleBar", "scale_bar", "dual_bars",
|
8
|
+
"InsetMap","inset_map", "ExtentIndicator","indicate_extent", "DetailIndicator","indicate_detail", "inset_usa"]
|