Skip to content

Query Open Geospatial Consortium (OGC) Servers (English)

roe-dl edited this page Sep 28, 2024 · 14 revisions

What is OGC?

The Open Geospatial Consortium is a association of governmental weather services, IT companies like Google, and others. It created a format for querying location related information from servers. The american NOAA, the german DWD, and others operate OGC servers to provide weather maps, warning maps, satellite pictures, etc.

Configuration

Put the configuration into weewx.conf.

Example configuration for querying the NOAA server:

[WeatherServices]
    path = /etc/weewx/skins/SKINNAME/SUBDIRECTORY
    ...
    [[download]]
        ...
        [[[NOAA conus_cref_qcd]]]
            provider = NOAA
            model = wms
            server_url = 'https://opengeo.ncep.noaa.gov/geoserver/conus/conus_bref_qcd/ows'
            map = -130,20,70,35
            file = "conus_cref_qcd.png"
            [[[[parameters]]]]
                layers = conus_bref_qcd
                width = 512
                height = 512
                format = "image/png"
                #cql_filter = "INCLUDE"
                #styles = ''
                transparent = true

Description of the keys:

  • path: where to save the downloaded file
  • provider: name of the provider, for example NOAA
  • model: wms, optionally with version number like wms 1.1.1 or wms 1.3.0
  • server_url: URL of the server (that part of the URL up to the question mark)
  • map: map dimensions: west, south, width, height (for America, 'west' is a negative value) for WMS 1.1.1, depending on CRS for WMS 1.3.0
  • file: file name to use to save the file
  • [[[parameters]]]: URL parameters according to the OGC specification
    • crs or srs: coordinate reference system, optional on some servers, mandatory on others
    • layers: list of layers to show (mandatory)
    • width: width in pixels (mandatory)
    • height: height in pixels (mandatory)
    • format: format of the file to download (ask the provider for a list of available formats)
    • cql_filter: list of filter conditions. It has to be as long as the list of layers. If you want one layer not to be filtered, use INCLUDE instead. (optional)
    • styles: Some layers have options. This is a list of options. If present, it has to be as long as the list of layers. If there is no special option for one layer, use '' instead. (optional)
    • transparent: whether to let the background transparent (true) or white (false) (optional)
  • from_encoding: In case data is text this specifies which encoding data on the server has. (optional)
  • to_encoding: In case data is text this specifies the encoding the file is to be saved in. (optional)
  • compare_content: The target file shall only be written if the file content changed. Therefore a web server provides a modification timestamp. If that timestamp indicates that the file did not change since the last download, no download is performed at all. Unfortunately (some?) OGC servers do not provide the modification timestamp. So the only way is to compare the content of the file. This is the default, if the key compare_content is missing. Using compare_content = false you can switch off comparison.
  • log_success: whether to log successful downloads (optional)
  • log_failure: whether to log failures (optional)
  • log_sleeping: wheather to log sleeping time when the thread starts sleeping

The above example would download the file using the following URL:

https://opengeo.ncep.noaa.gov/geoserver/conus/conus_bref_qcd/ows?SERVICE=WMS&request=GetMap&format=image%2Fpng&layers=conus_bref_qcd&width=512&height=512&bbox=-130,20,-60,55

In Order to upload the downloaded file to the web server add the file name to the copy_always key in skin.conf. For the above example this would be:

...
[CopyGenerator]
    ...
    copy_always = ..., SUBDIRECTORY/conus_cref_qcd.png

Including in skins

Including image files

For the example used to explain the configuration the page template would contain:

<img src="$relative_url/SUBDIRECTORY/conus_cref_qcd.png?v=<%=os.path.getmtime("/etc/weewx/skins/SKINNAME/SUBDIRECTORY/conus_cref_qcd.png")%>" />

Imagine $relative_url as . if the template is in the base directory of the skin and .. if the template is in a subdirectory.

The part of the URL after the question mark makes sure the user's browser re-loads the file when it is changed.

Including text files

#include "SUBDIRECTORY/file.ext"

Examples

NOAA conus_cref_qcd

This example is used to describe the configuration. See above Configuration for details.

The result looks like this:

image

Meteosat satellite picture of Europe

[WeatherServices]
    path = /etc/weewx/skins/SKINNAME/SUBDIRECTORY
    ...
    [[download]]
        ...
        [[[satellite picture europe]]]
            provider = DWD
            model = wms
            map = -53.99411011583333,22.998440489999993,107.99722,53.99412
            file = meteosat-europe.png
            [[[[parameters]]]]
                layers = dwd:Satellite_meteosat_1km_euat_rgb_day_hrv_and_night_ir108_3h,dwd:Laender
                width = 1024
                height = 574
                format = "image/png"

This example would download the file using this URL:

https://maps.dwd.de/geoserver/dwd/ows?service=WMS&version=1.3&request=GetMap&bbox=-53.99411011583333,22.998440489999993,54.00310988416667,76.99256048999999&layers=dwd:Satellite_meteosat_1km_euat_rgb_day_hrv_and_night_ir108_3h,dwd:Laender&width=1024&height=574&format=image%2Fpng

The result looks like this:

image

Meteosat world mosaic infrared

[WeatherServices]
    path = /etc/weewx/skins/SKINNAME/SUBDIRECTORY
    ...
    [[download]]
        ...
                format = "image/png"
        [[[Meteosat world mosaic ir picture]]]
            provider = DWD
            model = wms
            map = -179.86289999999997,-89.92471,359.75279,179.84942
            file = meteosat-worldmosaic.png
            [[[[parameters]]]]
                layers = dwd:Satellite_worldmosaic_3km_world_ir108_3h
                width = 1024
                height = 512
                format = "image/png"

This example would download the file using this URL:

https://maps.dwd.de/geoserver/dwd/ows?service=WMS&version=1.3&request=GetMap&bbox=-179.86289999999997,-89.92471,179.88989000000004,89.92471&layers=dwd:Satellite_worldmosaic_3km_world_ir108_3h&width=1024&height=512&format=image%2Fpng

The result looks like this:

image

EUMETSAT

[WeatherServices]
    path = /etc/weewx/skins/SKINNAME/SUBDIRECTORY
    ...
    [[download]]
        ...
        [[[satellite picture of EUMETSAT]]]
            provider = EUMETSAT
            model = wms 1.3.0
            map = 22.998440489999993,-53.99411011583333,53.99412,107.99722
            file = wms-eumetsat.png
            [[[[parameters]]]]
                crs = EPSG:4326
                layers = backgrounds:ne_background,msg_fes:ir108,msg_fes:h60b,backgrounds:ne_10m_coastline,backgrounds:ne_boundary_lines_land,backgrounds:graticules-light,msg_fes:rdt
                width = 1024
                height = 574
                format = "image/png"
                transparent = true

The result would look like this:

image

Finnish Meteorological Institute (FMI)

The Finnish Meteorological Institute's open data

List of available layers

Example configuration:

[WeatherServices]
    path = /etc/weewx/skins/SKINNAME/SUBDIRECTORY
    ...
    [[download]]
        ...
        [[[korpo_etop_20]]]
            # 20 dBZ echo top from Korpo radar
            provider = FMI
            model = wms
            map = 16.487,57.657,9.711,4.821
            file = finland.png
            [[[[parameters]]]]
                crs = EPSG:4326
                layers = Basemaps:naturalearthgray,Radar:korpo_etop_20
                width = 512
                height = 512
                format = image/png

The result would look like this:

image

Links

Clone this wiki locally