Skip to content

Commit f278881

Browse files
authored
Merge pull request #45 from swiss-territorial-data-lab/gs/make_examples
Correct log output
2 parents 5773dfd + e158520 commit f278881

File tree

16 files changed

+872
-764
lines changed

16 files changed

+872
-764
lines changed

README.md

Lines changed: 65 additions & 53 deletions
Large diffs are not rendered by default.

examples/mineral-extract-sites-detection/config_trne.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ generate_tilesets.py:
1919
datasets:
2020
aoi_tiles: trne/tiles.geojson
2121
ground_truth_labels: trne/labels.geojson
22-
# fp_labels:
23-
# fp_shp: trne/FP.geojson
22+
# add_fp_labels:
23+
# fp_labels: trne/FP.geojson
2424
# frac_trn: 0.7 # fraction of fp tiles to add to the trn dataset, then the remaining tiles will be split in 2 and added to tst and val datasets
2525
image_source:
2626
type: XYZ # supported values: 1. MIL = Map Image Layer 2. WMS 3. XYZ 4. FOLDER
2727
year: 2020 # supported values: 1. multi-year (tiles of different year), 2. <year> (i.e. 2020)
2828
location: https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.swissimage-product/default/{year}/3857/{z}/{x}/{y}.jpeg
29-
# empty_tiles: # add empty tiles to datasets
29+
# add_empty_tiles: # add empty tiles to datasets
3030
# tiles_frac: 0.5 # fraction (relative to the number of tiles intersecting labels) of empty tiles to add
3131
# frac_trn: 0.7 # fraction of empty tiles to add to the trn dataset, then the remaining tiles will be split in 2 and added to tst and val datasets
3232
# keep_oth_tiles: False # keep tiles in oth dataset not intersecting oth labels

examples/mineral-extract-sites-detection/prepare_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def bbox(bounds):
264264
logger.info(f"There were {nb_tiles} tiles created")
265265

266266
# Get the number of tiles intersecting labels
267-
tiles_4326_gt_gdf = gpd.sjoin(tiles_4326_all_gdf, gt_labels_4326_gdf, how='inner', predicate='intersects')
267+
tiles_4326_gt_gdf = gpd.sjoin(tiles_4326_all_gdf, gt_labels_4326_gdf[['geometry', 'CATEGORY', 'SUPERCATEGORY']], how='inner', predicate='intersects')
268268
tiles_4326_gt_gdf.drop_duplicates(['id'], inplace=True)
269269
logger.info(f"- Number of tiles intersecting GT labels = {len(tiles_4326_gt_gdf)}")
270270

examples/road-surface-classification/config_rs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ generate_tilesets.py:
2222
enable: False # sample of tiles
2323
nb_tiles_max: 500
2424
working_directory: outputs_RS
25+
output_folder: .
2526
datasets:
2627
aoi_tiles: json_inputs/tiles_aoi.geojson
2728
ground_truth_labels: json_inputs/ground_truth_labels.geojson
@@ -31,7 +32,6 @@ generate_tilesets.py:
3132
year: 2018
3233
location: https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.swissimage-product/default/{year}/3857/{z}/{x}/{y}.jpeg
3334
srs: "EPSG:3857"
34-
output_folder: .
3535
tile_size: 256 # per side, in pixels
3636
overwrite: False
3737
n_jobs: 10

examples/swimming-pool-detection/GE/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ nobody@<id>:/app# exit
2323
$ sudo chmod -R a+w examples
2424
```
2525

26-
We strongly encourage the end-user to review the provided `config_GE.yaml` file as well as the various output files, a list of which is printed by each script before exiting.
26+
We strongly encourage the end-user to review the provided `config_GE.yaml` file as well as the various output files, a list of which is printed by each script before exiting.
27+
28+
Due to timeout of the WMS service, the user might have to run the tileset generation several times.

examples/swimming-pool-detection/GE/config_GE.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ prepare_data.py:
22
datasets:
33
lakes_shapefile: https://ge.ch/sitg/geodata/SITG/OPENDATA/3951/SHP_GEO_LAC_LEMAN.zip
44
parcels_shapefile: https://ge.ch/sitg/geodata/SITG/OPENDATA/8450/SHP_CAD_PARCELLE_MENSU.zip
5-
swimmingpools_shapefile: https://ge.ch/sitg/geodata/SITG/OPENDATA/1836/SHP_CAD_PISCINE.zip
5+
swimming_pools_shapefile: https://ge.ch/sitg/geodata/SITG/OPENDATA/1836/SHP_CAD_PISCINE.zip
66
OK_z18_tile_IDs_csv: data/OK_z18_tile_IDs.csv
77
output_folder: output_GE
88

examples/swimming-pool-detection/GE/prepare_data.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
OUTPUT_DIR = cfg['output_folder']
3636
LAKES_SHPFILE = cfg['datasets']['lakes_shapefile']
3737
PARCELS_SHPFILE = cfg['datasets']['parcels_shapefile']
38-
SWIMMINGPOOLS_SHPFILE = cfg['datasets']['swimmingpools_shapefile']
38+
SWIMMING_POOLS_SHPFILE = cfg['datasets']['swimming_pools_shapefile']
3939
OK_TILE_IDS_CSV = cfg['datasets']['OK_z18_tile_IDs_csv']
4040
ZOOM_LEVEL = 18 # this is hard-coded 'cause we only know "OK tile IDs" for this zoom level
4141

@@ -49,27 +49,27 @@
4949

5050
dataset_dict = {}
5151

52-
for dataset in ['lakes', 'parcels', 'swimmingpools']:
52+
for dataset in ['lakes', 'parcels', 'swimming_pools']:
5353

5454
shpfile_name = eval(f'{dataset.upper()}_SHPFILE').split('/')[-1]
5555
shpfile_path = os.path.join(OUTPUT_DIR, shpfile_name)
5656

5757
if eval(f'{dataset.upper()}_SHPFILE').startswith('http'):
5858

59-
logger.info(f"Downloading the {dataset} dataset...")
59+
logger.info(f"Downloading the {dataset.replace('_', ' ')} dataset...")
6060
r = requests.get(eval(f'{dataset.upper()}_SHPFILE'), timeout=30)
6161
with open(shpfile_path, 'wb') as f:
6262
f.write(r.content)
6363

6464
written_files.append(shpfile_path)
6565
logger.success(f"...done. A file was written: {shpfile_path}")
6666

67-
logger.info(f"Loading the {dataset} dataset as a GeoPandas DataFrame...")
67+
logger.info(f"Loading the {dataset.replace('_', ' ')} dataset as a GeoPandas DataFrame...")
6868
dataset_dict[dataset] = gpd.read_file(f'zip://{shpfile_path}')
6969
logger.success(f"...done. {len(dataset_dict[dataset])} records were found.")
7070

71-
dataset_dict['swimmingpools']['CATEGORY'] = "swimming pool"
72-
dataset_dict['swimmingpools']['SUPERCATEGORY'] = "facility"
71+
dataset_dict['swimming_pools']['CATEGORY'] = "swimming pool"
72+
dataset_dict['swimming_pools']['SUPERCATEGORY'] = "facility"
7373

7474
# ------ Computing the Area of Interest (AoI) = cadastral parcels - Léman lake
7575

@@ -123,7 +123,7 @@
123123
OK_tiles_gdf.to_crs(epsg=4326).to_file(OK_TILES_GEOJSON, driver='GeoJSON')
124124
written_files.append(OK_TILES_GEOJSON)
125125

126-
labels_gdf = dataset_dict['swimmingpools'].copy()
126+
labels_gdf = dataset_dict['swimming_pools'].copy()
127127
labels_gdf = labels_gdf.to_crs(epsg=4326)
128128

129129
# Ground Truth Labels = Labels intersecting OK tiles

0 commit comments

Comments
 (0)