rslearn.data_sources.hf_srtm¶
hf_srtm ¶
Global SRTM void-filled elevation data from USGS, mirrored on Hugging Face by AI2.
This module provides: 1. A bulk download utility to fetch SRTM data from USGS EarthExplorer via the M2M API. This can be used to initialize a mirror of the data. 2. A data source that will pull from the AI2 Hugging Face mirror.
The SRTM dataset in USGS EarthExplorer is "srtm_v2" which contains void-filled elevation data from the Shuttle Radar Topography Mission. The bulk download fetches the highest resolution available: 1 arc-second (~30m) in the US and 3 arc-second (~90m) globally.
See https://www.usgs.gov/centers/eros/science/usgs-eros-archive-digital-elevation-shuttle-radar-topography-mission-srtm for details.
SRTM ¶
Bases: DataSource
Data source for SRTM elevation data from the AI2 Hugging Face mirror.
The data is split into 1x1-degree tiles, with filenames like: N05/SRTM1N05W163V2.tif (1 arc-second, ~30m resolution) N05/SRTM3N05W163V2.tif (3 arc-second, ~90m resolution)
SRTM1 (1 arc-second) is available for some regions (primarily US territories), while SRTM3 (3 arc-second) is available globally. By default, SRTM1 is preferred when available for higher resolution. Set always_use_3arcsecond=True to always use the lower resolution SRTM3 data for consistency.
Items from this data source do not come with a time range. The band name will match that specified in the band set, which should have a single band (e.g. "dem").
Source code in rslearn/data_sources/hf_srtm.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
get_item_by_name ¶
get_item_by_name(name: str) -> Item
Gets an item by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
the name of the item to get. For SRTM, the item name is the filename of the GeoTIFF tile. |
required |
Returns:
| Type | Description |
|---|---|
Item
|
the Item object |
Source code in rslearn/data_sources/hf_srtm.py
get_items ¶
get_items(geometries: list[STGeometry], query_config: QueryConfig) -> list[list[MatchedItemGroup[Item]]]
Get a list of items in the data source intersecting the given geometries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometries
|
list[STGeometry]
|
the spatiotemporal geometries |
required |
query_config
|
QueryConfig
|
the query configuration |
required |
Returns:
| Type | Description |
|---|---|
list[list[MatchedItemGroup[Item]]]
|
List of groups of items that should be retrieved for each geometry. |
Source code in rslearn/data_sources/hf_srtm.py
ingest ¶
ingest(tile_store: TileStoreWithLayer, items: list[Item], geometries: list[list[STGeometry]]) -> None
Ingest items into the given tile store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tile_store
|
TileStoreWithLayer
|
the tile store to ingest into |
required |
items
|
list[Item]
|
the items to ingest |
required |
geometries
|
list[list[STGeometry]]
|
a list of geometries needed for each item |
required |
Source code in rslearn/data_sources/hf_srtm.py
bulk_download_srtm ¶
bulk_download_srtm(output_dir: str, num_workers: int = 4, timeout: timedelta = timedelta(minutes=5)) -> None
Bulk download SRTM data from USGS EarthExplorer.
Downloads all SRTM tiles to the specified output directory. Uses atomic rename to ensure partially downloaded files are not included. Files that already exist in the output directory are skipped.
The scene list is cached in scenes.json in the output directory to avoid re-querying on subsequent runs.
Requires M2M_USERNAME and M2M_TOKEN environment variables to be set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str
|
directory to save downloaded files |
required |
num_workers
|
int
|
number of parallel download workers |
4
|
timeout
|
timedelta
|
timeout for API requests and downloads |
timedelta(minutes=5)
|
Source code in rslearn/data_sources/hf_srtm.py
main ¶
Command-line entry point for bulk SRTM download.
Requires M2M_USERNAME and M2M_TOKEN environment variables to be set.