S2 utils
embedders.s2vec.s2_utils ¶
Utility functions for S2 cells.
get_children_from_token ¶
Given an S2 cell token (string), return a list of its child cells at the specified target level.
PARAMETER | DESCRIPTION |
---|---|
token
|
The S2 cell token (hex string, e.g., '89c2588').
TYPE:
|
target_level
|
The desired resolution level for the child cells.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: A GeoDataFrame of S2 cells representing the children at the target level. |
Source code in srai/embedders/s2vec/s2_utils.py
get_patches_from_img_gdf ¶
get_patches_from_img_gdf(
img_gdf: gpd.GeoDataFrame, target_level: int
) -> tuple[gpd.GeoDataFrame, gpd.GeoDataFrame]
Get patches from an image GeoDataFrame at a specified target level.
PARAMETER | DESCRIPTION |
---|---|
img_gdf
|
GeoDataFrame containing image regions.
TYPE:
|
target_level
|
The desired resolution level for the patches.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
tuple[gpd.GeoDataFrame, gpd.GeoDataFrame]: GeoDataFrames containing |
GeoDataFrame
|
patches at the target level and the joint gdf between images and patches. |
Source code in srai/embedders/s2vec/s2_utils.py
sort_patches ¶
Sort patches from top-left to bottom-right based on their bounding box coordinates.
PARAMETER | DESCRIPTION |
---|---|
patches_gdf
|
GeoDataFrame containing patches with a 'geometry' column.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: Sorted GeoDataFrame. |