Grids
SquareGridGenerator
This gridding approach creates equally spaced grids relative to the bounding box of the AOI. The grid spacing is defined by cell_size
SquareGridGenerator
def SquareGridGenerator(
cell_size:float, # height and width of a square cell in meters
grid_projection:str='EPSG:3857', # projection of grid output
boundary:Union=None, # original boundary
):
Initialize self. See help(type(self)) for accurate signature.
SquareGridGenerator.create_cell
def create_cell(
x:float, # x coord of bottom left
y:float, # y coord of bottom left
)->Polygon:
Create a square cell based on the bottom left coordinates and cell_size
SquareGridGenerator.create_grid_for_polygon
def create_grid_for_polygon(
boundary, geometry
):
SquareGridGenerator.generate_grid
def generate_grid(
aoi_gdf:GeoDataFrame
)->GeoDataFrame:
FastSquareGridGenerator
This gridding approach creates equally spaced grids relative to the bounding box of the AOI. The grid spacing is defined by cell_size
This is significantly faster than SquareGridGenerator
This uses these optimizations to speed up grid generation:
- Vectorized Translation Functions: Functions that translate between lat,lon and x,y are written in polars.
- Voxel Traversal and Scanline Fill Algorithms: Faster alternative to finding all pixels within a polygon without using polygon intersection operations. These are implemented in
polygon_fill.fast_polygon_fill()
This also does error correction on the polygon boundary using off-boundary pixels. Read more in the polygon fill module reference
FastSquareGridGenerator
def FastSquareGridGenerator(
cell_size:float, # height and width of a square cell in meters
grid_projection:str='EPSG:3857', # planar projection of grid
boundary:Union=None, # original boundary
):
Initialize self. See help(type(self)) for accurate signature.
FastSquareGridGenerator.generate_grid
def generate_grid(
aoi_gdf:GeoDataFrame,
unique_id_col:Optional=None, # the ids under this column will be preserved in the output tiles
)->Union:
H3GridGenerator
H3GridGenerator
def H3GridGenerator(
resolution:int, # Resolution of hexagon. See: https://h3geo.org/docs/core-library/restable/ for more info
return_geometry:bool=True, # If geometry should be returned. Setting this to false will only return hex_ids
):
Initialize self. See help(type(self)) for accurate signature.
H3GridGenerator.get_hexes_for_polygon
def get_hexes_for_polygon(
poly:Polygon
):
H3GridGenerator.generate_grid
def generate_grid(
aoi_gdf:GeoDataFrame
)->DataFrame:
BingTileGridGenerator
BingTileGridGenerator
def BingTileGridGenerator(
zoom_level:int, # Zoom level of tile. See: https://docs.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system for more info
return_geometry:bool=True, # If geometry should be returned. Setting this to false will only return quadkeys
add_xyz_cols:bool=False, # If quadkey should be converted to their xyz values.
):
Initialize self. See help(type(self)) for accurate signature.
BingTileGridGenerator.get_all_tiles_for_polygon
def get_all_tiles_for_polygon(
polygon:Polygon
):
Get the interseting tiles with polygon for a zoom level. Polygon should be in EPSG:4326
BingTileGridGenerator.generate_grid
def generate_grid(
aoi_gdf:GeoDataFrame
)->DataFrame:
BingTileGridGenerator.generate_grid_join
def generate_grid_join(
aoi_gdf:GeoDataFrame, filter:bool=True, n_workers:int=4, progress:bool=True
)->DataFrame:
FastBingTileGridGenerator
This is significantly faster than BingTileGridGenerator
This uses these optimizations to speed up grid generation:
- Vectorized Translation Functions: Functions that translate between lat,lon and x,y are written in polars.
- Voxel Traversal and Scanline Fill Algorithms: Faster alternative to finding all pixels within a polygon without using polygon intersection operations. These are implemented in
polygon_fill.fast_polygon_fill()
This also does error correction on the polygon boundary using off-boundary pixels. Read more in the polygon fill module reference
FastBingTileGridGenerator
def FastBingTileGridGenerator(
zoom_level:int, # Zoom level of tile. See: https://docs.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system for more info
return_geometry:bool=True, # If geometry should be returned. Setting this to false will only return quadkeys
add_xyz_cols:bool=False, # If xyz columns should be returned. Unlike BingTileGridGenerator, choosing to return xyz columns doesn't substantionally add compute time.
):
Initialize self. See help(type(self)) for accurate signature.
FastBingTileGridGenerator.generate_grid
def generate_grid(
aoi_gdf:GeoDataFrame,
unique_id_col:Optional=None, # the ids under this column will be preserved in the output tiles
)->Union: