Update pages/12_🌲_VertXtractor.py
Browse files- pages/12_🌲_VertXtractor.py +32 -11
pages/12_🌲_VertXtractor.py
CHANGED
@@ -9,6 +9,25 @@ import json
|
|
9 |
|
10 |
st.set_page_config(layout="wide", page_title="Extracteur de données géospatiales")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
LAYERS = {
|
13 |
"Swisstopo - SWISSIMAGE 10 cm": {"id": "ch.swisstopo.swissimage-dop10", "source": "swisstopo", "type": "image"},
|
14 |
"Swisstopo - Carte nationale 1:25'000": {"id": "ch.swisstopo.pixelkarte-farbe-pk25.noscale", "source": "swisstopo", "type": "image"},
|
@@ -18,7 +37,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"},
|
@@ -54,43 +73,45 @@ def get_swisstopo_url(bbox, layer_info):
|
|
54 |
return None
|
55 |
|
56 |
def get_esri_url(bbox, layer_info):
|
|
|
|
|
|
|
|
|
57 |
if layer_info["type"] == "image":
|
58 |
-
return get_esri_image_url(bbox,
|
59 |
elif layer_info["type"] == "raster":
|
60 |
-
return get_esri_terrain_url(bbox,
|
61 |
return None
|
62 |
|
63 |
-
def get_esri_image_url(bbox,
|
64 |
-
url = f"https://services.arcgisonline.com/arcgis/rest/services/{service_name}/MapServer/export"
|
65 |
params = {
|
66 |
'bbox': f'{bbox[0]},{bbox[1]},{bbox[2]},{bbox[3]}',
|
67 |
'bboxSR': 4326,
|
68 |
'size': '1000,1000',
|
69 |
'imageSR': 3857,
|
70 |
-
'format': 'png',
|
71 |
'f': 'json'
|
72 |
}
|
73 |
-
response = requests.get(
|
74 |
if response.status_code == 200:
|
75 |
result = response.json()
|
76 |
if 'href' in result:
|
77 |
return result['href']
|
78 |
return None
|
79 |
|
80 |
-
def get_esri_terrain_url(bbox,
|
81 |
-
url = f"https://elevation.arcgis.com/arcgis/rest/services/{service_name}/ImageServer/exportImage"
|
82 |
params = {
|
83 |
'bbox': f'{bbox[0]},{bbox[1]},{bbox[2]},{bbox[3]}',
|
84 |
'bboxSR': 4326,
|
85 |
'size': '1000,1000',
|
86 |
'imageSR': 3857,
|
87 |
-
'format': 'tiff',
|
88 |
'pixelType': 'F32',
|
89 |
'noDataInterpretation': 'esriNoDataMatchAny',
|
90 |
'interpolation': '+RSP_BilinearInterpolation',
|
91 |
'f': 'json'
|
92 |
}
|
93 |
-
response = requests.get(
|
94 |
if response.status_code == 200:
|
95 |
result = response.json()
|
96 |
if 'href' in result:
|
|
|
9 |
|
10 |
st.set_page_config(layout="wide", page_title="Extracteur de données géospatiales")
|
11 |
|
12 |
+
# Dictionnaires d'ESRI_extractor
|
13 |
+
ESRI_SERVICES = {
|
14 |
+
'World_Imagery' : 'https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer',
|
15 |
+
'World_Topo_Map' : 'https://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer',
|
16 |
+
'World_Shaded_Relief' : 'https://services.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer',
|
17 |
+
'World_Terrain_Base' : 'https://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer',
|
18 |
+
'World_Street_Map' : 'https://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer',
|
19 |
+
'World_Elevation' : 'https://elevation.arcgis.com/arcgis/rest/services/WorldElevation/Terrain/ImageServer',
|
20 |
+
}
|
21 |
+
|
22 |
+
ESRI_FORMATS = {
|
23 |
+
'png' : 'png',
|
24 |
+
'png8' : 'png8',
|
25 |
+
'png24' : 'png24',
|
26 |
+
'png32' : 'png32',
|
27 |
+
'jpg' : 'jpg',
|
28 |
+
'tiff' : 'tiff',
|
29 |
+
}
|
30 |
+
|
31 |
LAYERS = {
|
32 |
"Swisstopo - SWISSIMAGE 10 cm": {"id": "ch.swisstopo.swissimage-dop10", "source": "swisstopo", "type": "image"},
|
33 |
"Swisstopo - Carte nationale 1:25'000": {"id": "ch.swisstopo.pixelkarte-farbe-pk25.noscale", "source": "swisstopo", "type": "image"},
|
|
|
37 |
"Swisstopo - Réseau hydrographique": {"id": "ch.bafu.vec25-gewaessernetz", "source": "swisstopo", "type": "vector"},
|
38 |
"Swisstopo - swissBUILDINGS3D 3.0 Beta": {"id": "ch.swisstopo.swissbuildings3d_3_0", "source": "swisstopo", "type": "3d"},
|
39 |
"ESRI - World Imagery": {"id": "World_Imagery", "source": "esri", "type": "image"},
|
40 |
+
"ESRI - World Elevation": {"id": "World_Elevation", "source": "esri", "type": "raster"},
|
41 |
"ESRI - World Topographic": {"id": "World_Topo_Map", "source": "esri", "type": "image"},
|
42 |
"ESRI - World Street Map": {"id": "World_Street_Map", "source": "esri", "type": "image"},
|
43 |
"ESRI - World Terrain": {"id": "World_Terrain_Base", "source": "esri", "type": "image"},
|
|
|
73 |
return None
|
74 |
|
75 |
def get_esri_url(bbox, layer_info):
|
76 |
+
service_url = ESRI_SERVICES.get(layer_info["id"])
|
77 |
+
if not service_url:
|
78 |
+
return None
|
79 |
+
|
80 |
if layer_info["type"] == "image":
|
81 |
+
return get_esri_image_url(bbox, service_url)
|
82 |
elif layer_info["type"] == "raster":
|
83 |
+
return get_esri_terrain_url(bbox, service_url)
|
84 |
return None
|
85 |
|
86 |
+
def get_esri_image_url(bbox, service_url):
|
|
|
87 |
params = {
|
88 |
'bbox': f'{bbox[0]},{bbox[1]},{bbox[2]},{bbox[3]}',
|
89 |
'bboxSR': 4326,
|
90 |
'size': '1000,1000',
|
91 |
'imageSR': 3857,
|
92 |
+
'format': ESRI_FORMATS['png'],
|
93 |
'f': 'json'
|
94 |
}
|
95 |
+
response = requests.get(f"{service_url}/export", params=params)
|
96 |
if response.status_code == 200:
|
97 |
result = response.json()
|
98 |
if 'href' in result:
|
99 |
return result['href']
|
100 |
return None
|
101 |
|
102 |
+
def get_esri_terrain_url(bbox, service_url):
|
|
|
103 |
params = {
|
104 |
'bbox': f'{bbox[0]},{bbox[1]},{bbox[2]},{bbox[3]}',
|
105 |
'bboxSR': 4326,
|
106 |
'size': '1000,1000',
|
107 |
'imageSR': 3857,
|
108 |
+
'format': ESRI_FORMATS['tiff'],
|
109 |
'pixelType': 'F32',
|
110 |
'noDataInterpretation': 'esriNoDataMatchAny',
|
111 |
'interpolation': '+RSP_BilinearInterpolation',
|
112 |
'f': 'json'
|
113 |
}
|
114 |
+
response = requests.get(f"{service_url}/exportImage", params=params)
|
115 |
if response.status_code == 200:
|
116 |
result = response.json()
|
117 |
if 'href' in result:
|