matplotlib-map-utils 2.0.1__tar.gz → 2.1.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.
Files changed (26) hide show
  1. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/PKG-INFO +59 -8
  2. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/README.md +55 -5
  3. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/core/scale_bar.py +3 -3
  4. matplotlib_map_utils-2.1.0/matplotlib_map_utils/utils/__init__.py +3 -0
  5. matplotlib_map_utils-2.1.0/matplotlib_map_utils/utils/usa.json +1038 -0
  6. matplotlib_map_utils-2.1.0/matplotlib_map_utils/utils/usa.py +336 -0
  7. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils.egg-info/PKG-INFO +59 -8
  8. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils.egg-info/SOURCES.txt +3 -0
  9. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/pyproject.toml +5 -2
  10. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/LICENSE +0 -0
  11. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/__init__.py +0 -0
  12. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/core/__init__.py +0 -0
  13. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/core/north_arrow.py +0 -0
  14. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/defaults/__init__.py +0 -0
  15. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/defaults/north_arrow.py +0 -0
  16. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/defaults/scale_bar.py +0 -0
  17. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/scratch/map_utils.py +0 -0
  18. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/scratch/north_arrow_old_classes.py +0 -0
  19. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/validation/__init__.py +0 -0
  20. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/validation/functions.py +0 -0
  21. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/validation/north_arrow.py +0 -0
  22. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils/validation/scale_bar.py +0 -0
  23. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils.egg-info/dependency_links.txt +0 -0
  24. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils.egg-info/requires.txt +0 -0
  25. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/matplotlib_map_utils.egg-info/top_level.txt +0 -0
  26. {matplotlib_map_utils-2.0.1 → matplotlib_map_utils-2.1.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: matplotlib-map-utils
3
- Version: 2.0.1
3
+ Version: 2.1.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,12 +8,13 @@ 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
- Requires-Python: >=3.9
11
+ Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: matplotlib>=3.9.0
15
15
  Requires-Dist: cartopy>=0.23.0
16
16
  Requires-Dist: great-circle-calculator>=1.3.1
17
+ Dynamic: license-file
17
18
 
18
19
  # matplotlib-map-utils
19
20
 
@@ -29,12 +30,14 @@ Requires-Dist: great-circle-calculator>=1.3.1
29
30
 
30
31
  `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/).
31
32
 
32
- As of `v2.x` (the current version), this includes two tools:
33
+ As of `v2.x` (the current version), this includes two tools and one utility:
33
34
 
34
35
  * `north_arrow.py`, which generates a high quality, context-aware north arrow for a given plot.
35
36
 
36
37
  * `scale_bar.py`, which generates a high quality, context-aware scale bar to a given plot.
37
38
 
39
+ * `usa.py`, which contains a class that helps filter for states and territories within the USA based on given characteristics.
40
+
38
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.
39
42
 
40
43
  ---
@@ -49,11 +52,11 @@ pip install matplotlib-map-utils
49
52
 
50
53
  The requirements for this package are:
51
54
 
52
- * `python >= 3.9.0` (due to the dictionary-concatenation method utilized)
55
+ * `python >= 3.10` (due to the use of the pipe operator to concatenate dictionaries and types)
53
56
 
54
- * `matplotlib >= 3.9.0` (might work with lower versions but not guaranteed)
57
+ * `matplotlib >= 3.9` (might work with lower versions but not guaranteed)
55
58
 
56
- * `cartopy >= 0.23.0` (due to earlier bug with calling `copy()` on `CRS` objects)
59
+ * `cartopy >= 0.23` (due to earlier bug with calling `copy()` on `CRS` objects)
57
60
 
58
61
  ---
59
62
 
@@ -78,6 +81,10 @@ package_name/
78
81
  │ ├── __init__.py
79
82
  │ ├── north_arrow.py
80
83
  │ └── scale_bar.py
84
+ ├── utils/
85
+ │ ├── __init__.py
86
+ │ ├── usa.py
87
+ │ └── usa.json
81
88
  ```
82
89
 
83
90
  Where:
@@ -230,6 +237,38 @@ Refer to `docs\howto_scale_bar` for details on how to customize each facet of th
230
237
 
231
238
  ---
232
239
 
240
+ ### Utilities
241
+
242
+ <details>
243
+ <summary><i>Expand instructions</i></summary>
244
+
245
+ #### Quick Start
246
+
247
+ Importing the bundled utility functions and classes can be done like so:
248
+
249
+ ```py
250
+ from matplotlib_map_utils.utils import USA
251
+ ```
252
+
253
+ 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.
254
+
255
+ An example:
256
+
257
+ ```python
258
+ # Loading the object
259
+ usa = USA()
260
+ # Getting a list FIPS codes for US States
261
+ usa.filter(states=True, to_return="fips")
262
+ # Getting a list of State Names for states in the South and Midwest regions
263
+ usa.filter(region=["South","Midtwest"], to_return="name")
264
+ ```
265
+
266
+ Refer to `docs\howto_utils` for details on how to use this class, including with `pandas.apply()`.
267
+
268
+ </details>
269
+
270
+ ---
271
+
233
272
  ### Development Notes
234
273
 
235
274
  #### Inspiration and Thanks
@@ -246,6 +285,10 @@ Two more projects assisted with the creation of this script:
246
285
 
247
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).
248
287
 
288
+ - `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
+
290
+ - `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
+
249
292
  #### Future Roadmap
250
293
 
251
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.
@@ -268,7 +311,15 @@ If I continue development of this project, I will be looking to add or fix the f
268
311
 
269
312
  * Create more styles for the bar, potentiallly including dual boxes and a sawtooth bar
270
313
 
271
- 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 and coverting FIPS codes.
314
+ * **Utils:**
315
+
316
+ * (USA): Stronger fuzzy search mechanics, so that it will accept flexible inputs for FIPS/abbr/name
317
+
318
+ * (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.)
319
+
320
+ * (USA): Stronger typing options, so you don't have to recall which `region` or `division` types are available, etc.
321
+
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.
272
323
 
273
324
  I am also open to ideas for other extensions to create!
274
325
 
@@ -12,12 +12,14 @@
12
12
 
13
13
  `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
14
 
15
- As of `v2.x` (the current version), this includes two tools:
15
+ As of `v2.x` (the current version), this includes two tools and one utility:
16
16
 
17
17
  * `north_arrow.py`, which generates a high quality, context-aware north arrow for a given plot.
18
18
 
19
19
  * `scale_bar.py`, which generates a high quality, context-aware scale bar to a given plot.
20
20
 
21
+ * `usa.py`, which contains a class that helps filter for states and territories within the USA based on given characteristics.
22
+
21
23
  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.
22
24
 
23
25
  ---
@@ -32,11 +34,11 @@ pip install matplotlib-map-utils
32
34
 
33
35
  The requirements for this package are:
34
36
 
35
- * `python >= 3.9.0` (due to the dictionary-concatenation method utilized)
37
+ * `python >= 3.10` (due to the use of the pipe operator to concatenate dictionaries and types)
36
38
 
37
- * `matplotlib >= 3.9.0` (might work with lower versions but not guaranteed)
39
+ * `matplotlib >= 3.9` (might work with lower versions but not guaranteed)
38
40
 
39
- * `cartopy >= 0.23.0` (due to earlier bug with calling `copy()` on `CRS` objects)
41
+ * `cartopy >= 0.23` (due to earlier bug with calling `copy()` on `CRS` objects)
40
42
 
41
43
  ---
42
44
 
@@ -61,6 +63,10 @@ package_name/
61
63
  │ ├── __init__.py
62
64
  │ ├── north_arrow.py
63
65
  │ └── scale_bar.py
66
+ ├── utils/
67
+ │ ├── __init__.py
68
+ │ ├── usa.py
69
+ │ └── usa.json
64
70
  ```
65
71
 
66
72
  Where:
@@ -213,6 +219,38 @@ Refer to `docs\howto_scale_bar` for details on how to customize each facet of th
213
219
 
214
220
  ---
215
221
 
222
+ ### Utilities
223
+
224
+ <details>
225
+ <summary><i>Expand instructions</i></summary>
226
+
227
+ #### Quick Start
228
+
229
+ Importing the bundled utility functions and classes can be done like so:
230
+
231
+ ```py
232
+ from matplotlib_map_utils.utils import USA
233
+ ```
234
+
235
+ 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.
236
+
237
+ An example:
238
+
239
+ ```python
240
+ # Loading the object
241
+ usa = USA()
242
+ # Getting a list FIPS codes for US States
243
+ usa.filter(states=True, to_return="fips")
244
+ # Getting a list of State Names for states in the South and Midwest regions
245
+ usa.filter(region=["South","Midtwest"], to_return="name")
246
+ ```
247
+
248
+ Refer to `docs\howto_utils` for details on how to use this class, including with `pandas.apply()`.
249
+
250
+ </details>
251
+
252
+ ---
253
+
216
254
  ### Development Notes
217
255
 
218
256
  #### Inspiration and Thanks
@@ -229,6 +267,10 @@ Two more projects assisted with the creation of this script:
229
267
 
230
268
  - `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).
231
269
 
270
+ - `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
+
272
+ - `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
+
232
274
  #### Future Roadmap
233
275
 
234
276
  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.
@@ -251,7 +293,15 @@ If I continue development of this project, I will be looking to add or fix the f
251
293
 
252
294
  * Create more styles for the bar, potentiallly including dual boxes and a sawtooth bar
253
295
 
254
- 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 and coverting FIPS codes.
296
+ * **Utils:**
297
+
298
+ * (USA): Stronger fuzzy search mechanics, so that it will accept flexible inputs for FIPS/abbr/name
299
+
300
+ * (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.)
301
+
302
+ * (USA): Stronger typing options, so you don't have to recall which `region` or `division` types are available, etc.
303
+
304
+ 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.
255
305
 
256
306
  I am also open to ideas for other extensions to create!
257
307
 
@@ -679,7 +679,7 @@ def _config_bar(ax, bar):
679
679
  # If the provided units are in degrees, we will convert to meters first
680
680
  # This will recalculate the ax_range
681
681
  if units_proj=="degree":
682
- warnings.warn(f"Provided CRS {bar["projection"]} uses degrees. An attempt will be made at conversion, but there will be accuracy issues: it is recommended that you use a projected CRS instead.")
682
+ warnings.warn(f"Provided CRS {bar['projection']} uses degrees. An attempt will be made at conversion, but there will be accuracy issues: it is recommended that you use a projected CRS instead.")
683
683
  ylim = ax.get_ylim()
684
684
  xlim = ax.get_xlim()
685
685
  # Using https://github.com/seangrogan/great_circle_calculator/blob/master/great_circle_calculator/great_circle_calculator.py
@@ -706,7 +706,7 @@ def _config_bar(ax, bar):
706
706
  try:
707
707
  units_user = sbt.units_standard.get(bar["unit"])
708
708
  except:
709
- warnings.warn(f"Desired output units selected by user ({bar["unit"]}) are considered invalid; please use one of the units specified in the units_standard dictionary in defaults.py")
709
+ warnings.warn(f"Desired output units selected by user ({bar['unit']}) are considered invalid; please use one of the units specified in the units_standard dictionary in defaults.py")
710
710
  units_user = None
711
711
 
712
712
  # Converting
@@ -749,7 +749,7 @@ def _config_bar(ax, bar):
749
749
  if bar["length"] < ax_dim:
750
750
  bar_max = (bar["length"] / ax_dim) * ax_range
751
751
  else:
752
- warnings.warn(f"Provided bar length ({bar["length"]}) is greater than the axis length ({ax_dim}); setting bar length to default (25% of axis length).")
752
+ warnings.warn(f"Provided bar length ({bar['length']}) is greater than the axis length ({ax_dim}); setting bar length to default (25% of axis length).")
753
753
  bar_max = 0.25 * ax_range
754
754
  # If bar["max"] is provided, don't need to go through all of this effort
755
755
  else:
@@ -0,0 +1,3 @@
1
+ from .usa import USA
2
+
3
+ __all__ = ["USA"]