Skip to content

sheffieldhackspace/water-level-monitoring-grafana

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

River Flood Monitoring API

Stations within 5 km of Sheffield Hackspace

table of water monitoring stations

map of water monitoring stations

URLs:

# save
curl "https://environment.data.gov.uk/flood-monitoring/id/stations?lat=53.369771&long=-1.474261&dist=5" \
  > stations.json

$ cat stations.json | jq -r '.items | length | tostring + " total stations"'
14 total stations

# print results nicely
$ cat stations.json | jq -r '.items | .[] | ("\(.RLOIid) (\(.label)) measures " + (.measures|length|tostring) + " quantities\n  opened \(.dateOpened) at \(.lat) \(.long)\n  and is in \(.riverName), \(.town)")'
8339 (Sheffield Oakbrook Road) measures 1 quantities
  opened 2005-12-09 at 53.367798 -1.521432
  and is in Porter Brook, Sheffield
8308 (Sheffield Centenary Works) measures 1 quantities
  opened 1998-01-16 at 53.351517 -1.484072
  and is in River Sheaf, Sheffield
…

# save as CSV
cat stations.json | jq -r '.items | .[] |= (.measures = (.measures|length))' | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' | csvtool paste - \
  > stations.csv

# turn CSV to geojson
# rename headers "lat" to "latitude" first and use code from https://blog.alifeee.co.uk/notes/making-a-geojson-file-from-a-csv/
cat stations.csv | sed '1s+,lat,+,latitude,+;1s+,long,+,longitude,+' | jq -Rn '(input|split(",")) as $headers | ($headers|[index("longitude"), index("latitude")]) as $indices | {"type": "FeatureCollection", "features": [inputs|split(",") | {"type": "Feature", "properties": ([($headers), .] | transpose | map( { "key": .[0], "value": .[1] } ) | from_entries | del(.latitude, .longitude)), "geometry": {"type": "Point", "coordinates": [(.[$indices[0]]|tonumber), (.[$indices[1]]|tonumber)]}}]}' \
  > stations.geojson

# single station data
$ curl "https://environment.data.gov.uk/flood-monitoring/id/stations/F0402/readings?_sorted" \
  > F0402.json
$ cat F0402.json | jq -r '.items | min_by(.dateTime | fromdate) | ("\(.value) on \(.dateTime)")'
0.198 on 2025-09-17T05:45:00Z
$ cat F0402.json | jq -r '.items | max_by(.dateTime | fromdate) | ("\(.value) on \(.dateTime)")'
0.216 on 2025-09-22T10:30:00Z

# plot
cat F0402.json \
  | jq -r '.items | .[] | (.dateTime | fromdate|tostring) + "\t" + (.value|tostring)' \
  | eplot -t "Level"

graph of water level over time

data can be plotted on Grafana using the Infinity datasource to load JSON.

screenshot of grafana dashboard showing water level data

About

showing local river water levels on a grafana dashboard

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published