Contains the bounding boxes and miscallaneous additional information for countries extracted from
http://www.naturalearthdata.com/
Note that many countries have a number of “subunits”: geographically disjoint components like Alaska in the USA, administratively distinct regions such as the countries of Great Britain, or overseas islands for many European nations. As a result this module returns iterators over sets of Country objects for each country code, rather than single Country objects.
Previous versions of this library returned an (often large) singular bounding box for each country code; in many cases these spanned much of the globe and were therefore geographically less useful.
Installation
$ pip install country-bounding-boxes
Usage
>>> from country_bounding_boxes import (
country_subunits_containing_point,
country_subunits_by_iso_code
)
Get a country by its 2- or 3-letter ISO code:
>>> [c.name for c in country_subunits_by_iso_code('ZW')]
['Zimbabwe']
>>> [c.name for c in country_subunits_by_iso_code('ZWE')]
['Zimbabwe']
>>> [c.name for c in country_subunits_by_iso_code('TM')]
['Turkmenistan']
>>> [c.name for c in country_subunits_by_iso_code('GB')]
['Wales', 'England', 'N. Ireland', 'Scotland']
Inspect bounding box as (lon1, lat1, lon2, lat2) tuples:
>>> [c.bbox for c in country_subunits_by_iso_code('TM')]
[(52.5024597512, 35.2706639674, 66.5461503437, 42.7515510117)]
>>> [c.bbox for c in country_subunits_by_iso_code('GB')]
[(-5.2623046875, 51.3904296875, -2.6623046875, 53.4192871094),
(-5.65625, 50.0213867188, 1.74658203125, 55.8079589844),
(-8.14482421875, 54.0512695312, -5.47041015625, 55.241796875),
(-7.54296875, 54.689453125, -0.774267578125, 60.8318847656)]
Get a set of countries by their intersection with a point:
>>> [c.name for c in
country_subunits_containing_point(lon=-79.888252,
lat=32.819747)]
['U.S.A.']
>>> [c.name for c in
country_subunits_containing_point(lon=5.983333,
lat=50.883333)]
['Germany', 'France', 'Netherlands']
Development
If you want to do development on the library, follow these steps:
Create a virtualenv
bin/pip install -r requirements/tests.txt
bin/nosetests -s country_bounding_boxes
Metadata
Release files for country-bounding-boxes 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| country-bounding-boxes-0.2.3.tar.gz | 61.3 kB | Without provenance | Details |
Release files / country-bounding-boxes-0.2.3.tar.gz
| Download URL | country-bounding-boxes-0.2.3.tar.gz |
|---|---|
| Size | 61.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bbd1f4b029a0c2aa33a69eb4922e908f5af561221d08eeb7b7de4677705e5426
|
|
BLAKE2b-256 checksum How to use checksums |
984622750bd08b3296d0fceb01a1c73ff20c9f565626cb6bceb9d8829d641519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for country-bounding-boxes 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.