Skip to content

Commit adc7eb1

Browse files
committed
Improve documentation
1 parent 74de690 commit adc7eb1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Before running any commands, it is necessary to create a `config.json` file to s
4747
- `imagery`: One of:
4848
- A template string for a tiled imagery service. Note that you will generally need an API key to obtain images and there may be associated costs. The above example requires a [Mapbox access token](https://www.mapbox.com/help/how-access-tokens-work/)
4949
- A GeoTIFF file location. Works with both local and remote files. Ex: `'http://oin-hotosm.s3.amazonaws.com/593ede5ee407d70011386139/0/3041615b-2bdb-40c5-b834-36f580baca29.tif'`
50-
- A WMS endpoint `GetMap` request. Fill out all necessary parameters except `bbox` which should be set as `{bbox}`. Ex:
50+
- A [WMS endpoint](http://www.opengeospatial.org/standards/wms) `GetMap` request. Fill out all necessary parameters except `bbox` which should be set as `{bbox}`. Ex:
5151
`'https://basemap.nationalmap.gov/arcgis/services/USGSImageryOnly/MapServer/WMSServer?SERVICE=WMS&REQUEST=GetMap&VERSION=1.1.1&LAYERS=0&STYLES=&FORMAT=image%2Fjpeg&TRANSPARENT=false&HEIGHT=256&WIDTH=256&SRS=EPSG%3A3857&BBOX={bbox}'`
5252
- `background_ratio`: For single-class classification problems, we need to download images with no matching class. We will download `background_ratio` times the number of images matching the one class.
5353
- `ml_type`: One of `"classification"`, `"object-detection"`, or `"segmentation"`. For the final label numpy arrays (`y_train` and `y_test`), we will produce a different label depending upon the `type`.

label_maker/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,22 @@ def get_tile_wms(tile, imagery, folder, imagery_offset):
9494
Converts the tile boundaries to the spatial reference system (SRS) specified
9595
by the WMS query parameter.
9696
"""
97+
# retrieve the necessary parameters from the query string
9798
query_dict = parse_qs(imagery.lower())
9899
image_format = query_dict['format'][0].split('/')[1]
99100
wms_srs = query_dict['srs'][0]
100101

102+
# find our tile bounding box
101103
bound = bounds(*[int(t) for t in tile.split('-')])
102104
p1 = Proj({'init': 'epsg:4326'})
103105
p2 = Proj({'init': wms_srs})
104106

105-
# project tile boundaries from lat/lng to WMS SRS
107+
# project the tile bounding box from lat/lng to WMS SRS
106108
tile_ll_proj = transform(p1, p2, bound.west, bound.south)
107109
tile_ur_proj = transform(p1, p2, bound.east, bound.north)
108110
bbox = tile_ll_proj + tile_ur_proj
109111

112+
# request the image with the transformed bounding box and save
110113
wms_url = imagery.replace('{bbox}', ','.join([str(b) for b in bbox]))
111114
r = requests.get(wms_url)
112115
tile_img = op.join(folder, '{}.{}'.format(tile, image_format))

0 commit comments

Comments
 (0)