Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_quadkey():
tile = mercantile.Tile(486, 332, 10)
expected = "0313102310"
assert mercantile.quadkey(tile) == expected
Output:
0313102310
$ echo "0313102310" | mercantile quadkey
Output:
[486, 332, 10]
"""
src = normalize_input(input)
try:
for line in iter_lines(src):
if line[0] == "[":
tile = json.loads(line)[:3]
output = mercantile.quadkey(tile)
else:
tile = mercantile.quadkey_to_tile(line)
output = json.dumps(tile)
click.echo(output)
except mercantile.QuadKeyError:
raise click.BadParameter("{0}".format(input), param=input, param_hint="input")
def do_prepare_url(self, url, tile_size, lon, lat, zoom, x, y):
quadkey = mercantile.quadkey(x, y, zoom)
return url.format(q=quadkey)
raise ValueError('This dataframe has no valid geometry.')
geometry_name = input_gdf.geometry.name
dfs = []
for _, row in input_gdf.iterrows():
input_geometry = row[geometry_name]
bounds = input_geometry.bounds
tiles = mercantile.tiles(bounds[0], bounds[1], bounds[2], bounds[3], zoom_level)
new_rows = []
for tile in tiles:
new_row = row.copy()
new_geometry = box(*mercantile.bounds(tile))
if new_geometry.intersects(input_geometry):
new_row[geometry_name] = new_geometry
new_row['quadkey'] = mercantile.quadkey(tile)
new_rows.append(new_row)
dfs.append(pd.DataFrame(new_rows))
df = pd.concat(dfs).reset_index(drop=True)
return CartoDataFrame(df, geometry=geometry_name, crs='epsg:4326')
def bbox_to_quadkeys(bbox: list, zoom: int):
""" Find all quadkeys in a bbox """
tiles = mercantile.tiles(bbox[0], bbox[1], bbox[2], bbox[3], int(zoom))
quadkeys = []
for tile in tiles:
quadkeys.append(mercantile.quadkey(tile))
return quadkeys