Update pages/12_🌲_VertXtractor.py
Browse files- pages/12_🌲_VertXtractor.py +42 -12
pages/12_🌲_VertXtractor.py
CHANGED
@@ -18,7 +18,7 @@ LAYERS = {
|
|
18 |
"Swisstopo - Réseau hydrographique": {"id": "ch.bafu.vec25-gewaessernetz", "source": "swisstopo", "type": "vector"},
|
19 |
"Swisstopo - swissBUILDINGS3D 3.0 Beta": {"id": "ch.swisstopo.swissbuildings3d_3_0", "source": "swisstopo", "type": "3d"},
|
20 |
"ESRI - World Imagery": {"id": "World_Imagery", "source": "esri", "type": "image"},
|
21 |
-
"ESRI - World Elevation": {"id": "
|
22 |
"ESRI - World Topographic": {"id": "World_Topo_Map", "source": "esri", "type": "image"},
|
23 |
"ESRI - World Street Map": {"id": "World_Street_Map", "source": "esri", "type": "image"},
|
24 |
"ESRI - World Terrain": {"id": "World_Terrain_Base", "source": "esri", "type": "image"},
|
@@ -47,17 +47,47 @@ def get_download_url(bbox, layer_info):
|
|
47 |
data_key = 'rgb' if 'rgb' in asset_keys else 'data' if 'data' in asset_keys else next(iter(asset_keys))
|
48 |
return feature['assets'][data_key]['href']
|
49 |
else: # ESRI
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
"
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
}
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
return None
|
62 |
|
63 |
def main():
|
|
|
18 |
"Swisstopo - Réseau hydrographique": {"id": "ch.bafu.vec25-gewaessernetz", "source": "swisstopo", "type": "vector"},
|
19 |
"Swisstopo - swissBUILDINGS3D 3.0 Beta": {"id": "ch.swisstopo.swissbuildings3d_3_0", "source": "swisstopo", "type": "3d"},
|
20 |
"ESRI - World Imagery": {"id": "World_Imagery", "source": "esri", "type": "image"},
|
21 |
+
"ESRI - World Elevation": {"id": "WorldElevation/Terrain", "source": "esri", "type": "raster"},
|
22 |
"ESRI - World Topographic": {"id": "World_Topo_Map", "source": "esri", "type": "image"},
|
23 |
"ESRI - World Street Map": {"id": "World_Street_Map", "source": "esri", "type": "image"},
|
24 |
"ESRI - World Terrain": {"id": "World_Terrain_Base", "source": "esri", "type": "image"},
|
|
|
47 |
data_key = 'rgb' if 'rgb' in asset_keys else 'data' if 'data' in asset_keys else next(iter(asset_keys))
|
48 |
return feature['assets'][data_key]['href']
|
49 |
else: # ESRI
|
50 |
+
if layer_info["type"] == "image":
|
51 |
+
return get_esri_image_url(bbox, layer_info["id"])
|
52 |
+
elif layer_info["type"] == "raster":
|
53 |
+
return get_esri_terrain_url(bbox, layer_info["id"])
|
54 |
+
return None
|
55 |
+
|
56 |
+
def get_esri_image_url(bbox, service_name):
|
57 |
+
url = f"https://services.arcgisonline.com/arcgis/rest/services/{service_name}/MapServer/export"
|
58 |
+
params = {
|
59 |
+
'bbox': f'{bbox[0]},{bbox[1]},{bbox[2]},{bbox[3]}',
|
60 |
+
'bboxSR': 4326,
|
61 |
+
'size': '1000,1000',
|
62 |
+
'imageSR': 3857,
|
63 |
+
'format': 'png',
|
64 |
+
'f': 'json'
|
65 |
+
}
|
66 |
+
response = requests.get(url, params=params)
|
67 |
+
if response.status_code == 200:
|
68 |
+
result = response.json()
|
69 |
+
if 'href' in result:
|
70 |
+
return result['href']
|
71 |
+
return None
|
72 |
+
|
73 |
+
def get_esri_terrain_url(bbox, service_name):
|
74 |
+
url = f"https://elevation.arcgis.com/arcgis/rest/services/{service_name}/ImageServer/exportImage"
|
75 |
+
params = {
|
76 |
+
'bbox': f'{bbox[0]},{bbox[1]},{bbox[2]},{bbox[3]}',
|
77 |
+
'bboxSR': 4326,
|
78 |
+
'size': '1000,1000',
|
79 |
+
'imageSR': 3857,
|
80 |
+
'format': 'tiff',
|
81 |
+
'pixelType': 'F32',
|
82 |
+
'noDataInterpretation': 'esriNoDataMatchAny',
|
83 |
+
'interpolation': '+RSP_BilinearInterpolation',
|
84 |
+
'f': 'json'
|
85 |
+
}
|
86 |
+
response = requests.get(url, params=params)
|
87 |
+
if response.status_code == 200:
|
88 |
+
result = response.json()
|
89 |
+
if 'href' in result:
|
90 |
+
return result['href']
|
91 |
return None
|
92 |
|
93 |
def main():
|