Skip to content

Commit

Permalink
Merge pull request #75 from eurodatacube/mobility-data-updates
Browse files Browse the repository at this point in the history
split mobility data for RACE and trilateral
  • Loading branch information
lubojr authored Dec 19, 2023
2 parents 232cf39 + 9c9cd48 commit 5fe7fa7
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion catalogs/race.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ collections:
- OX_Crude_Oil_Storage_Index
- OX_EU_Crude_Oil_Storage_Index
# - OW_Covid_19_vaccinations
- GG_Mobility_Data
- GG_Google_Mobility_Data_RACE
# - CV_Covid_19_cases
1 change: 1 addition & 0 deletions catalogs/trilateral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ collections:
- ESDC_gross_primary_productivity
- ESDC_kndvi
- ESDC_net_ecosystem_exchange
- GG_Google_Mobility_Data_trilateral
2 changes: 1 addition & 1 deletion collections/E12c_truck_detections_motorways_GTIF.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ Resources:
Type: byoc
CollectionId: 34fbfb05-c3e5-4885-9840-830ee85dddd4
LayerId: VIS_TRUCK_DETECTION_MOTORWAYS_NEW
OverwriteBBox: [46.4, 49, 9.5, 17]
OverwriteBBox: [5.5, 44.0, 16.5, 48.7]
Image: E12c_truck_detections_motorways_GTIF/thumbnail.png
Legend: E12c_truck_detections_motorways_GTIF/cm_legend.png
2 changes: 1 addition & 1 deletion collections/E12d_truck_detections_primary_roads_GTIF.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ Resources:
Type: byoc
CollectionId: 81201dac-c408-4cf8-b9a5-ca8349e4ab6c
LayerId: VIS_TRUCK_DETECTION_PRIMARY_NEW
OverwriteBBox: [46.4, 49, 9.5, 17]
OverwriteBBox: [5.5, 44.0, 16.5, 48.7]
Image: E12d_truck_detections_primary_roads_GTIF/thumbnail.png
Legend: E12d_truck_detections_motorways_GTIF/cm_legend.png
22 changes: 22 additions & 0 deletions collections/GG_Google_Mobility_Data_RACE.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Name: GG_Google_Mobility_Data_RACE
Title: Mobility
EodashIdentifier: GG
Subtitle: Mobility data from Google
Description: GG_Google_Mobility_Data/GG.md
Themes:
- economy
Tags:
- placeholder
Satellite:
- placeholder
Sensor:
- placeholder
Agency:
- ESA
Resources:
- EndPoint: https://xcube-geodb.brockmann-consult.de/eodash/6bf15325-f6a0-4b6a-bf80-a2491753f8f2/
Name: GeoDB
Database: eodash
CollectionId: Mobility_data
AdditionalQueryString: 'aoi_id=in.("AT","BA","BE","BG","CH","CZ","DE","DK","EE","EG","ES","FI","FR","GB","GR","HR","HU","IE","IT","LT","LU","LV","MK","MT","NL","NO","PL","PT","RO","RS","RU","SE","SI","SK","TR")'
IdKey: 'aoi_id'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Name: GG_Google_Mobility_Data
Name: GG_Google_Mobility_Data_trilateral
Title: Mobility
EodashIdentifier: GG
Subtitle: Mobility data from Google
Expand All @@ -18,3 +18,4 @@ Resources:
Name: GeoDB
Database: eodash
CollectionId: Mobility_data
IdKey: 'aoi_id'
23 changes: 12 additions & 11 deletions generators/generate_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,9 @@ def add_to_catalog(collection, catalog, endpoint, data):
def handle_GeoDB_endpoint(config, endpoint, data, catalog):
collection = get_or_create_collection(catalog, endpoint["CollectionId"], data, config, endpoint)
select = "?select=aoi,aoi_id,country,city,time"
where_parameter = endpoint.get("WhereParameter")
url = endpoint["EndPoint"] + endpoint["Database"] + "_%s"%endpoint["CollectionId"] + select
if where_parameter:
url += f"&{where_parameter}"
if additional_query_parameters := endpoint.get("AdditionalQueryString"):
url += f"&{additional_query_parameters}"
response = json.loads(requests.get(url).text)

# Sort locations by key
Expand All @@ -354,15 +353,17 @@ def handle_GeoDB_endpoint(config, endpoint, data, catalog):
unique_values = list({v["aoi_id"]:v for v in values}.values())[0]
country = unique_values["country"]
city = unique_values["city"]
IdKey = endpoint.get("IdKey", "city")
IdValue = unique_values[IdKey]
if country not in countries:
countries.append(country)
# sanitize city identifier to be sure it is filename save
if city is not None:
city = "".join([c for c in city if c.isalpha() or c.isdigit() or c==' ']).rstrip()
# Additional check to see if city name is empty afterwards
if city == "" or city is None:
# use aoi_id as a fallback unique id instead of city
city = key
# sanitize unique key identifier to be sure it is saveable as a filename
if IdValue is not None:
IdValue = "".join([c for c in IdValue if c.isalpha() or c.isdigit() or c==' ']).rstrip()
# Additional check to see if unique key name is empty afterwards
if IdValue == "" or IdValue is None:
# use aoi_id as a fallback unique id instead of configured key
IdValue = key
if city not in cities:
cities.append(city)
min_date = min(times)
Expand All @@ -373,7 +374,7 @@ def handle_GeoDB_endpoint(config, endpoint, data, catalog):
buff = 0.01
bbox = [lon-buff, lat-buff,lon+buff,lat+buff]
item = Item(
id = city,
id = IdValue,
bbox=bbox,
properties={},
geometry = create_geojson_point(lon, lat),
Expand Down

0 comments on commit 5fe7fa7

Please sign in to comment.