Skip to content

Commit

Permalink
ArcticDEM DTM provider
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrandwijk committed Jan 21, 2025
1 parent 7707b5b commit cb2dae4
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,14 @@ The generator supports adding the own DTM providers, please refer to the [DTM Pr

### Supported DTM providers

![coverage map](https://github.com/user-attachments/assets/e02a4b5e-c5a9-4e6f-826f-048081704ef9)
![coverage map](https://github.com/user-attachments/assets/e96461fd-e063-4cae-9f59-11bf6efee195)

In addition to SRTM 30m, which provides global coverage, the map above highlights all countries and/or regions where higher resolution coverage is provided by one of the DTM providers.

| Provider Name | Resolution | Developer |
| ---------------------------------- | ------------ | ------------------------------------------- |
| 🌎 SRTM30 | 30 meters | [iwatkot](https://github.com/iwatkot) |
| 🌎 ArcticDEM | 2 meters | [kbrandwijk](https://github.com/kbrandwijk) |
| 🇺🇸 USGS | 1-90 meters | [ZenJakey](https://github.com/ZenJakey) |
| 🏴󠁧󠁢󠁥󠁮󠁧󠁿 England | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
| 🏴󠁧󠁢󠁳󠁣󠁴󠁿 Scotland | 0.25-1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
Expand Down
1 change: 1 addition & 0 deletions maps4fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from maps4fs.generator.dtm.switzerland import SwitzerlandProvider
from maps4fs.generator.dtm.mv import MecklenburgVorpommernProvider
from maps4fs.generator.dtm.baden import BadenWurttembergProvider
from maps4fs.generator.dtm.arctic import ArcticProvider
from maps4fs.generator.game import Game
from maps4fs.generator.map import Map
from maps4fs.generator.settings import (
Expand Down
75 changes: 75 additions & 0 deletions maps4fs/generator/dtm/arctic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""This module contains provider of Arctic data."""

import os

import requests

from maps4fs.generator.dtm.dtm import DTMProvider


class ArcticProvider(DTMProvider):
"""Provider of Arctic data."""

_code = "arctic"
_name = "ArcticDEM"
_region = "Global"
_icon = "🌍"
_resolution = 2
_author = "[kbrandwijk](https://github.com/kbrandwijk)"
_is_community = True

_extents = (83.98823036056658, 50.7492704708152, 179.99698443265999, -180)

_instructions = (
"This provider source includes 2 meter DEM data for the entire Arctic region about 50 "
"degrees North. The tiles are very big, around 1 GB each, so downloading and processing "
"them can take a long time."
)

_url = "https://stac.pgc.umn.edu/api/v1/collections/arcticdem-mosaics-v4.1-2m/items"

def download_tiles(self):
download_urls = self.get_download_urls()
all_tif_files = self.download_tif_files(download_urls, self.shared_tiff_path)
return all_tif_files

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.shared_tiff_path = os.path.join(self._tile_directory, "shared")
os.makedirs(self.shared_tiff_path, exist_ok=True)

def get_download_urls(self) -> list[str]:
"""Get download URLs of the GeoTIFF files from the OGC API.
Returns:
list: List of download URLs.
"""
urls = []

try:
# Make the GET request
north, south, east, west = self.get_bbox()
print(north, south, east, west)
response = requests.get( # pylint: disable=W3101
self.url, # type: ignore
params={
"bbox": f"{west},{south},{east},{north}",
"limit": "100",
},
timeout=60,
)
self.logger.debug("Getting file locations from ArcticDEM OGC API...")

# Check if the request was successful (HTTP status code 200)
if response.status_code == 200:
# Parse the JSON response
json_data = response.json()
items = json_data["features"]
for item in items:
urls.append(item["assets"]["dem"]["href"])
else:
self.logger.error("Failed to get data. HTTP Status Code: %s", response.status_code)
except requests.exceptions.RequestException as e:
self.logger.error("Failed to get data. Error: %s", e)
self.logger.debug("Received %s urls", len(urls))
return urls

0 comments on commit cb2dae4

Please sign in to comment.