Skip to content

Koninklijk Nederlands Meteorologisch Instituut (KNMI)

roe-dl edited this page Oct 3, 2024 · 14 revisions

What is KNMI?

The Koninklijk Nederlands Meteorologisch Instituut (KNMI) is the governmental weather service of the Netherlands. As every weather service in the EU they provide a lot of data for free, this time under the CC BY 4.0 license.

Using KNMI API with WeeWX

To retrieve data from KNMI you need to register with them at their developer portal and obtain an API key. There are different API keys for different services, but all of them you get in one place.

Please, don't forget to mention KNMI as data source and provide a link to their website, as the license requires.

Text forecasts

The KNMI data platform provides various text forecasts for download. Using weewx-DWD you can download them and include them in your web site. See weather forecast datasets page for a list of available data.

Configuration

[WeatherServices]
    path = '/etc/weewx/skins/SKINNAME/SUBDIRECTORY'
    [[forecast]]
        [[[description_of_the_file_to_download]]]
            provider = KNMI
            model = name_of_dataset
            content_type = 'MIME type or file name extension'
            file = 'target-filename'
            api_key = 'the API key you got from KNMI'
    [[download]]
        [[[description_of_the_file_to_download]]]
            provider = KNMI
            model = opendata
            url = 'https://api.dataplatform.knmi.nl/open-data/v1/datasets/<dataset-name>/versions/1.0'
            content_type = 'MIME type or file name extension'
            file = 'target-filename'
            api_key = 'the API key you got from KNMI'

model values:

  • opendata: general name to use with the url key
  • short_term_weather_forecast:
  • waarschuwingen_nederland_48h:
  • waarschuwingen_kustdistricten:
  • marifoon:

Example: short term weather forecast

[WeatherServices]
    path = '/etc/weewx/skins/SKINNAME/SUBDIRECTORY'
    [[forecast]]
        [[[short term weather forecast text]]]
            provider = KNMI
            model = short_term_weather_forecast
            content_type = 'html' # or 'txt' or 'xml'
            file = 'basisverwachting.html'
            api_key = 'the API key you got from KNMI'

or in general notation:

[WeatherServices]
    path = '/etc/weewx/skins/SKINNAME/SUBDIRECTORY'
    [[download]]
        [[[short term weather forecast text]]]
            provider = KNMI
            model = opendata
            url = 'https://api.dataplatform.knmi.nl/open-data/v1/datasets/short_term_weather_forecast/versions/1.0'
            content_type = 'html' # or 'txt' or 'xml'
            file = 'basisverwachting.html'
            api_key = 'the API key you got from KNMI'

Including in skins

for the example above:

#include raw "SUBDIRECTORY/basisverwachting.html"

Example text forecast:

image

Weather maps from KNMI data platform

Configuration

[WeatherServices]
    path = '/etc/weewx/skins/SKINNAME/SUBDIRECTORY'
    [[download]]
        [[[short term weather forecast text]]]
            provider = KNMI
            model = opendata
            url = 'https://api.dataplatform.knmi.nl/open-data/v1/datasets/weather_maps/versions/1.0'
            content_type = 'gif'
            file = 'AL.gif'
            api_key = 'the API key you got from KNMI'

Including in skins

<img src="SUBDIRECTORY/AL.gif" width="100%" alt="weer map" />

Example:

image

Other sources

A similar map can be obtained from the german weather service DWD by using the following configuration:

[WeatherServices]
    path = '/etc/weewx/skins/SKINNAME/SUBDIRECTORY'
    [[download]]
        [[[DWD-BWK]]]
            provider = DWD
            model = bwk-map

The target file is bwk_bodendruck_na_ana.png if not set up otherwise.

Other data from the KNMI data platform

See here for available data. Configuration is as described before.

Example:

[WeatherServices]
    path = '/etc/weewx/skins/SKINNAME/SUBDIRECTORY'
    [[download]]
        [[[aardbevingen_cijfers]]]
            provider = KNMI
            model = opendata
            url = 'https://api.dataplatform.knmi.nl/open-data/v1/datasets/aardbevingen_cijfers/versions/1/files/incident-parameters'
            file = 'incident-parameters.json'
            api_key = 'the API key you got from KNMI'

In this example, the dataset aardbevingen_cijfers contains one single content type only (that is JSON), but 3 different files, called trend-parameters, incident-parameters, and aantal-aardbevingen. Therefore the URL has a files part here, which was not the case for the other examples shown before.

To present the contents of the JSON file on your web site you may need to write some JavaScript code within the skin.

KNMI OGC server

KNMI operates an OGC server, too. See Query Open Geospatial Consortium (OGC) Servers for more details on using OGC servers.

Example:

[WeatherServices]
    path = '/etc/weewx/skins/SKINNAME/SUBDIRECTORY'
    [[download]]
        [[[precipitation radar]]]
            provider = KNMI
            model = wms
            map = 50.7,3.0,3.3,4.3
            server_url = 'https://api.dataplatform.knmi.nl/wms/adaguc-server'
            dataset = radar_reflectivity_composites
            file = 'neerslag.png'
            api_key = 'the API key you got from KNMI'
            [[[[parameters]]]]
                format = image/png
                width = 512
                height = 512
                crs = EPSG:4326
                layers = precipitation
                transparent = true
        [[[baselayers]]]
            provider = KNMI
            model = wms
            map = 50.7,3.0,3.1,4.3
            server_url = 'https://geoservices.knmi.nl/wms'
            api_key = 'the API key you got from KNMI'
            dataset = baselayers
            file = 'baselayers.png'
            [[[[parameters]]]]
                #request = GetMap
                #version = 1.1.1
                format = image/png
                width = 512
                height = 512
                crs = EPSG:4326
                layers = countryborders

This results in 2 files, that can be put one over the other. The baselayers.png file contains the borders and the coast line of the Netherlands. The neerslag.png file contains the radar data. Please note, the both need to have the same values of the map, width, and height keys.

The HTML code could look like this:

    <div style="display:block">
        <div style="position:absolute;top:0px;left:0px">
          <img src="baselayers.png" width="100%" />
        </div>
        <div style="position:absolute;top:0px;left:0px">
          <img src="neerslag.png" width="100%" />
        </div>
    </div>

The result then would look like this:

Links

Clone this wiki locally