Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions dcc_allmend_fluesse/etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@

BUFFER_M = 150
EVENT_TYPES = ["Veranstaltung", "Aktivität", "Festivität"]
ALLMEND_PARAMS = {"where": "belgartbez IN (" + ", ".join(f'"{t}"' for t in EVENT_TYPES) + ")"} # to filter the event_types already while pulling the data
ALLMEND_PARAMS = {
"where": "belgartbez IN (" + ", ".join(f'"{t}"' for t in EVENT_TYPES) + ")"
} # to filter the event_types already while pulling the data

OUTPUT_COLUMNS = ["Bezeichnung", "Belegstatus", "datum_von", "datum_bis", "Nähe_Flüsse", "Link"]

MAX_URL_LENGTH = 2000 # common safe threshold for URL length

# ------------------- extract --------------------------------


def allmend_has_changed(saved_date: Path) -> bool:

r = common.requests_get("https://data.bs.ch/api/explore/v2.1/catalog/datasets/100018")
Expand All @@ -50,8 +53,9 @@ def allmend_has_changed(saved_date: Path) -> bool:
file.write_text(new_value)
return True

# downloads the two data sets, allmendbewilligungen and gewässerachsen, as geojson
def download(source_path: Path, path: Path, *, params: dict | None=None):

# downloads the two data sets, allmendbewilligungen and gewässerachsen, as geojson
def download(source_path: Path, path: Path, *, params: dict | None = None):

logging.info("trying to downlad the data files")

Expand All @@ -73,8 +77,12 @@ def load_river_lines(rivers_path: Path) -> tuple[gpd.GeoDataFrame, gpd.GeoDataFr
rhein = gdf[gdf["gz_gewaessername"] == "Rhein"]
wiese = gdf[gdf["gz_gewaessername"] == "Wiese"]
birs = gdf[gdf["gz_gewaessername"] == "Birs"]

return [rhein.to_crs(CRS_SWISS).geometry.union_all(), wiese.to_crs(CRS_SWISS).geometry.union_all(), birs.to_crs(CRS_SWISS).geometry.union_all()]

return [
rhein.to_crs(CRS_SWISS).geometry.union_all(),
wiese.to_crs(CRS_SWISS).geometry.union_all(),
birs.to_crs(CRS_SWISS).geometry.union_all(),
]


def make_query_url(field, values, base_url="https://data.bs.ch/explore/dataset/100018/table/"):
Expand Down