Commit 53f93fc3 authored by Nicolas Garcia Ospina's avatar Nicolas Garcia Ospina
Browse files

Addressed threads

parent f13fd05e
Pipeline #27913 passed with stage
in 2 minutes and 20 seconds
......@@ -31,7 +31,7 @@ logger.info("Launching quadtreegrid")
parser = argparse.ArgumentParser(
description="""Get all quadkeys from given bounds
or get the bounds of a vector file"""
or get the bounds of a vector file"""
)
parser.add_argument(
"-in_bounds",
......
......@@ -124,20 +124,19 @@ def get_tiles_from_polygon(in_geometry):
Returns:
tiles_ids (list): List of quadkeys as strings.
"""
in_geometry = in_geometry.buffer(0.01)
tiles = []
if in_geometry.geom_type == "Polygon":
sw_lon, sw_lat, ne_lon, ne_lat = in_geometry.bounds
tiles_generator = mercantile.tiles(sw_lon, sw_lat, ne_lon, ne_lat, args.zoom)
tiles.extend([mercantile.quadkey(tile) for tile in tiles_generator])
elif in_geometry.geom_type == "MultiPolygon":
geometries = list(in_geometry)
for geometry in geometries:
sw_lon, sw_lat, ne_lon, ne_lat = geometry.bounds
tiles_generator = mercantile.tiles(sw_lon, sw_lat, ne_lon, ne_lat, args.zoom)
tiles.extend([mercantile.quadkey(tile) for tile in tiles_generator])
else:
raise IOError("Input is not a valid geometry.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment