Commit c87b7a08 authored by Cecilia Nievas's avatar Cecilia Nievas Committed by Nicolas Garcia Ospina
Browse files

Apply 8 suggestion(s) to 2 file(s)

parent e2e036c9
Pipeline #25875 failed with stage
in 2 minutes and 20 seconds
......@@ -16,8 +16,8 @@ by the West,South,East,North limits separated with single spaces:
```
python quadtreegrid.py -in_bounds 1 1 5 5
```
This would create a file called `output_quadkeys.txt` with all the `zoom level 18` tiles within
that bounding box.
This would create a file called `output_quadkeys.txt` with all the `zoom level 18` tiles that
contain that bounding box.
## -in_file
The bounding box can be also extracted from a `shapefile` for example, this can be done with the
......@@ -25,29 +25,29 @@ argument `-in_file` followed by the relative or absolute path of the target file
```
python quadtreegrid.py -in_file /path/to/my_shapefile.shp
```
This would create a file called `output_quadkeys.txt` with all the `zoom level 18` tiles within
the bounding box of the entire shapefile.
This would create a file called `output_quadkeys.txt` with all the `zoom level 18` tiles that
contain the bounding box of the entire shapefile.
## Optional arguments
Two optional arguments to include are: 1) `-output` which allows to set a filename or filepath to
resulting text file. if the resulting filename has the `csv` extension, a header with the name
`quadkey` will be included. The default for this is `output_quadkeys.txt`. 2) the `-zoom` argument
the resulting text file. If the resulting filename has the `csv` extension, a header with the name
`quadkey` will be included. The default for this is `output_quadkeys.txt`. 2) The `-zoom` argument
sets the desired zoom level of the output tiles. Its default value is `18`.
```
python quadtreegrid.py -in_bounds 1 1 5 5 -output ./custom_filepath.csv -zoom 9
```
This would create a file called `custom_filepath.csv` with all the `zoom level 9` tiles within
that bounding box and the header `quadkey`.
This would create a file called `custom_filepath.csv` with all the `zoom level 9` tiles that
contain the input bounding box and the header `quadkey`.
# quadtreegrid_polyfill.py examples
The `quadtreegrid_polyfill.py` script allows the creation of a grid with all quadkeys available in an
The `quadtreegrid_polyfill.py` script allows for the identification of the quadkeys of all tiles that contain an
irregular polygon or multipolygon. It is an optimization of the `Babel("bing").polyfill()` function
from `Babelgrid`. The current version of this script uses the country borders from the [GADM 3.6](https://gadm.org/)
from [Babelgrid](https://pypi.org/project/babelgrid/). The current version of this script uses the country borders from [GADM 3.6](https://gadm.org/)
dataset. This dataset must be downloaded separately from [this_link](https://biogeo.ucdavis.edu/data/gadm3.6/gadm36_levels_shp.zip),
and the shapefile `gadm36_0.shp` must be placed in the data directory of this repository. Currently,
and the shapefile `gadm36_0.shp` must be placed in the `data` directory of this repository (`quadtreegrid/data`). Currently,
this is hard coded but may become more flexible in a further version.
## -country
......
......@@ -75,7 +75,7 @@ args = parser.parse_args()
# Get a country polygon by name from the GADM dataset and do small buffer
country_name = args.country.replace("_", " ")
print(country_name)
world = gpd.read_file("../data/gadm36_0.shp").to_crs("epsg:4326")
world = gpd.read_file(os.path.join("..", os.path.dirname(__file__), "data", "gadm36_0.shp")).to_crs("epsg:4326")
country = world[world["NAME_0"] == country_name]
logger.info("Setting a buffer on target 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