Skip to content

Commit 3839c0e

Browse files
committed
don't modify the scripts from main
1 parent 78bc721 commit 3839c0e

8 files changed

Lines changed: 25 additions & 22 deletions

File tree

olmoearth_pretrain/dataset_creation/rslearn_to_olmoearth/cdl.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from rslearn.data_sources import Item
99
from rslearn.dataset import Dataset, Window
1010
from rslearn.utils.mp import star_imap_unordered
11+
from rslearn.utils.raster_array import RasterArray
1112
from upath import UPath
1213

1314
from olmoearth_pretrain.data.constants import Modality, TimeSpan
@@ -44,12 +45,12 @@ def convert_cdl(window: Window, olmoearth_path: UPath) -> None:
4445
assert len(Modality.CDL.band_sets) == 1
4546
band_set = Modality.CDL.band_sets[0]
4647
raster_dir = window.get_raster_dir(LAYER_NAME, band_set.bands)
47-
raster = GEOTIFF_RASTER_FORMAT.decode_raster(
48+
image = GEOTIFF_RASTER_FORMAT.decode_raster(
4849
raster_dir, window.projection, window.bounds
49-
)
50+
).get_chw_array()
5051

5152
# Skip if there are any background/nodata.
52-
if raster.array.min() == 0:
53+
if image.min() == 0:
5354
return
5455

5556
dst_fname = get_modality_fname(
@@ -64,7 +65,7 @@ def convert_cdl(window: Window, olmoearth_path: UPath) -> None:
6465
path=dst_fname.parent,
6566
projection=window.projection,
6667
bounds=window.bounds,
67-
raster=raster,
68+
raster=RasterArray(chw_array=image),
6869
fname=dst_fname.name,
6970
)
7071
metadata_fname = get_modality_temp_meta_fname(

olmoearth_pretrain/dataset_creation/rslearn_to_olmoearth/gse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def convert_gse(window: Window, olmoearth_path: UPath) -> None:
5353
assert len(Modality.GSE.band_sets) == 1
5454
band_set = Modality.GSE.band_sets[0]
5555
raster_dir = window.get_raster_dir(LAYER_NAME, band_set.bands)
56-
raster = GEOTIFF_RASTER_FORMAT.decode_raster(
56+
image = GEOTIFF_RASTER_FORMAT.decode_raster(
5757
raster_dir, window.projection, window.bounds
5858
)
5959
dst_fname = get_modality_fname(
@@ -68,7 +68,7 @@ def convert_gse(window: Window, olmoearth_path: UPath) -> None:
6868
path=dst_fname.parent,
6969
projection=window.projection,
7070
bounds=window.bounds,
71-
raster=raster,
71+
raster=image,
7272
fname=dst_fname.name,
7373
)
7474
metadata_fname = get_modality_temp_meta_fname(

olmoearth_pretrain/dataset_creation/rslearn_to_olmoearth/naip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def convert_naip(window: Window, olmoearth_path: UPath) -> None:
5555
assert len(Modality.NAIP.band_sets) == 1
5656
band_set = Modality.NAIP.band_sets[0]
5757
raster_dir = window.get_raster_dir(LAYER_NAME, band_set.bands)
58-
raster = raster_format.decode_raster(raster_dir, window.projection, window.bounds)
58+
image = raster_format.decode_raster(raster_dir, window.projection, window.bounds)
5959
dst_fname = get_modality_fname(
6060
olmoearth_path,
6161
Modality.NAIP,
@@ -68,7 +68,7 @@ def convert_naip(window: Window, olmoearth_path: UPath) -> None:
6868
path=dst_fname.parent,
6969
projection=window.projection,
7070
bounds=window.bounds,
71-
raster=raster,
71+
raster=image,
7272
fname=dst_fname.name,
7373
)
7474
metadata_fname = get_modality_temp_meta_fname(

olmoearth_pretrain/dataset_creation/rslearn_to_olmoearth/naip_10.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def convert_naip(window: Window, olmoearth_path: UPath) -> None:
6363
Modality.NAIP_10, band_set, window.projection, window.bounds
6464
)
6565
raster_dir = window.get_raster_dir(LAYER_NAME, band_set.bands)
66-
raster = raster_format.decode_raster(
66+
image = raster_format.decode_raster(
6767
raster_dir, adjusted_projection, adjusted_bounds
6868
)
6969
dst_fname = get_modality_fname(
@@ -78,7 +78,7 @@ def convert_naip(window: Window, olmoearth_path: UPath) -> None:
7878
path=dst_fname.parent,
7979
projection=adjusted_projection,
8080
bounds=adjusted_bounds,
81-
raster=raster,
81+
raster=image,
8282
fname=dst_fname.name,
8383
)
8484
metadata_fname = get_modality_temp_meta_fname(

olmoearth_pretrain/dataset_creation/rslearn_to_olmoearth/srtm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def convert_srtm(window: Window, olmoearth_path: UPath) -> None:
3838
assert len(Modality.SRTM.band_sets) == 1
3939
band_set = Modality.SRTM.band_sets[0]
4040
raster_dir = window.get_raster_dir(LAYER_NAME, band_set.bands)
41-
raster = GEOTIFF_RASTER_FORMAT.decode_raster(
41+
image = GEOTIFF_RASTER_FORMAT.decode_raster(
4242
raster_dir, window.projection, window.bounds
4343
)
4444
dst_fname = get_modality_fname(
@@ -53,7 +53,7 @@ def convert_srtm(window: Window, olmoearth_path: UPath) -> None:
5353
path=dst_fname.parent,
5454
projection=window.projection,
5555
bounds=window.bounds,
56-
raster=raster,
56+
raster=image,
5757
fname=dst_fname.name,
5858
)
5959
metadata_fname = get_modality_temp_meta_fname(

olmoearth_pretrain/dataset_creation/rslearn_to_olmoearth/worldcover.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def convert_worldcover(window: Window, olmoearth_path: UPath) -> None:
3838
assert len(Modality.WORLDCOVER.band_sets) == 1
3939
band_set = Modality.WORLDCOVER.band_sets[0]
4040
raster_dir = window.get_raster_dir(LAYER_NAME, band_set.bands)
41-
raster = GEOTIFF_RASTER_FORMAT.decode_raster(
41+
image = GEOTIFF_RASTER_FORMAT.decode_raster(
4242
raster_dir, window.projection, window.bounds
4343
)
4444
dst_fname = get_modality_fname(
@@ -53,7 +53,7 @@ def convert_worldcover(window: Window, olmoearth_path: UPath) -> None:
5353
path=dst_fname.parent,
5454
projection=window.projection,
5555
bounds=window.bounds,
56-
raster=raster,
56+
raster=image,
5757
fname=dst_fname.name,
5858
)
5959
metadata_fname = get_modality_temp_meta_fname(

olmoearth_pretrain/dataset_creation/rslearn_to_olmoearth/worldpop.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import tqdm
99
from rslearn.dataset import Dataset, Window
1010
from rslearn.utils.mp import star_imap_unordered
11+
from rslearn.utils.raster_array import RasterArray
1112
from upath import UPath
1213

1314
from olmoearth_pretrain.data.constants import Modality, TimeSpan
@@ -38,16 +39,16 @@ def convert_worldpop(window: Window, olmoearth_path: UPath) -> None:
3839
assert len(Modality.WORLDPOP.band_sets) == 1
3940
band_set = Modality.WORLDPOP.band_sets[0]
4041
raster_dir = window.get_raster_dir(LAYER_NAME, band_set.bands)
41-
raster = GEOTIFF_RASTER_FORMAT.decode_raster(
42+
image = GEOTIFF_RASTER_FORMAT.decode_raster(
4243
raster_dir, window.projection, window.bounds
4344
).get_chw_array()
4445

4546
# Clip population count to 0. NODATA is -99999 and includes locations that are
4647
# mapped as "unsettled" but really that is 0 population.
47-
raster.array[raster.array < 0] = 0
48+
image[image < 0] = 0
4849
# Skip areas that are fully nodata since it is more likely to be wrong and also is
4950
# a less useful target.
50-
if raster.array.max() == 0:
51+
if image.max() == 0:
5152
return
5253

5354
dst_fname = get_modality_fname(
@@ -62,7 +63,7 @@ def convert_worldpop(window: Window, olmoearth_path: UPath) -> None:
6263
path=dst_fname.parent,
6364
projection=window.projection,
6465
bounds=window.bounds,
65-
raster=raster,
66+
raster=RasterArray(chw_array=image),
6667
fname=dst_fname.name,
6768
)
6869
metadata_fname = get_modality_temp_meta_fname(

olmoearth_pretrain/dataset_creation/rslearn_to_olmoearth/wri_canopy_height_map.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import tqdm
1010
from rslearn.dataset import Dataset, Window
1111
from rslearn.utils.mp import star_imap_unordered
12+
from rslearn.utils.raster_array import RasterArray
1213
from upath import UPath
1314

1415
from olmoearth_pretrain.data.constants import Modality, TimeSpan
@@ -40,15 +41,15 @@ def convert_chm(window: Window, olmoearth_path: UPath) -> None:
4041
assert len(Modality.WRI_CANOPY_HEIGHT_MAP.band_sets) == 1
4142
band_set = Modality.WRI_CANOPY_HEIGHT_MAP.band_sets[0]
4243
raster_dir = window.get_raster_dir(LAYER_NAME, band_set.bands)
43-
raster = GEOTIFF_RASTER_FORMAT.decode_raster(
44+
image = GEOTIFF_RASTER_FORMAT.decode_raster(
4445
raster_dir, window.projection, window.bounds
4546
).get_chw_array()
4647

4748
# Skip areas with any nodata (255).
48-
if raster.array.max() == 255:
49+
if image.max() == 255:
4950
return
5051
# Also skip if there are not enough positive pixels.
51-
if np.count_nonzero(raster.array) / raster.array.size < 0.2:
52+
if np.count_nonzero(image) / image.size < 0.2:
5253
return
5354

5455
dst_fname = get_modality_fname(
@@ -63,7 +64,7 @@ def convert_chm(window: Window, olmoearth_path: UPath) -> None:
6364
path=dst_fname.parent,
6465
projection=window.projection,
6566
bounds=window.bounds,
66-
raster=raster,
67+
raster=RasterArray(chw_array=image),
6768
fname=dst_fname.name,
6869
)
6970
metadata_fname = get_modality_temp_meta_fname(

0 commit comments

Comments
 (0)