Download the PHP package cstuder/parse-swissmetnet without Composer

On this page you can find all versions of the php package cstuder/parse-swissmetnet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package parse-swissmetnet

parse-swissmetnet

Project Status: Active – The project has reached a stable, usable state and is being actively developed. PHPUnit tests

Simple PHP package to parse SwissMetNet Open Data strings.

Disclaimer: This library is not official and not affiliated with MeteoSwiss.

Created for usage on api.existenz.ch and indirectly on Aare.guru. As of 2025 in productive use.

SwissMetNet

Starting from may 2025, MeteoSwiss (Bundesamt für Meteorologie und Klimatologie/Federal Office of Meteorology and Climatology) publishes their SwissMetNet measurement data on the new OGD Portal. See their Open Data Documentation for further information.

Measures air temperatures, rain rate/precipitation, wind, pressure, geopotentials, sunshine duration and more. Not every station measures every parameter.

Note that most stations measure this 2 meters above ground, but some tower stations locate their sensors higher in the air. The parameters with suffix _tow are measured on tower stations.

Periodicity: 10 minutes.

Licencing restrictions apply by MeteoSwiss. CC-BY. You will have to credit any usage of the data with the string "Source: MeteoSwiss". See the official Terms of Use for details.

Getting the data

  1. Go to the STAC browser for the Automatic weather stations.
  2. Download the assets for station and parameter metadata CSV files.
  3. Go to the desired station.
  4. Download the assets for the measurement data as CSV files.

There is a special file called VQHA80.csvonly mentioned in the documentation. It contains last measured values for all stations for the main parameters. This file is updated every 10 minutes.

Data format 2025

Starting from may 2025 the assets with historical data are published. They differ slightly again from the previous format: Different headers and a different time format:

Data format 2020

Starting from 2020-10-19 the data format of VQHA80 changed slighty from the orginial CSV format: They are now valid CSV files, semicolon separated, with a new header line:

Data format

MeteoSwiss data files VQHA80 are semicolon separated CSVs with a custom header:

Legay data format

Older data files like VQHA69.csv used the pipe symbol as separators:

Metadata format

The legacy metadata files are free form textual files with space separated tables. Good luck parsing those.

Encoding is ISO-8859-1. This library outputs UTF-8.

Starting from 2021, the metadata is split up into two files: A text file (I.e. VQHA80_en.txt) containing the parameter metadata and a link to a CSV (I.e. ch.meteoschweiz.messnetz-automatisch_en.csv) containing the location metadata.

Starting from 2025, all metadata is published as CSV files. (ogd-smn_meta_stations.csv and ogd-smn_meta_parameters.csv).

Installation

composer require cstuder/parse-swissmetnet

Example usage

See the bin directory for more working code.

Methods

The parser is intentionally limited: It parses the given string and returns all data which looks valid. It silently skips over any line it doesn't understand.

Values are converted to float. Missing data values are not returned, the values will never be null.

SuperParser::parse(string $raw)

Parses a SwissMetNet data string, tries out all available parsers one after another. If any of them finds anything, returns that data.

Returns an empty row if no parsers find anything. Use at your own risk.

Returns a row of value objects with the keys timestamp, loc, par, val.

DataParser2025::parse(string $raw)

Parses a SwissMetNet data string containing semicolon separated measurements in the OGD 2025 version.

Returns a row of value objects with the keys timestamp, loc, par, val.

DataParser2020::parse(string $raw)

Parses a SwissMetNet data string containing semicolon separated measurements in the 2020 version.

Returns a row of value objects with the keys timestamp, loc, par, val.

DataParser::parse(string $raw)

Parses a SwissMetNet data string containing semicolon separated measurements.

Returns a row of value objects with the keys timestamp, loc, par, val.

LegacyDataParser::parse(string $raw)

Parses an older SwissMetNet data string containing pipe separated measurements.

Returns a row of value objects with the keys timestamp, loc, par, val.

MetadataParser::parse(string $raw)

Parses a SwissMetNet description string containing location and parameter definitions.

Returns two fields: locations and parameters, both containing arrays of StdClass objects with fields such as location coordinates or parameter units.

This parse method behaves like the SuperParser: It tries parsing text files à la VQHA80_en.txt and CSV files à la ch.meteoschweiz.messnetz-automatisch_en.txt. It combines the found metadata into one list.

MetadataParser::parseFromTextFile(string $raw)

Parses a SwissMetNet description string from a file like VQHA80_en.txt containing location and parameter definitions.

Returns two fields: locations and parameters, both containing arrays of StdClass objects with fields such as location coordinates or parameter units.

MetadataParser::parseFromCsvFile(string $raw)

Parses a SwissMetNet description string from a file like ogd-smn_meta_stations.csv containing location and parameter definitions.

Returns two fields: locations and parameters, both containing arrays of StdClass objects with fields such as location coordinates or parameter units.

Testing

Run composer test to execute the PHPUnit test suite.

Releasing

  1. Add changes to the changelog.
  2. Add new parsers to the SuperParser.
  3. Create a new tag vX.X.X.
  4. Push.

License

MIT.

Author

Christian Studer [email protected], Bureau für digitale Existenz.


All versions of parse-swissmetnet with dependencies

PHP Build Version
Package Version
Requires cstuder/parse-valueholder Version ^0.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cstuder/parse-swissmetnet contains the following files

Loading the files please wait ....