Commit 2646e972 authored by Sonja Tripkovic's avatar Sonja Tripkovic

Updates to pull_from_geodatenviewer_meas and pull_from_geodatenviewer_list in fetch.py

parent 2335e4ae
......@@ -131,12 +131,14 @@ def pull_from_geodatenviewer_list(squares: List[str]) -> gpd.GeoDataFrame:
# downloading .zip files
# example of single square with data: https://www.wien.gv.at/ma41datenviewer/downloads/ma41/geodaten/fmzk_bkm/103081_bkm.zip
for square_number in squares:
urllib.request.urlretrieve(
"https://www.wien.gv.at/ma41datenviewer/downloads/geodaten/fmzk_bkm/{}_bkm.zip".format(
square_number
),
os.path.join(dir_path, "{}.zip".format(square_number)),
)
try:
urllib.request.urlretrieve(
"https://www.wien.gv.at/ma41datenviewer/downloads/geodaten/fmzk_bkm/{}_bkm.zip".format(
square_number
),
os.path.join(dir_path, "{}.zip".format(square_number)),
)
except: continue
# extracting and deleting .zip files
for item in os.listdir(dir_path): # loop through items in dir
......@@ -150,8 +152,10 @@ def pull_from_geodatenviewer_list(squares: List[str]) -> gpd.GeoDataFrame:
# combine all .shp files
geo_df_all = pd.DataFrame()
for square in squares:
geo_df = gpd.read_file(os.path.join(dir_path, square + "_bkm.shp"))
geo_df_all = pd.concat([geo_df_all, geo_df], ignore_index=True)
try:
geo_df = gpd.read_file(os.path.join(dir_path, square + "_bkm.shp"))
geo_df_all = pd.concat([geo_df_all, geo_df], ignore_index=True)
except: continue
shutil.rmtree(dir_path) # deletes the directory containing all the files
return geo_df_all
......@@ -187,10 +191,8 @@ def pull_from_geodatenviewer_meas(
for file in os.listdir(raster_path):
if file.endswith(".shp"):
raster_gdf = gpd.read_file(os.path.join(raster_path, file))
if raster_gdf.geometry.crs != "EPSG:4326":
raise ValueError(
"Raster EPSG has changed, see https://www.data.gv.at/katalog/dataset/b2d17060-b2f4-4cd7-a2e5-64beccfeb4c1 for mor information."
)
raster_gdf.to_crs(4326,inplace=True)
meas_gdf = gpd.GeoDataFrame(geometry=measurement_coords)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment