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.2.0.24.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for these_united_states-1.2.0.24.tar.gz
Algorithm Hash digest
SHA256 d49b3ac4cb027935dbcf6dcc33ec68362a1e53db1d04c57682521e002f6059db
MD5 1110452510381c9941cba563c36a8241
BLAKE2b-256 49eb0d666d53017f1351772cf2a75e2b2ab3d7b0c8e0bdf79adfe9666b3a5672

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for these_united_states-1.2.0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 35b8d51ec76949297cedcc96282d7614c9a3352dc9ee1e86d8d8d6f1083d1a47
MD5 b4ab2cc22bdf703eaf55c3ae8bc61265
BLAKE2b-256 9580a0201ae970f82dd8c746f46d58b80fabd5513a40d6cde4e4253a5c147e12

See more details on using hashes here.

Supported by

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