Skip to main content

Utility library for performing reverse geocoding of states in the United States of America

Project description

these-united-states

A Python library for performing reverse geocoding of the United States of America.

Overview

These-united-states provides a simple, class-based interface to shapefiles from the United States Census Bureau defining boundaries of U.S. states and territories. States may be queried via full state name, abbreviation, or by coordinates (latitude/longitude pairs). State objects contain some metadata, including the bounding box, area, and polygons defining the state's boundaries.

Example

>>> import united_states

>>> us = united_states.UnitedStates()

>>> us.from_coords(29.881888, -82.726846)
[State(abbr='FL', name='Florida', bbox=BBox(left=-87.634896, bottom=24.396307999999998, right=-79.974306, top=31.000968))]

>>> us.by_abbr['WA']
State(abbr='WA', name='Washington', bbox=BBox(left=-124.848974, bottom=45.543541, right=-116.916071, top=49.002435999999996))

>>> us.by_name['Alaska']
State(abbr='AK', name='Alaska', bbox=BBox(left=-179.231086, bottom=51.175092, right=179.859681, top=71.439786))

Command-line interface

These-united-states is also usable from the command-line, with the appropriate extras installed.

$ pip install "these-united-states[cli,plot]"

$ python -m united_states 29.881888,-82.726846
(29.881888, -82.726846)  Florida

$ python -m united_states --help
Usage: united_states [OPTIONS] [POINT]...

  Lookup U.S. states by coordinate (reverse geocoding).

Options:
  -b, --bbox / --no-bbox          Print state bounding boxes in listing
                                  (implies -l/--list).

  -d, --dc / --no-dc              Include the District of Columbia.
  -x, --exclude TEXT              Exclude states by abbreviation or name.
  -h, --help                      Show this message and exit.
  -i, --include TEXT              Include states by abbreviation or name.
  -l, --list / --no-list          List included states.
  -o, --oconus / --no-oconus      Include states outside the continental U.S.
  -p, --plot / --no-plot          Plot the results (requires matplotlib).
  -s, --seed FLOAT                Seed random number generator for color plot
                                  selection.

  -t, --territories / --no-territories
                                  Include U.S. territories.

  Options may be given multiple times. Options taking arguments are
  additive. Multiple abbreviations or names may be provided in a single
  option using a comma-separated list.

License

BSD 3-Clause license

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

these_united_states-1.1.0.21.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

these_united_states-1.1.0.21-py3-none-any.whl (9.9 MB view details)

Uploaded Python 3

File details

Details for the file these_united_states-1.1.0.21.tar.gz.

File metadata

  • Download URL: these_united_states-1.1.0.21.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.7

File hashes

Hashes for these_united_states-1.1.0.21.tar.gz
Algorithm Hash digest
SHA256 5db43c656145efafe59dbf34530ad103982ce8388ba681f0ffc19e5701008091
MD5 d541e47c12301430c617dc947173426d
BLAKE2b-256 efc91317608006b5d8c8d7f38368ab2c1d8a0096f172233d1e554f6ba1c51ef2

See more details on using hashes here.

File details

Details for the file these_united_states-1.1.0.21-py3-none-any.whl.

File metadata

  • Download URL: these_united_states-1.1.0.21-py3-none-any.whl
  • Upload date:
  • Size: 9.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.7

File hashes

Hashes for these_united_states-1.1.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 fe170bccafd50f075281fb2ec1f00aa4554daee9219ce3d0067d4de82f4fb1b8
MD5 7c3f6ecfcbf78dfc02355ca063541f32
BLAKE2b-256 7a2978c8c98c97063f51594e1b23c7462eef6e04456a856ec6fd8376f4fbce52

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page