here.geopandas_adapter.geotiles.heretile module#
Module to operate with HERETile tiling scheme using (Geo)DataFrames.
- here.geopandas_adapter.geotiles.heretile.ancestor(tile_ids: Series, level: int | None = None) Series[source]#
Return the ancestor tiles at the given level for the tiles.
Index and
NaNvalues are retained.NaNis also returned in case of invalid tile IDs or tiling level, or when the ancestor doesn’t exist.- Parameters:
tile_ids – the tile IDs
level – the tiling level
- Returns:
a
pd.Serieswith the tile IDs of the ancestors or parents, when existing- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.contains_coordinates(tile_ids: Series, lngs: Series, lats: Series) Series[source]#
Return if the tiles contains the points.
The check includes the tile boundary, aligned with the way shapely
intersectsoperates.NaNvalues or not all the series containing a value for a given index determine the resulting tile ID to beNaN.- Parameters:
tile_ids – the tile IDs
lngs – the Series with longitudes
lats – the Series with latitudes
- Returns:
a
pd.Seriescontaining if the points are inside the tiles- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.contains_geometry(tile_ids: Series, geometries: GeoSeries, fully_contained=False) Series[source]#
Return if the tiles contain the geometries.
Inclusion is modeled as the shapely relation
intersects(fully_containedis false) orcontains(otherwise) between the tile and the geometry.NaNvalues or not all the series containing a value for a given index determine the resulting tile ID to beNaN.- Parameters:
tile_ids – the tile IDs
geometries – a ``gpd.GeoSeries` with any geometric type
fully_contained – check if each geometry is fully contained in each tile
- Returns:
a
pd.Seriesof booleans, if the geometries are inside the tiles- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.contains_point(tile_ids: Series, pts: GeoSeries) Series[source]#
Return if the tiles contains the points.
This method is more efficient than
contains_geometryfor points.The check includes the tile boundary, aligned with the way shapely
intersectsoperates.NaNvalues or not all the series containing a value for a given index determine the resulting tile ID to beNaN.- Parameters:
tile_ids – the tile IDs
pts – the ``gpd.GeoSeries` with points
- Returns:
a
pd.Seriesof booleans, if the points are inside the tiles- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.descendants(tile_ids: Series, level: int | None = None) Series[source]#
Return the tile IDs of all descendants at some level for each tile.
Index and
NaNvalues are retained.NaNis also returned in place of empty lists or in case of invalid tile IDs or tiling level.Use
pd.Series.explodemethod to turn the lists into multiple rows.- Parameters:
tile_ids – the tile IDs
level – the tiling level
- Returns:
a
pd.Serieswith the list of descendants tile IDs for each tile- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.from_coordinates(lngs: Series, lats: Series, level: int) Series[source]#
Return the tiles that contain points.
Series must be indexed the same.
NaNvalues or series missing a row for some index value determine the resulting tile ID to beNaN. This is also the case if a point can’t be mapped to a tile ID.Index is retained.
- Parameters:
lngs – the Series with longitudes
lats – the Series with latitudes
level – the tiling level
- Returns:
a
Seriestile IDs,NaNwhen no tile ID can be calculated
- here.geopandas_adapter.geotiles.heretile.from_point(pts: GeoSeries, level: int) Series[source]#
Return the tiles that contain points.
NaNvalues or rows not containing a Point determine the resulting tile ID to beNaN. This is also the case if a point can’t be mapped to a tile ID.Index is retained.
- Parameters:
pts – the GeoSeries with the points
level – the tiling level
- Returns:
a
Seriestile IDs,NaNwhen no tile ID can be calculated
- here.geopandas_adapter.geotiles.heretile.from_x_y_level(xs: Series, ys: Series, levels: Series) Series[source]#
Return the tiles given X and Y components and levels.
Series must be indexed the same.
NaNvalues or series missing a row for some index value determine the resulting tile ID to beNaN. This is also the case if not tile ID corresponds to a (x, y, level) tuple.Index is retained.
- Parameters:
xs – the Series with the tile X component
ys – the Series with the tile Y component
levels – the Series with tile levels
- Returns:
a
Seriestile IDs,NaNwhen no tile ID can be calculated- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.get_boundary_ring(tile_ids: Series) GeoSeries[source]#
Return the boundary of the tiles as linear rings.
Each ring describes the boundary counter-clockwise. It contains 5 points, since a linear ring is always closed by repeating its first point.
Index and
NaNvalues are retained by returningNone.Noneare also returned in case of invalid tile IDs.- Parameters:
tile_ids – the tile IDs
- Returns:
a
gpd.GeoSeriesof linear rings- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.get_bounds(tile_ids: Series) DataFrame[source]#
Return the bounds of the tiles.
This function returns bounds following the same convention of the
boundsfunction of shapely.Index and
NaNvalues are retained.NaNare also returned in case of invalid tile IDs.- Parameters:
tile_ids – the tile IDs
- Returns:
a
DataFramewith columnswest,south,east,north.NaNwhen not applicable- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.get_center_coordinates(tile_ids: Series) DataFrame[source]#
Return the center points of the tiles.
Index and
NaNvalues are retained.NaNare also returned in case of invalid tile IDs.- Parameters:
tile_ids – the tile IDs
- Returns:
a tuple of 2
Seriescontaining longitude and latitude,NaNwhen not applicable- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.get_center_point(tile_ids: Series) GeoSeries[source]#
Return the center points of the tiles.
Index and
NaNvalues are retained by returningNone.Noneare also returned in case of invalid tile IDs.- Parameters:
tile_ids – the tile IDs
- Returns:
a
GeoSeriesof points,Nonewhen not applicable- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.get_corners(tile_ids: Series) GeoDataFrame[source]#
Return the southwestern and northeastern corners of the tiles.
Index and
NaNvalues are retained by returningNone.Noneare also returned in case of invalid tile IDs.- Parameters:
tile_ids – the tile IDs
- Returns:
a
GeoDataFramewith columnssouthwest,northeast.Nonewhen not applicable # noqa- Raises:
ValueError – in case the series doesn’t contain integers or strings # noqa
- here.geopandas_adapter.geotiles.heretile.get_level(tile_ids: Series) Series[source]#
Return the levels of the tiles.
Index and
NaNvalues are retained.NaNare also returned in case of invalid tile IDs.- Parameters:
tile_ids – the tile IDs
- Returns:
a
Seriestiling levels,NaNwhen not applicable- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.get_polygon(tile_ids: Series) GeoSeries[source]#
Return the tiles as polygons.
Index and
NaNvalues are retained by returningNone.Noneare also returned in case of invalid tile IDs.- Parameters:
tile_ids – the tile IDs
- Returns:
a
gpd.GeoSeriesof polygons- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.get_x(tile_ids: Series) Series[source]#
Return the X components of the tiles.
Index and
NaNvalues are retained.NaNare also returned in case of invalid tile IDs.- Parameters:
tile_ids – the tile IDs
- Returns:
a
Seriesof X components,NaNwhen not applicable- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.get_x_y_level(tile_ids: Series) DataFrame[source]#
Return the X and Y components and the levels of the tiles.
Index and
NaNvalues are retained.NaNare also returned in case of invalid tile IDs.Resulting
NaNvalues are removed, unlessdrop_nais set to false.- Parameters:
tile_ids – the tile IDs
- Returns:
a
DataFramewith columnsx,y,level,NaNwhen not applicable- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.get_y(tile_ids: Series) Series[source]#
Return the Y components of the tiles.
Index and
NaNvalues are retained.NaNare also returned in case of invalid tile IDs.- Parameters:
tile_ids – the tile IDs
- Returns:
a
Seriesof Y components,NaNwhen not applicable- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.in_geometry(geometries: GeoSeries, level: int, fully_contained: bool = False) Series[source]#
Return the tiles that are included in the geometries.
If
fully_containedis false, some of the returned tiles may be partially outside the geometry. Otherwise, return only the tiles wholly inside the geometry.Inclusion is modeled as the shapely relation
intersects(fully_containedis false) orcontains(otherwise) between the geometry and the tiles.Examples (
fully_containedis false): - if the geometry is a point, return one, two or four tiles - if the geometry is a line string, it return all the tiles along the line - if the geometry is a polygon, it returns all the tiles intersecting with the polygon - for multi-geometries, return the union of the tiles in each geometryExamples (
fully_containedis true): - if the geometry is a point, nothing is returned - if the geometry is a line string, nothing is returned - if the geometry is a polygon, it returns all the tiles contained in the polygon - for multi-geometries, return the union of the tiles in each geometryIndex and
NaNvalues are retained.NaNis also returned in place of empty lists.Use
pd.Series.explodemethod to turn the lists into multiple rows.- Parameters:
geometries – the GeoSeries with arbitrary geometries
level – the tiling level
fully_contained – return only tiles wholly inside the bounding box
- Returns:
a
Serieswith the list of tile IDs corresponding to each geometry, in the order of West to East first, then South to North
- here.geopandas_adapter.geotiles.heretile.in_geometry_bounds(geometries: GeoSeries, level: int, fully_contained: bool = False) Series[source]#
Return the tiles that are included in the bounds of geometries.
If
fully_containedis false, some of the returned tiles may be partially outside the bounds. Otherwise, return only the tiles wholly inside the bounds.Index and
NaNvalues are retained.NaNis also returned in place of empty lists.Use
pd.Series.explodemethod to turn the lists into multiple rows.- Parameters:
geometries – the GeoSeries with arbitrary geometries
level – the tiling level
fully_contained – return only tiles wholly inside the bounding box
- Returns:
a
Serieswith the list of tile IDs corresponding to each geometry, in the order of West to East first, then South to North
- here.geopandas_adapter.geotiles.heretile.is_contained_in_geometry(tile_ids: Series, geometries: GeoSeries, fully_contained=False) Series[source]#
Return if the tiles are contained in the geometries.
Inclusion is modeled as the shapely relation
intersects(fully_containedis false) orcontains(otherwise) between the geometry and the tile.- Parameters:
tile_ids – the tile IDs
geometries – a ``gpd.GeoSeries` with any geometric type
fully_contained – check if the tile is fully contained in the geometry
- Returns:
a
pd.Seriesof booleans, if the tiles are contained in the geometries, fully or partially- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.is_descendant(tile_ids: Series, of_tile_ids: Series) Series[source]#
Check if tiles are the direct descendant of other tiles.
Index and
NaNvalues are retained. Series should be indexed the same.- Parameters:
tile_ids – the subject tile IDs
of_tile_ids – check the relationship of the subjects with these tiles
- Returns:
a
pd.Seriescontaining if each tile is the descendant of the other tile- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.is_parent(tile_ids: Series, of_tile_ids: Series) Series[source]#
Check if tiles are the direct parents of other tiles.
Index and
NaNvalues are retained. Series should be indexed the same.- Parameters:
tile_ids – the subject tile IDs
of_tile_ids – check the relationship of the subjects with these tiles
- Returns:
a
pd.Seriescontaining if each tile is the parent of the other tile- Raises:
ValueError – in case the series doesn’t contain integers # noqa
- here.geopandas_adapter.geotiles.heretile.is_valid(tile_ids: Series) Series[source]#
Check if integers are a valid tile IDs.
Index and
NaNvalues are retained.- Parameters:
tile_ids – a Series of integers
- Returns:
a
Seriesof booleans with the result of the test- Raises:
ValueError – in case the series doesn’t contain integers # noqa
Example: >>> is_valid(pd.Series([0, 1, 2, 3, 4])) 0 False 1 True 2 False 3 False 4 True dtype: bool
- here.geopandas_adapter.geotiles.heretile.neighbors(tile_ids: Series, level: int | None = None) Series[source]#
Return tile IDs of all neighbors on given level for tiles.
Index and
NaNvalues are retained.NaNis also returned in place of empty lists or in case of invalid tile IDs or tiling level.Use
pd.Series.explodemethod to turn the lists into multiple rows.- Parameters:
tile_ids – the subject tile IDs
level – the tiling level
- Returns:
a
pd.Serieswith the list of neighboring tile IDs- Raises:
ValueError – in case the series doesn’t contain integers # noqa