Skip to main content

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): If True, 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


Download files

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

Source Distribution

geosquare_grid-1.0.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

geosquare_grid-1.0.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file geosquare_grid-1.0.0.tar.gz.

File metadata

  • Download URL: geosquare_grid-1.0.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

Hashes for geosquare_grid-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8e13ee2c1b3223cbb78b9a94a5b8146dd9943b1716162a4e0c209f1950a879aa
MD5 6b8c52116d318b688881eb7e43592ab7
BLAKE2b-256 835c2812068e84c1e951eb0b136359fc5331ddaa206a923dac59bb971b3b303e

See more details on using hashes here.

Provenance

The following attestation bundles were made for geosquare_grid-1.0.0.tar.gz:

Publisher: python-publish.yml on geosquareai/geosquare-grid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file geosquare_grid-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: geosquare_grid-1.0.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

Hashes for geosquare_grid-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c6e8a89e9b67cd80111f7a2d3860d89a85d7018a9c756888c755d6701c8bf68
MD5 fac333e436b3a45bd009e63f58865c4f
BLAKE2b-256 8370476056b7e0d51826fbc316537e01b6f58a161a26945d367a71a0a712437b

See more details on using hashes here.

Provenance

The following attestation bundles were made for geosquare_grid-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on geosquareai/geosquare-grid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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