A library for converting geographic coordinates to grid identifiers (GIDs) and performing spatial operations.
Project description
Geosquare Grid
Geosquare Grid is a Python library that provides methods for converting between geographic coordinates (longitude and latitude) and grid identifiers (GIDs). It also includes functionality for spatial operations and geometry handling, making it a useful tool for geospatial analysis and mapping applications.
Features
- Convert longitude/latitude to GID and vice versa.
- Retrieve bounds for grid cells.
- Get geometries for grid cells.
- Find all grid cells that overlap with specified geometries.
- Easy integration with QGIS for geospatial applications.
Installation
You can install the Geosquare Grid library using pip:
pip install geosquare-grid
Usage
Here is a simple example of how to use the Geosquare Grid library:
from geosquare_grid import GeosquareGrid
# Initialize the GeosquareGrid object
grid = GeosquareGrid()
# Convert longitude and latitude to GID
gid = grid.lonlat_to_gid(longitude=106.8938638928753022, latitude=-6.2608983083383016, level=5)
print(f"GID: {gid}")
# Convert GID back to longitude and latitude
longitude, latitude = grid.gid_to_lonlat(gid)
print(f"Longitude: {longitude}, Latitude: {latitude}")
# Get bounds for the grid cell
bounds = grid.get_bounds()
print(f"Bounds: {bounds}")
Methods
lonlat_to_gid
Converts geographic coordinates to a geospatial grid identifier (GID).
Parameters:
longitude(float): Longitude in decimal degrees (-180 to 180).latitude(float): Latitude in decimal degrees (-90 to 90).level(int): Precision level (1-14).
Returns:
str: Grid identifier.
gid_to_lonlat
Converts a grid ID to geographic coordinates.
Parameters:
gid(str): Grid identifier.
Returns:
Tuple[float, float]: Longitude and latitude of the grid cell's lower-left corner.
gid_to_bound
Converts a grid ID to its geographical bounds.
Parameters:
gid(str): Grid identifier.
Returns:
Tuple[float, float, float, float]: Bounding box(min_longitude, min_latitude, max_longitude, max_latitude).
get_bounds
Returns the geographic boundary of the grid cell.
Returns:
Tuple[float, float, float, float]: Bounding box(min_longitude, min_latitude, max_longitude, max_latitude).
polyfill
Finds all grid cells that intersect with a polygon.
Parameters:
geometry(Polygon): Polygon geometry to fill.size(Union[int, List[int]]): Grid cell size or range of sizes.start(str): Starting cell identifier (default: "2").fullcover(bool): IfTrue, only fully contained cells are returned.
Returns:
List[str]: List of grid cell identifiers.
Documentation
For more detailed documentation, including advanced usage and API reference, please refer to the docs.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geosquare_grid-0.1.0.tar.gz.
File metadata
- Download URL: geosquare_grid-0.1.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbff6922a58caaa3517096fbc80f525d234e22c3f2254e378a78889634931c39
|
|
| MD5 |
516044d0a69b1e69325c6258c46145ed
|
|
| BLAKE2b-256 |
5a5dab6c5800306ecb7f623891c0df12eab9d0329e75661d9d71ddf26761d33d
|
Provenance
The following attestation bundles were made for geosquare_grid-0.1.0.tar.gz:
Publisher:
python-publish.yml on geosquareai/geosquare-grid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geosquare_grid-0.1.0.tar.gz -
Subject digest:
cbff6922a58caaa3517096fbc80f525d234e22c3f2254e378a78889634931c39 - Sigstore transparency entry: 233791937
- Sigstore integration time:
-
Permalink:
geosquareai/geosquare-grid@69b9a3c75ab4bebf0434491afc5cab0f006ec216 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/geosquareai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@69b9a3c75ab4bebf0434491afc5cab0f006ec216 -
Trigger Event:
release
-
Statement type:
File details
Details for the file geosquare_grid-0.1.0-py3-none-any.whl.
File metadata
- Download URL: geosquare_grid-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8be2a453d8cdcd94540a41342d24361e27ced49250e37a58b0e00348d357986e
|
|
| MD5 |
fa8707c05867f2b4ec8a2b5eadbcedaa
|
|
| BLAKE2b-256 |
c334290b55d02cc102ee15e7b0bc088d984ec80f3e3fc768fa499bdc7db8db89
|
Provenance
The following attestation bundles were made for geosquare_grid-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on geosquareai/geosquare-grid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geosquare_grid-0.1.0-py3-none-any.whl -
Subject digest:
8be2a453d8cdcd94540a41342d24361e27ced49250e37a58b0e00348d357986e - Sigstore transparency entry: 233791942
- Sigstore integration time:
-
Permalink:
geosquareai/geosquare-grid@69b9a3c75ab4bebf0434491afc5cab0f006ec216 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/geosquareai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@69b9a3c75ab4bebf0434491afc5cab0f006ec216 -
Trigger Event:
release
-
Statement type: