matplotlib-map-utils 3.1.0__py3-none-any.whl → 3.1.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.
- matplotlib_map_utils/core/scale_bar.py +6 -1
- matplotlib_map_utils-3.1.1.dist-info/METADATA +1158 -0
- {matplotlib_map_utils-3.1.0.dist-info → matplotlib_map_utils-3.1.1.dist-info}/RECORD +6 -6
- matplotlib_map_utils-3.1.0.dist-info/METADATA +0 -482
- {matplotlib_map_utils-3.1.0.dist-info → matplotlib_map_utils-3.1.1.dist-info}/WHEEL +0 -0
- {matplotlib_map_utils-3.1.0.dist-info → matplotlib_map_utils-3.1.1.dist-info}/licenses/LICENSE +0 -0
- {matplotlib_map_utils-3.1.0.dist-info → matplotlib_map_utils-3.1.1.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,7 @@ matplotlib_map_utils/__init__.py,sha256=2mL2sZOjfxC--EthFMTMuYh1uvozz-9PzM4EDprD
|
|
2
2
|
matplotlib_map_utils/core/__init__.py,sha256=mIn7x-LZlvNaYMcmjZXwnKNTirv3Vv2lAJodwRg_AdU,471
|
3
3
|
matplotlib_map_utils/core/inset_map.py,sha256=iJISV0gZ3OmhO-DzC5z5kH5qL8fpdqmHn5OkdhdtzAY,41561
|
4
4
|
matplotlib_map_utils/core/north_arrow.py,sha256=UDn0TBnLuhuONbibb_XT8C2HNSY6ONLCQgadR19WpmI,22846
|
5
|
-
matplotlib_map_utils/core/scale_bar.py,sha256=
|
5
|
+
matplotlib_map_utils/core/scale_bar.py,sha256=kM9WMwdpKJuShl8BkzsRcFhc0y-Kxu8wJpriz8iVYzk,67064
|
6
6
|
matplotlib_map_utils/defaults/__init__.py,sha256=_pegE5kv_sb0ansSF4XpWBRwboaP4zUjWY1KIGbK-TE,119
|
7
7
|
matplotlib_map_utils/defaults/inset_map.py,sha256=RNwaZqWjDjdNwPgmqx_cN9lQQ6DW_Db61peaeMRCPlc,1569
|
8
8
|
matplotlib_map_utils/defaults/north_arrow.py,sha256=uZb1RsUWxFTHywm8HATj_9iPF_GjCs_Z2HOn0JchjTY,8571
|
@@ -17,8 +17,8 @@ matplotlib_map_utils/validation/functions.py,sha256=IIT9DiPKVv_ZHUTC8FwXJPt2pzdQ
|
|
17
17
|
matplotlib_map_utils/validation/inset_map.py,sha256=C5e_zOBKHqVNgufhwoIxu1OhlvXoaj70WxreW4BSfnA,6019
|
18
18
|
matplotlib_map_utils/validation/north_arrow.py,sha256=6D-uLiMmre0E9JwjR0BTWNZJyCqPuL0b3HGZ91UHoXw,10442
|
19
19
|
matplotlib_map_utils/validation/scale_bar.py,sha256=dYhiuqBV8wkMmFsR8p4RMbfBmN1DU--5cWU-Om9m7UY,18162
|
20
|
-
matplotlib_map_utils-3.1.
|
21
|
-
matplotlib_map_utils-3.1.
|
22
|
-
matplotlib_map_utils-3.1.
|
23
|
-
matplotlib_map_utils-3.1.
|
24
|
-
matplotlib_map_utils-3.1.
|
20
|
+
matplotlib_map_utils-3.1.1.dist-info/licenses/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
21
|
+
matplotlib_map_utils-3.1.1.dist-info/METADATA,sha256=AZQKlt58icL88wIRhSJwyEdU6XhEDwcr-zpiwBBsoQQ,63423
|
22
|
+
matplotlib_map_utils-3.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
matplotlib_map_utils-3.1.1.dist-info/top_level.txt,sha256=6UyDpxsnMhSOd9a-abQe0lLJveybJyYtUHMdX7zXgKA,21
|
24
|
+
matplotlib_map_utils-3.1.1.dist-info/RECORD,,
|
@@ -1,482 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: matplotlib-map-utils
|
3
|
-
Version: 3.1.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
|
-
Classifier: Framework :: Matplotlib
|
12
|
-
Requires-Python: >=3.10
|
13
|
-
Description-Content-Type: text/markdown
|
14
|
-
License-File: LICENSE
|
15
|
-
Requires-Dist: matplotlib>=3.9.0
|
16
|
-
Requires-Dist: cartopy>=0.23.0
|
17
|
-
Requires-Dist: great-circle-calculator>=1.3.1
|
18
|
-
Dynamic: license-file
|
19
|
-
|
20
|
-

|
21
|
-
|
22
|
-
---
|
23
|
-
|
24
|
-
**Documentation:** See `docs` folder
|
25
|
-
|
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.
|
29
|
-
|
30
|
-
---
|
31
|
-
|
32
|
-
### 👋 Introduction
|
33
|
-
|
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/).
|
35
|
-
|
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.
|
43
|
-
|
44
|
-
The three elements listed above are all intended to be high-resolution, easily modifiable, and context-aware, relative to your specific plot.
|
45
|
-
|
46
|
-
This package also contains a single utility object:
|
47
|
-
|
48
|
-
* `usa.py`, which contains a class that helps filter for states and territories within the USA based on given characteristics.
|
49
|
-
|
50
|
-
Together, these allow for the easy creation of a map such as the following:
|
51
|
-
|
52
|
-

|
53
|
-
|
54
|
-
---
|
55
|
-
|
56
|
-
### 💾 Installation
|
57
|
-
|
58
|
-
This package is available on PyPi, and can be installed like so:
|
59
|
-
|
60
|
-
```bash
|
61
|
-
pip install matplotlib-map-utils
|
62
|
-
```
|
63
|
-
|
64
|
-
The requirements for this package are:
|
65
|
-
|
66
|
-
* `python >= 3.10` (due to the use of the pipe operator to concatenate dictionaries and types)
|
67
|
-
|
68
|
-
* `matplotlib >= 3.9` (might work with lower versions but not guaranteed)
|
69
|
-
|
70
|
-
* `cartopy >= 0.23` (due to earlier bug with calling `copy()` on `CRS` objects)
|
71
|
-
|
72
|
-
---
|
73
|
-
|
74
|
-
### 📦 Package Structure
|
75
|
-
|
76
|
-
<details>
|
77
|
-
<summary><i>The package is arrayed in the following way:</i></summary>
|
78
|
-
|
79
|
-
```bash
|
80
|
-
package_name/
|
81
|
-
├── __init__.py
|
82
|
-
│
|
83
|
-
├── core/
|
84
|
-
│ ├── __init__.py
|
85
|
-
│ ├── inset_map.py
|
86
|
-
│ ├── north_arrow.py
|
87
|
-
│ ├── scale_bar.py
|
88
|
-
├── validation/
|
89
|
-
│ ├── __init__.py
|
90
|
-
│ ├── functions.py
|
91
|
-
│ └── inset_map.py
|
92
|
-
│ ├── north_arrow.py
|
93
|
-
│ └── scale_bar.py
|
94
|
-
├── defaults/
|
95
|
-
│ ├── __init__.py
|
96
|
-
│ ├── north_arrow.py
|
97
|
-
│ └── scale_bar.py
|
98
|
-
│ └── inset_map.py
|
99
|
-
├── utils/
|
100
|
-
│ ├── __init__.py
|
101
|
-
│ ├── usa.py
|
102
|
-
│ └── usa.json
|
103
|
-
```
|
104
|
-
|
105
|
-
Where:
|
106
|
-
|
107
|
-
* `core` contains the main functions and classes for each object
|
108
|
-
|
109
|
-
* `validation` contains type hints for each variable and functions to validate inputs
|
110
|
-
|
111
|
-
* `defaults` contains default settings for each object at different paper sizes
|
112
|
-
|
113
|
-
* `utils` contains utility functions and objects
|
114
|
-
|
115
|
-
</details>
|
116
|
-
|
117
|
-
---
|
118
|
-
|
119
|
-
### 🧭 North Arrow
|
120
|
-
|
121
|
-
<details>
|
122
|
-
<summary><i>Expand instructions</i></summary>
|
123
|
-
|
124
|
-
#### Quick Start
|
125
|
-
|
126
|
-
Importing the North Arrow functions and classes can be done like so:
|
127
|
-
|
128
|
-
```py
|
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
|
132
|
-
```
|
133
|
-
|
134
|
-
The quickest way to add a single north arrow to a single plot is to use the `north_arrow` function:
|
135
|
-
|
136
|
-
```python
|
137
|
-
# Setting up a plot
|
138
|
-
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
139
|
-
# Adding a north arrow to the upper-right corner of the axis, without any rotation (see Rotation under Formatting Components for details)
|
140
|
-
north_arrow.north_arrow(ax=ax, location="upper right", rotation={"degrees":0})
|
141
|
-
```
|
142
|
-
|
143
|
-
An object-oriented approach is also supported:
|
144
|
-
|
145
|
-
```python
|
146
|
-
# Setting up a plot
|
147
|
-
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
148
|
-
# Creating a north arrow for the upper-right corner of the axis, without any rotation (see Rotation under Formatting Components for details)
|
149
|
-
na = north_arrow.NorthArrow(location="upper right", rotation={"degrees":0})
|
150
|
-
# Adding the artist to the plot
|
151
|
-
ax.add_artist(na)
|
152
|
-
```
|
153
|
-
|
154
|
-
Both of these will create an output like the following:
|
155
|
-
|
156
|
-

|
157
|
-
|
158
|
-
#### Customization
|
159
|
-
|
160
|
-
Both the object-oriented and functional approaches can be customized to allow for fine-grained control over formatting:
|
161
|
-
|
162
|
-
```python
|
163
|
-
north_arrow(
|
164
|
-
ax,
|
165
|
-
location = "upper right", # accepts a valid string from the list of locations
|
166
|
-
scale = 0.5, # accepts a valid positive float or integer
|
167
|
-
# each of the follow accepts arguments from a customized style dictionary
|
168
|
-
base = {"facecolor":"green"},
|
169
|
-
fancy = False,
|
170
|
-
label = {"text":"North"},
|
171
|
-
shadow = {"alpha":0.8},
|
172
|
-
pack = {"sep":6},
|
173
|
-
aob = {"pad":2},
|
174
|
-
rotation = {"degrees": 35}
|
175
|
-
)
|
176
|
-
```
|
177
|
-
|
178
|
-
This will create an output like the following:
|
179
|
-
|
180
|
-

|
181
|
-
|
182
|
-
Refer to `docs\howto_north_arrow` for details on how to customize each facet of the north arrow.
|
183
|
-
|
184
|
-
#### Rotation
|
185
|
-
|
186
|
-
The north arrow object is also capable of pointing towards "true north", given a CRS and reference point:
|
187
|
-
|
188
|
-

|
189
|
-
|
190
|
-
Instructions for how to do so can be found in `docs\howto_north_arrow`.
|
191
|
-
</details>
|
192
|
-
|
193
|
-
---
|
194
|
-
|
195
|
-
### 📏 Scale Bar
|
196
|
-
|
197
|
-
<details>
|
198
|
-
<summary><i>Expand instructions</i></summary>
|
199
|
-
|
200
|
-
#### Quick Start
|
201
|
-
|
202
|
-
Importing the Scale Bar functions and classes can be done like so:
|
203
|
-
|
204
|
-
```py
|
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
|
208
|
-
```
|
209
|
-
|
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:
|
211
|
-
|
212
|
-
```python
|
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!
|
216
|
-
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
217
|
-
# Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
|
218
|
-
# Here, this scale bar will have the "boxes" style
|
219
|
-
scale_bar(ax=ax, location="upper right", style="boxes", bar={"projection":3857})
|
220
|
-
```
|
221
|
-
|
222
|
-
An object-oriented approach is also supported:
|
223
|
-
|
224
|
-
```python
|
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!
|
228
|
-
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
229
|
-
# Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
|
230
|
-
# Here, we change the boxes to "ticks"
|
231
|
-
sb = ScaleBar(location="upper right", style="ticks", bar={"projection":3857})
|
232
|
-
# Adding the artist to the plot
|
233
|
-
ax.add_artist(sb)
|
234
|
-
```
|
235
|
-
|
236
|
-
Both of these will create an output like the following (function is left, class is right):
|
237
|
-
|
238
|
-

|
239
|
-
|
240
|
-
#### Customization
|
241
|
-
|
242
|
-
Both the object-oriented and functional approaches can be customized to allow for fine-grained control over formatting:
|
243
|
-
|
244
|
-
```python
|
245
|
-
scale_bar(
|
246
|
-
ax,
|
247
|
-
location = "upper right", # accepts a valid string from the list of locations
|
248
|
-
style = "boxes", # accepts a valid positive float or integer
|
249
|
-
# each of the follow accepts arguments from a customized style dictionary
|
250
|
-
bar = {"unit":"mi", "length":2}, # converting the units to miles, and changing the length of the bar (in inches)
|
251
|
-
labels = {"style":"major", "loc":"below"}, # placing a label on each major division, and moving them below the bar
|
252
|
-
units = {"loc":"text"}, # changing the location of the units text to the major division labels
|
253
|
-
text = {"fontfamily":"monospace"}, # changing the font family of all the text to monospace
|
254
|
-
)
|
255
|
-
```
|
256
|
-
|
257
|
-
This will create an output like the following:
|
258
|
-
|
259
|
-

|
260
|
-
|
261
|
-
Refer to `docs\howto_scale_bar` for details on how to customize each facet of the scale bar.
|
262
|
-
|
263
|
-
#### Specifying Length
|
264
|
-
|
265
|
-
There are three main ways of specifying the length of a scale bar:
|
266
|
-
|
267
|
-
- `length` is used to set the total length of the bar, either in _inches_ (for values >= 1) or as a _fraction of the axis_ (for values < 1).
|
268
|
-
- The default value of the scale bar utilizes this method, with a `length` value of `0.25` (meaning 25% of the axis).
|
269
|
-
- It will automatically orient itself against the horizontal or vertical axis when calculating its fraction, based on the value supplied for `rotation`.
|
270
|
-
- Note that any values here will be rounded to a "nice" whole integer, so the length will *always be approximate*; ex., if two inches is 9,128 units, your scale bar will end up being 9,000 units, and therefore a little less than two inches.
|
271
|
-
- Values `major_div` and `minor_div` are ignored, while a value for `max` will _override_ `length`.
|
272
|
-
|
273
|
-
- `max` is used to define the total length of the bar, _in the same units as your map_, as determined by the value of `projection` and `unit`.
|
274
|
-
- Ex: If you are using a projection in feet, and give a `max` of `1000`, your scale bar will be representative of 1,000 feet.
|
275
|
-
- Ex: If you are using a projection in feet, but provide a value of `meter` to `unit`, and give a `max` of `1000`, your scale bar will be representative of 1,000 meters.
|
276
|
-
- Will _override_ any value provided for `length`, and give a warning that it is doing so!
|
277
|
-
- Values can be optionally be provided for `major_div` and `minor_div`, to subdivide the bar into major or minor segments as you desire; if left blank, values for these will be calculated automatically (see `preferred_divs` in `validation/scale_bar.py` for the values used).
|
278
|
-
|
279
|
-
- `major_mult` can be used alongside `major_div` to _derive_ the total length: `major_mult` is the _length of a **single** major division_, in the _same units as your map_ (as determined by the value of `projection` and `unit`), which is then multiplied out by `major_div` to arrive at the desired length of the bar.
|
280
|
-
- Ex: If you set `major_mult` to 1,000, and `major_div` to 3, your bar will be 3,000 units long, divided into three 1,000 segments.
|
281
|
-
- This is the _only_ use case for `major_mult` - using it anywhere else will result in warnings and/or errors!
|
282
|
-
- Specifying either `max` or `length` will override this method!
|
283
|
-
- `minor_div` can still be _optionally_ provided.
|
284
|
-
|
285
|
-
All of the above cases expect a valid CRS to be supplied to the `projection` parameter, to correctly calculate the relative size of the bar with respect to the map's underlying units. However, three _additional_ values may be passed to `projection`, to override this behavior entirely:
|
286
|
-
|
287
|
-
- If `projection` is set to `px`, `pixel`, or `pixels`, then values for `max` and `major_mult` are interpreted as being in _pixels_ (so a `max` of 1,000 will result in a bar 1,000 pixels long)
|
288
|
-
|
289
|
-
- If `projection` is set to `pt`, `point`, or `points`, then values for `max` and `major_mult` are interpreted as being in _points_ (so a `max` of 1,000 will result in a bar 1,000 points long (a point is 1/72 of an inch))
|
290
|
-
|
291
|
-
- If `projection` is set to `dx`, `custom`, or `axis`, then values for `max` and `major_mult` are interpreted as being in _the units of the x or y axis_ (so a `max` of 1,000 will result in a bar equal to 1,000 units of the x-axis (if orientated horizontally))
|
292
|
-
|
293
|
-
The intent of these additional methods is to provide an alternative interface for defining the bar, in the case of non-standard projections, or for non-cartographic use cases (in particular, this is inspired by the `dx` implementation of `matplotlib-scalebar`). However, this puts the onus on the user to know how big their bar should be - you also cannot pass a value to `unit` to convert! Note you can provide custom label text to the bar via the `labels` and `units` arguments (ex. if you need to label "inches" or something).
|
294
|
-
|
295
|
-
</details>
|
296
|
-
|
297
|
-
---
|
298
|
-
|
299
|
-
### 🗺️ Inset Map
|
300
|
-
|
301
|
-
<details>
|
302
|
-
<summary><i>Expand instructions</i></summary>
|
303
|
-
|
304
|
-
#### Quick Start
|
305
|
-
|
306
|
-
Importing the Inset Map functions and classes can be done like so:
|
307
|
-
|
308
|
-
```py
|
309
|
-
from matplotlib_map_utils.core.inset_map import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail
|
310
|
-
from matplotlib_map_utils.core import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail # also valid
|
311
|
-
from matplotlib_map_utils import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail # also valid
|
312
|
-
```
|
313
|
-
|
314
|
-
The quickest way to add a single inset map to an existing plot is the `inset_map` function:
|
315
|
-
|
316
|
-
```python
|
317
|
-
# Setting up a plot
|
318
|
-
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
319
|
-
# Adding an inset map to the upper-right corner of the axis
|
320
|
-
iax = inset_map(ax=ax, location="upper right", size=0.75, pad=0, xticks=[], yticks=[])
|
321
|
-
# You can now plot additional data to iax as desired
|
322
|
-
```
|
323
|
-
|
324
|
-
An object-oriented approach is also supported:
|
325
|
-
|
326
|
-
```python
|
327
|
-
# Setting up a plot
|
328
|
-
fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
|
329
|
-
# Creating an object for the inset map
|
330
|
-
im = InsetMap(location="upper right", size=0.75, pad=0, xticks=[], yticks=[])
|
331
|
-
# Adding the inset map template to the plot
|
332
|
-
iax = im.create(ax=ax)
|
333
|
-
# You can now plot additional data to iax as desired
|
334
|
-
```
|
335
|
-
|
336
|
-
Both of these will create an output like the following:
|
337
|
-
|
338
|
-

|
339
|
-
|
340
|
-
#### Extent and Detail Indicators
|
341
|
-
|
342
|
-
Inset maps can be paired with either an extent or detail indicator, to provide additional geographic context to the inset map
|
343
|
-
|
344
|
-
```python
|
345
|
-
indicate_extent(inset_axis, parent_axis, inset_crs, parent_crs, ...)
|
346
|
-
indicate_detail(parent_axis, inset_axis, parent_crs, inset_crs, ...)
|
347
|
-
```
|
348
|
-
|
349
|
-
This will create an output like the following (extent indicator on the left, detail indicator on the right):
|
350
|
-
|
351
|
-

|
352
|
-
|
353
|
-
Refer to `docs\howto_inset_map` for details on how to customize the inset map and indicators to your liking.
|
354
|
-
|
355
|
-
</details>
|
356
|
-
|
357
|
-
---
|
358
|
-
|
359
|
-
### 🛠️ Utilities
|
360
|
-
|
361
|
-
<details>
|
362
|
-
<summary><i>Expand instructions</i></summary>
|
363
|
-
|
364
|
-
#### Quick Start
|
365
|
-
|
366
|
-
Importing the bundled utility functions and classes can be done like so:
|
367
|
-
|
368
|
-
```py
|
369
|
-
from matplotlib_map_utils.utils import USA
|
370
|
-
```
|
371
|
-
|
372
|
-
As of `v2.1.0`, there is only one utility class available: `USA`, an object to help quickly filter for subsets of US states and territories. This utility class is still in beta, and might change.
|
373
|
-
|
374
|
-
An example:
|
375
|
-
|
376
|
-
```python
|
377
|
-
# Loading the object
|
378
|
-
usa = USA()
|
379
|
-
# Getting a list FIPS codes for US States
|
380
|
-
usa.filter(states=True, to_return="fips")
|
381
|
-
# Getting a list of State Names for states in the South and Midwest regions
|
382
|
-
usa.filter(region=["South","Midwest"], to_return="name")
|
383
|
-
```
|
384
|
-
|
385
|
-
Refer to `docs\howto_utils` for details on how to use this class, including with `pandas.apply()`.
|
386
|
-
|
387
|
-
</details>
|
388
|
-
|
389
|
-
---
|
390
|
-
|
391
|
-
### 📝 Development Notes
|
392
|
-
|
393
|
-
#### Inspiration and Thanks
|
394
|
-
|
395
|
-
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.
|
396
|
-
|
397
|
-
Two more projects assisted with the creation of this script:
|
398
|
-
|
399
|
-
* [`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.
|
400
|
-
|
401
|
-
* [`Cartopy`](https://github.com/SciTools/cartopy/issues/2361) fixed an issue inherent to calling `.copy()` on `CRS` objects.
|
402
|
-
|
403
|
-
#### Releases
|
404
|
-
|
405
|
-
<details>
|
406
|
-
<summary><i>See prior release notes</i></summary>
|
407
|
-
|
408
|
-
- `v1.0.x`: Initial releases featuring the North Arrow element, along with some minor bug fixes.
|
409
|
-
|
410
|
-
- `v2.0.0`: Initial release of the Scale Bar element.
|
411
|
-
|
412
|
-
- `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).
|
413
|
-
|
414
|
-
- `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.
|
415
|
-
|
416
|
-
- `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.
|
417
|
-
|
418
|
-
</details>
|
419
|
-
<br>
|
420
|
-
|
421
|
-
- `v3.0.0`: Release of inset map and extent and detail indicator classes and functions.
|
422
|
-
|
423
|
-
- `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).
|
424
|
-
|
425
|
-
- `v3.1.0`: Overhauled the functionality for specifying the the length of a scale bar, including support for custom units/projections (similar to `matplotlib-scalebar`'s `dx` argument) and to specify the length of a major division instead of the entire scale bar, as requested [here](https://github.com/moss-xyz/matplotlib-map-utils/issues/10). Added ability to set artist-level `zorder` variables for all elements, with both the function and class method approaches, as requested [here](https://github.com/moss-xyz/matplotlib-map-utils/issues/9) and [here](https://github.com/moss-xyz/matplotlib-map-utils/issues/10). Also fixed a bug related to custom division labels on the scale bar.
|
426
|
-
|
427
|
-
#### Future Roadmap
|
428
|
-
|
429
|
-
With the release of `v3.x`, this project has achieved full coverage of the "main" map elements I think are necessary.
|
430
|
-
|
431
|
-
<details>
|
432
|
-
<summary><i>If I continue development of this project, I will be looking to add or fix the following features:</i></summary>
|
433
|
-
|
434
|
-
* For all: switch to a system based on Pydantic for easier type validation
|
435
|
-
|
436
|
-
* **North Arrow:**
|
437
|
-
|
438
|
-
* Copy the image-rendering functionality of the Scale Bar to allow for rotation of the entire object, label and arrow together
|
439
|
-
|
440
|
-
* Create more styles for the arrow, potentially including a compass rose and a line-only arrow
|
441
|
-
|
442
|
-
* **Scale Bar:**
|
443
|
-
|
444
|
-
* Allow for custom unit definitions (instead of just metres/feet/miles/kilometres/etc.), so that the scale bar can be used on arbitrary plots (such as inches/cm/mm, mathmatical plots, and the like)
|
445
|
-
|
446
|
-
* Fix/improve the `dual_bars()` function, which currently doesn't work great with rotations
|
447
|
-
|
448
|
-
* Clean up the variable naming scheme (consistency on `loc` vs `position`, `style` vs `type`, etc.)
|
449
|
-
|
450
|
-
* Create more styles for the bar, potentially including dual boxes and a sawtooth bar
|
451
|
-
|
452
|
-
* **Inset Map:**
|
453
|
-
|
454
|
-
* Clean up the way that connectors are drawn for detail indicators
|
455
|
-
|
456
|
-
* New functionality for placing multiple inset maps at once (with context-aware positioning to prevent overlap with each other)
|
457
|
-
|
458
|
-
* **Utils:**
|
459
|
-
|
460
|
-
* (USA): Stronger fuzzy search mechanics, so that it will accept flexible inputs for FIPS/abbr/name
|
461
|
-
|
462
|
-
* (USA): More integrated class types to allow for a more fully-formed object model (USA being a `Country`, with subclasses related to `State` and `Territory` that have their own classes of attributes, etc.)
|
463
|
-
|
464
|
-
* (USA): Stronger typing options, so you don't have to recall which `region` or `division` types are available, etc.
|
465
|
-
|
466
|
-
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!
|
467
|
-
|
468
|
-
</details>
|
469
|
-
|
470
|
-
#### Support and Contributions
|
471
|
-
|
472
|
-
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!
|
473
|
-
|
474
|
-
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.
|
475
|
-
|
476
|
-
I am open to contributions, especially to help tackle the roadmap above!
|
477
|
-
|
478
|
-
---
|
479
|
-
|
480
|
-
### ⚖️ License
|
481
|
-
|
482
|
-
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.
|
File without changes
|
{matplotlib_map_utils-3.1.0.dist-info → matplotlib_map_utils-3.1.1.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|