-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into datasets/glaciers_alps
- Loading branch information
Showing
71 changed files
with
757 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.8.0 | ||
rev: v0.9.1 | ||
hooks: | ||
- id: ruff | ||
types_or: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -358,6 +358,11 @@ MapInWild | |
|
||
.. autoclass:: MapInWild | ||
|
||
MDAS | ||
^^^^ | ||
|
||
.. autoclass:: MDAS | ||
|
||
Million-AID | ||
^^^^^^^^^^^ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# style | ||
mypy==1.14.1 | ||
ruff==0.8.4 | ||
ruff==0.9.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file added
BIN
+4.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/3K_DSM_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+3.36 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/3K_RGB_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+486 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/EeteS_EnMAP_10m_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+486 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/EeteS_EnMAP_30m_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+26.5 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/EeteS_Sentinel_2_10m_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+739 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/HySpex_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+8.36 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/Sentinel_1_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+26.5 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/Sentinel_2_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+1.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/osm_buildings_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+8.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/osm_landuse_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+1.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_1/osm_water_sub_area1.tif
Binary file not shown.
Binary file added
BIN
+4.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/3K_DSM_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+3.36 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/3K_RGB_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+486 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/EeteS_EnMAP_10m_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+486 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/EeteS_EnMAP_30m_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+26.5 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/EeteS_Sentinel_2_10m_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+739 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/HySpex_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+8.36 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/Sentinel_1_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+26.5 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/Sentinel_2_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+1.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/osm_buildings_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+8.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/osm_landuse_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+1.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_2/osm_water_sub_area2.tif
Binary file not shown.
Binary file added
BIN
+4.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/3K_DSM_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+3.36 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/3K_RGB_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+486 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/EeteS_EnMAP_10m_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+486 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/EeteS_EnMAP_30m_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+26.5 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/EeteS_Sentinel_2_10m_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+739 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/HySpex_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+8.36 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/Sentinel_1_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+26.5 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/Sentinel_2_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+1.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/osm_buildings_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+8.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/osm_landuse_sub_area3.tif
Binary file not shown.
Binary file added
BIN
+1.35 KB
tests/data/mdas/Augsburg_data_4_publication/sub_area_3/osm_water_sub_area3.tif
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import hashlib | ||
import os | ||
import shutil | ||
|
||
import numpy as np | ||
import rasterio | ||
from rasterio.crs import CRS | ||
from rasterio.transform import from_origin | ||
|
||
# Set the random seed for reproducibility | ||
np.random.seed(0) | ||
|
||
# Define the root directory, dataset name, subareas, and modalities based on mdas.py | ||
root_dir = '.' | ||
ds_root_name = 'Augsburg_data_4_publication' | ||
subareas = ['sub_area_1', 'sub_area_2', 'sub_area_3'] | ||
modalities = [ | ||
'3K_DSM', | ||
'3K_RGB', | ||
'HySpex', | ||
'EeteS_EnMAP_10m', | ||
'EeteS_EnMAP_30m', | ||
'EeteS_Sentinel_2_10m', | ||
'Sentinel_1', | ||
'Sentinel_2', | ||
'osm_buildings', | ||
'osm_landuse', | ||
'osm_water', | ||
] | ||
|
||
landuse_class_codes = [ | ||
-2147483647, # no label | ||
7201, # forest | ||
7202, # park | ||
7203, # residential | ||
7204, # industrial | ||
7205, # farm | ||
7206, # cemetery | ||
7207, # allotments | ||
7208, # meadow | ||
7209, # commercial | ||
7210, # nature reserve | ||
7211, # recreation ground | ||
7212, # retail | ||
7213, # military | ||
7214, # quarry | ||
7215, # orchard | ||
7217, # scrub | ||
7218, # grass | ||
7219, # heath | ||
] | ||
|
||
# Remove existing dummy data if it exists | ||
dataset_path = os.path.join(root_dir, ds_root_name) | ||
if os.path.exists(dataset_path): | ||
shutil.rmtree(dataset_path) | ||
|
||
|
||
def create_dummy_geotiff( | ||
path: str, | ||
num_bands: int = 3, | ||
width: int = 32, | ||
height: int = 32, | ||
dtype: np.dtype = np.uint16, | ||
binary: bool = False, | ||
landuse: bool = False, | ||
) -> None: | ||
"""Create a dummy GeoTIFF file.""" | ||
crs = CRS.from_epsg(32632) | ||
transform = from_origin(0, 0, 1, 1) | ||
|
||
if binary: | ||
data = np.random.randint(0, 2, size=(num_bands, height, width)).astype(dtype) | ||
elif landuse: | ||
num_pixels = num_bands * height * width | ||
no_label_ratio = 0.1 | ||
num_no_label = int(no_label_ratio * num_pixels) | ||
num_labels = num_pixels - num_no_label | ||
landuse_values = np.random.choice(landuse_class_codes[1:], size=num_labels) | ||
no_label_values = np.full(num_no_label, landuse_class_codes[0], dtype=dtype) | ||
combined = np.concatenate([landuse_values, no_label_values]) | ||
np.random.shuffle(combined) | ||
data = combined.reshape((num_bands, height, width)).astype(dtype) | ||
else: | ||
# Generate random data for other modalities | ||
data = np.random.randint(0, 255, size=(num_bands, height, width)).astype(dtype) | ||
|
||
os.makedirs(os.path.dirname(path), exist_ok=True) | ||
|
||
with rasterio.open( | ||
path, | ||
'w', | ||
driver='GTiff', | ||
height=height, | ||
width=width, | ||
count=num_bands, | ||
dtype=dtype, | ||
crs=crs, | ||
transform=transform, | ||
) as dst: | ||
dst.write(data) | ||
|
||
|
||
# Create directory structure and dummy data | ||
for subarea in subareas: | ||
# Format the subarea name for filenames, as in mdas.py _format_subarea method | ||
parts = subarea.split('_') | ||
subarea_formatted = parts[0] + '_' + parts[1] + parts[2] # e.g., 'sub_area1' | ||
|
||
subarea_dir = os.path.join(root_dir, ds_root_name, subarea) | ||
|
||
for modality in modalities: | ||
filename = f'{modality}_{subarea_formatted}.tif' | ||
file_path = os.path.join(subarea_dir, filename) | ||
|
||
if modality in ['osm_buildings', 'osm_water']: | ||
create_dummy_geotiff(file_path, num_bands=1, dtype=np.uint8, binary=True) | ||
elif modality == 'osm_landuse': | ||
create_dummy_geotiff(file_path, num_bands=1, dtype=np.float64, landuse=True) | ||
elif modality == 'HySpex': | ||
create_dummy_geotiff(file_path, num_bands=368, dtype=np.int16) | ||
elif modality in ['EeteS_EnMAP_10m', 'EeteS_EnMAP_30m']: | ||
create_dummy_geotiff(file_path, num_bands=242, dtype=np.uint16) | ||
elif modality == 'Sentinel_1': | ||
create_dummy_geotiff(file_path, num_bands=2, dtype=np.float32) | ||
elif modality in ['Sentinel_2', 'EeteS_Sentinel_2_10m']: | ||
create_dummy_geotiff(file_path, num_bands=13, dtype=np.uint16) | ||
elif modality == '3K_DSM': | ||
create_dummy_geotiff(file_path, num_bands=1, dtype=np.float32) | ||
elif modality == '3K_RGB': | ||
create_dummy_geotiff(file_path, num_bands=3, dtype=np.uint8) | ||
|
||
print(f'Dummy MDAS dataset created at {os.path.join(root_dir, ds_root_name)}') | ||
|
||
# Create a zip archive of the dataset directory | ||
zip_filename = f'{ds_root_name}.zip' | ||
zip_path = os.path.join(root_dir, zip_filename) | ||
|
||
shutil.make_archive( | ||
base_name=os.path.splitext(zip_path)[0], | ||
format='zip', | ||
root_dir='.', | ||
base_dir=ds_root_name, | ||
) | ||
|
||
|
||
def calculate_md5(filename: str) -> str: | ||
hash_md5 = hashlib.md5() | ||
with open(filename, 'rb') as f: | ||
for chunk in iter(lambda: f.read(4096), b''): | ||
hash_md5.update(chunk) | ||
return hash_md5.hexdigest() | ||
|
||
|
||
checksum = calculate_md5(zip_path) | ||
print(f'MD5 checksum: {checksum}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.