-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretrieve_bounds.py
More file actions
38 lines (31 loc) · 1.29 KB
/
Copy pathretrieve_bounds.py
File metadata and controls
38 lines (31 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Import libraries:
import rasterio
import pandas as pd
# Create a list ranging from 01 to 43:
list_43 = list(range(1,44))
updated_list = []
for i in list_43:
i = str(i)
i = i.zfill(2)
updated_list.append(i)
# Create a list of dictionaries with the following info: DTM file URL, DSM file URL, bounds - left, bounds - right, bounds - top, bounds - bottom:
DTM_bounds = []
for i in updated_list:
url_dtm = f'zip+https://downloadagiv.blob.core.windows.net/dhm-vlaanderen-ii-dtm-raster-1m/DHMVIIDTMRAS1m_k{i}.zip!/GeoTIFF/DHMVIIDTMRAS1m_k{i}.tif'
url_dsm = f'zip+https://downloadagiv.blob.core.windows.net/dhm-vlaanderen-ii-dsm-raster-1m/DHMVIIDSMRAS1m_k{i}.zip!/GeoTIFF/DHMVIIDSMRAS1m_k{i}.tif'
print(f"Accesssing {i}")
DTM_file = rasterio.open(url_dtm)
print(f"Opened DTM file {i}")
DTM_bounds.append({
'url_dtm': url_dtm,
'url_dsm' : url_dsm,
'left' : DTM_file.bounds.left,
'right' : DTM_file.bounds.right,
'top' : DTM_file.bounds.top,
'bottom' : DTM_file.bounds.bottom
})
print(f"Added bounds of DTM file {i}")
#Create a data frame from dictionary:
DTM_bounds_df = pd.DataFrame.from_dict(DTM_bounds)
# Save the data frame as .csv:
DTM_bounds_df.to_csv('DTM_bounds.csv', encoding='utf-8', index=False)