latlng-to-state
Quickly find U.S. states or regions from latitude/longitude coordinates using built-in geospatial data. latlng-to-state is a lightweight Python package for geospatial point-in-geometry analysis. It enables you to determine whether a given latitude/longitude point falls within or intersects any polygon geometry — such as U.S. states or other regions.
The package includes built-in datasets for:
- 🗺️ U.S. state geometries (from U.S. Census)
- 📍 U.S. ZIP code centroids (from U.S. Census)
It works seamlessly with GeoPandas and shapely, making it easy to integrate spatial logic into data pipelines, geocoding workflows, and location-based applications.
Disclaimer: This repository is primarily for tutorial and example purposes, demonstrating PyPI package development and GitHub Actions workflows.
🔧 Features
- 🗺️ Spatial Lookup: Determine if a lat/lng point is contained within or intersects with a polygon (e.g., a U.S. state).
- 📦 Built-in Data: Includes preloaded U.S. state geometries and U.S zip codes (as a
.parquetfile). - 🧪 Clean API: Simple utility functions for integrating geospatial logic into your own workflows.
- 🧱 Modular Design: Organized into utilities and core logic for easy extension.
📦 Installation & Dependencies
pip install latlng-to-state
Requires Python ≥ 3.9
This will automatically install the necessary dependencies, including:
geopandasshapelypandaspyarrow
🚀 Quickstart
import geopandas as gpd
from latlng_to_state.datasets import load_us_state_geometry
from latlng_to_state.core.lookup import lookup_geometry_by_point
# Load built-in U.S. state geometries
gdf = load_us_state_geometry()
# Sample lat/lng in Texas
lat, lng = 31.9686, -99.9018
# Lookup state name
state_name = lookup_geometry_by_point(lat, lng, gdf, check_type="contain", return_col="state")
print(state_name) # Output: Texas
lookup_geometry_by_point
lookup_geometry_by_point(
lat: float,
lng: float,
gdf: geopandas.GeoDataFrame,
check_type: Optional[str] = None,
return_col: str = "NAME"
) -> Optional[Union[str, int, float]]
Check whether a given lat/lng point falls inside or intersects with any geometry in a GeoDataFrame.
lat,lng: Coordinates of the point.gdf: AGeoDataFramecontaining geometries (e.g., U.S. states).check_type:"contain","intersect", orNone(tries contain then intersect).return_col: Column to return (e.g.,"NAME"for state name).
Returns the matched value from the return_col column, or None if no match.
load_us_state_geometry
from latlng_to_state.datasets import (
load_us_state_geometry
, load_us_zipcode_centroid
)
gdf = load_us_state_geometry()
Loads the built-in U.S. state geometry data as a GeoDataFrame.
📁 Included Data
The package includes:
- A U.S. state geometry and U.S. zipcode centroid dataset (in
parquetformat) bundled underlatlng_to_state/datasets/data.
💡 Data Source Disclosure
The U.S. state geometries and zipcode centroid data included in this package are sourced from the U.S. Census Bureau and are in the public domain. While efforts have been made to ensure data accuracy, this package is provided "as is" without any warranties. Users should verify the data suitability for their specific applications.
📄 License
This project is licensed under the MIT License.
🧑💻 Contributing
Contributions welcome! Feel free to open issues or submit PRs on GitHub.
Metadata
Release files for latlng-to-state 0.0.1
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 | Actions |
|---|---|---|---|---|
| latlng_to_state-0.0.1.tar.gz | 5.1 MB | With provenance | Details for latlng_to_state-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| latlng_to_state-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for latlng_to_state-0.0.1-py3-none-any.whl |
Total release size: 10.2 MB
Release files / latlng_to_state-0.0.1.tar.gz
| Download URL | latlng_to_state-0.0.1.tar.gz |
|---|---|
| Size | 5.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd501958dfb3d6c4c217b9c1212696b718c8d77e3c3f247592f8330bd4ae09fe
|
|
BLAKE2b-256 checksum How to use checksums |
dfd477c692ac4f6ba68ae3cd6291711c1310196e888bbce57f0d2725819275b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2025.
Transparency logRelease files / latlng_to_state-0.0.1-py3-none-any.whl
| Download URL | latlng_to_state-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c15655ed0bd7e01f39698ebb24fa3abda2c0b73357347ac98de000ad4a4129e1
|
|
BLAKE2b-256 checksum How to use checksums |
80c070b88d76c8eacbd7b15f5b352057354bcb94e8aa751487c81d4946f921e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2025.
Transparency logSecurity for latlng-to-state 0.0.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for latlng_to_state-0.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2025.
Transparency logA 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.