Last active
August 2, 2022 08:40
-
-
Save butchtm/3eff004bae150ea1b1d2dfeffdb5de17 to your computer and use it in GitHub Desktop.
Sample generation of geometry from bing tile quadkey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geopandas as gpd | |
import morecantile | |
import shapely.geometry as geom | |
import pandas as pd | |
tms = morecantile.tms.get('WebMercatorQuad') | |
schools = pd.DataFrame(dict(name=['Rurubao School'], quadkey=['133332330000'], amenity=['school'],)) | |
def quadkey_to_geom(x): | |
tile = tms.quadkey_to_tile(x) | |
feature = tms.feature(tile) | |
geometry = geom.shape(feature['geometry']) | |
return geometry | |
schools['geometry'] = schools.quadkey.apply(quadkey_to_geom); schools | |
schools_gdf = gpd.GeoDataFrame(schools, geometry='geometry', crs='EPSG:4326') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment