Geotiles and Partitioning

Operations with Single Objects

The HERE Geotiles package offers a collection of utility functions to help you operate with data that is partitioned using the HERETile tiling scheme. The terms "tile" and "tile ID" equate to the integer (long) key of a HERE tile as described in reference above.

Capabilities include:

  • Finding tile that contains a given geographic point
  • Finding all tiles partially or wholly included inside a given bounding box
  • Finding all tiles partially or wholly included inside a given Shapely geometry
  • Obtaining list of ancestor and descendant tiles
  • Obtaining list of neighboring tiles
  • Retrieving the boundary of a given tile
  • Checking if given tile is a descendant or parent of another
  • Checking validity of a tile ID

See examples, below. For details of all methods, see the API documentation.

Notes

  1. When dealing with latitude/longitude coordinate pairs, all methods take longitude as the first argument. This is in keeping with the conventions used by Shapely.

  2. Tile ID values can be given as either strings or integers, both will work.

Importing the library:

import here.geotiles.heretile as ht
from shapely.geometry import Polygon

Finding one tile, given WGS-84 coordinates:

# Which level 10 tile contains point 41.88429530213, -87.63881888707832?
tile10 = ht.from_coordinates(-87.63881888707832, 41.88429530213, 10)
print(tile10)
1255998

Finding descendant tiles:

# List all of tile10's level 12 descendants
for i in ht.descendants(tile10, 12):
    print(i)
20095968
20095969
20095972
20095973
20095970
20095971
20095974
20095975
20095976
20095977
20095980
20095981
20095978
20095979
20095982
20095983

Obtaining the polygon of a tile:

# Get the boundary of tile10 as a Shapely Polygon
print(ht.get_polygon(tile10))
POLYGON ((-87.5390625 41.8359375, -87.5390625 42.1875, -87.890625 42.1875, -87.890625 41.8359375, -87.5390625 41.8359375))

Find all tiles within a bounding box:

west = 13.41
east = 13.49
south = 52.50
north = 52.54
print( list(ht.in_bounding_box(west=west, south=south, east=east, north=north, level=12)) )
[23618402, 23618403]

Get the boundary of tile10 as a Shapely Polygon

print(ht.get_polygon(tile10))
POLYGON ((-87.5390625 41.8359375, -87.5390625 42.1875, -87.890625 42.1875, -87.890625 41.8359375, -87.5390625 41.8359375))

Vectorized Operations

Analogous methods operating with (Geo)DataFrames instead of single objects are available in the here-geopandas_adapter.geotiles package. This subpackage will be included if you install here-geopandas_adapter. See the API documentation for details.

results matching ""

    No results matching ""