Skip to main content

A user-friendly Python interface to interact with the Equi7Grid grid system

Project description

equi7grid-lite

header

No one will drive us from the paradise which EquiGrid created for us

PyPI License Black isort

The equi7grid-lite package implements a user-friendly Python interface to interact with the Equi7Grid grid system.

equi7grid-lite is an unofficial Python implementation of Equi7Grid. With this package, users can convert geographic coordinates to Equi7Grid tiles and vice versa. This implementation differs from the official version in tree key ways:

  • Quad-Tree Grid Splitting: Users are required to split the grid in a Quad-Tree fashion, meaning each grid level is divided into four tiles. For example, transitioning from level 1 to level 0 involves splitting each tile into four regular smaller tiles.

  • Revised Grid ID Encoding: The grid ID is always encoded in meters, and the reference to the tile system (e.g., "T1", "T3", "T6") is removed. Instead, tiles are dynamically defined by the min_grid_size parameter. Here is a comparison between the original Equi7Grid and equi7grid-lite:

    • 'EU500M_E036N006T6' -> 'EU2560_E4521N3011'

    Where 'EU' and 'AF' are the zones, '2560' is the min_grid_size, 'E4521' is the position in the x tile axis, and 'N3011' is the position in the y tile axis.

  • Upper Bound Level: The maximum grid level is determined as the nearest lower distance to 2_500_000 meters. This threshold serves as a limit to create the Quad-Tree grid structure.

equi7grid-lite

Please refer to the Equi7Grid repository for more information of the official implementation.

Installation

The equi7grid-lite package is available on PyPI and can be installed using pip:

pip install equi7grid-lite

Usage

The equi7grid-lite package provides a single class, Equi7Grid, which can be used to convert between geographic coordinates and Equi7Grid tiles.

from equi7grid_lite import Equi7Grid

grid_system = Equi7Grid(min_grid_size=2560)
grid_system

# Convert geographic coordinates to Equi7Grid tile
lon, lat = -79.5, -5.49
results = grid_system.lonlat2grid(lon=lon, lat=lat)

# Convert Equi7Grid tile to geographic coordinates
grid_system.grid2lonlat(grid_id=results["id"][0])
#      lon       lat        x        y
#0 -79.543717 -5.517556  5140480  6461440

The Equi7Grid class also provides a method for creating a grid of Equi7Grid tiles that cover a given bounding box.

import geopandas as gpd
from equi7grid_lite import Equi7Grid

# Define a POLYGON geometry
world_filepath = gpd.datasets.get_path('naturalearth_lowres')
world = gpd.read_file(world_filepath)
country = world[world.name == "Peru"].geometry.values[0]

# Create a grid of Equi7Grid tiles
grid_system = equi7grid_lite.Equi7GridLite(t1_tile_size=2560)
grid_system

# Create a grid of Equi7Grid tiles that cover the bounding box of the POLYGON geometry
grid = grid_system.create_grid(
    level=8,
    zone="SA",
    mask=polygon, # Only include tiles that intersect the polygon
    coverland=True # Only include tiles with landmasses    
)

# Export the grid to a GeoDataFrame
grid.to_file("grid.shp")

By running create_grid with different levels, you can obtain for any region its corresponding Equi7Grid Quad-Tree grid structure.

grid

Obtain the metadata of each Equi7Grid zone:

from equi7grid_lite import Equi7Grid

# Zones: SA, EU, AF, AS, NA, AU
Equi7Grid.SA

Each zone has the following attributes:

  • id: The zone ID code.
  • crs: The WKT representation of the CRS.
  • geometry_geo: The geometry of the zone in EPSG:4326.
  • geometry_equi7grid: The geometry of the zone in the Equi7Grid CRS.
  • bbox_geo: The bounding box of the zone in EPSG:4326.
  • bbox_equi7grid: The bounding box of the zone in the Equi7Grid CRS.
  • landmasses_equi7grid: The landmasses of the zone in the Equi7Grid CRS.

License

This package is released under the MIT License. For more information, see the LICENSE file.

Contributing

Contributions are welcome! For bug reports or feature requests, please open an issue on GitHub. For contributions, please submit a pull request with a detailed description of the changes.

Citation

This is a simple adaptation of the Equi7Grid paper and code. If you use this package in your research, please consider citing the original Equi7Grid package and paper.

Package:

@software{bernhard_bm_2023_8252376,
  author       = {Bernhard BM and
                  Sebastian Hahn and
                  actions-user and
                  cnavacch and
                  Manuel Schmitzer and
                  shochsto and
                  Senmao Cao},
  title        = {TUW-GEO/Equi7Grid: v0.2.4},
  month        = aug,
  year         = 2023,
  publisher    = {Zenodo},
  version      = {v0.2.4},
  doi          = {10.5281/zenodo.8252376},
  url          = {https://doi.org/10.5281/zenodo.8252376}
}

Paper:

@article{BAUERMARSCHALLINGER201484,
title = {Optimisation of global grids for high-resolution remote sensing data},
journal = {Computers & Geosciences},
volume = {72},
pages = {84-93},
year = {2014},
issn = {0098-3004},
doi = {https://doi.org/10.1016/j.cageo.2014.07.005},
url = {https://www.sciencedirect.com/science/article/pii/S0098300414001629},
author = {Bernhard Bauer-Marschallinger and Daniel Sabel and Wolfgang Wagner},
keywords = {Remote sensing, High resolution, Big data, Global grid, Projection, Sampling, Equi7 Grid}
}

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

equi7grid_lite-0.2.0.tar.gz (6.9 MB view details)

Uploaded Source

Built Distribution

equi7grid_lite-0.2.0-py3-none-any.whl (6.9 MB view details)

Uploaded Python 3

File details

Details for the file equi7grid_lite-0.2.0.tar.gz.

File metadata

  • Download URL: equi7grid_lite-0.2.0.tar.gz
  • Upload date:
  • Size: 6.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/7.0.1 keyring/24.3.1 pkginfo/1.9.6 readme-renderer/34.0 requests-toolbelt/1.0.0 requests/2.31.0 rfc3986/1.5.0 tqdm/4.66.1 urllib3/2.2.1 CPython/3.10.12

File hashes

Hashes for equi7grid_lite-0.2.0.tar.gz
Algorithm Hash digest
SHA256 98214fd28d0811475967f7ebb48d152d6ab7629148be1a2b09425f177b7874dd
MD5 0b864ca9f62466b221a01a2f2ed3459c
BLAKE2b-256 998951df638ec9a085e17f646158908fc98030d91885423cc254a9574badaf6d

See more details on using hashes here.

File details

Details for the file equi7grid_lite-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: equi7grid_lite-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/7.0.1 keyring/24.3.1 pkginfo/1.9.6 readme-renderer/34.0 requests-toolbelt/1.0.0 requests/2.31.0 rfc3986/1.5.0 tqdm/4.66.1 urllib3/2.2.1 CPython/3.10.12

File hashes

Hashes for equi7grid_lite-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2293f629554c115ec3a57dbba2a1e07f710f41e906ba824d8a5312727d13525
MD5 3930ea40a019abd3f5862e3d22727c87
BLAKE2b-256 74cb063b2aa7a95328a179ae4fca40c2df69b5a9858dddb9d8deaabb994835e8

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