Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Forecast lookup by latitude, longitude rather than station name? #2

Open
drmrbrewer opened this issue Jan 8, 2020 · 1 comment
Open

Comments

@drmrbrewer
Copy link

This library looks promising, thanks!

Is it possible to do a forecast data lookup based on latitude, longitude? I can't see anything in the examples... it would be something similar to what is in In [1] to In [3] of this page but using lat/long rather than e.g. "Berlin".

@bakunin75
Copy link

bakunin75 commented Jan 8, 2020

You can use the following workaround to obtain the station_id of the closest station to your input lat and lon.

import pandas as pd
from dwdbulk.api import observations

resolution = "10_minutes"
parameter = "air_temperature"
df_stations = observations.get_stations(resolution,parameter)
lat, lon = .., ..
df_stations["delta_lon_lat"] = (df_stations.geo_lon - lon).abs() + (df_stations.geo_lat-lat).abs()
df_stations.sort_values(by="delta_lon_lat", inplace=True)
station_id = df_stations.station_id.iloc[0]

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants