日本語のREADMEはこちらです: README.ja.md
This project automatically scrapes river water level data from the Fukui Prefecture's disaster information website, converts it into an open CSV format, and provides real-time visualizations.
- Map View: An interactive map showing the latest water level at each sensor, color-coded by the official alert status.
- Graph View: A map that visualizes the recent water level trend for each sensor as a simple bar chart relative to its danger level.
- Automated Data Collection: A GitHub Action runs hourly to fetch the latest data.
- Open Data in CSV Format: All sensor metadata and time-series data are stored in easy-to-use CSV files.
- Interactive Visualizations: Two web-based maps for at-a-glance status and trend analysis.
- Geospatial API: Includes a JavaScript module to find the nearest water level sensor to any geographic coordinate.
- sensors.csv: A master list of all monitoring stations. Includes ID, name, river, geographic location (Geo3x3), and official alert level thresholds (e.g., flood warning level, evacuation level).
- Daily Data Directory: Contains daily time-series data files named
yyyy-mm-dd.csv. Each file contains readings for all sensors for that day.
- A GitHub Actions workflow (
.github/workflows/scheduled-fetch.yml) is triggered every hour. - The workflow executes the Deno script
makeData.js. - This script scrapes the HTML from the Fukui Prefecture's river information map.
- The raw HTML is parsed to extract the latest water level reading for each sensor.
- The new data is appended to the CSV file for the current day in the
/datadirectory. - The updated data file is automatically committed and pushed back to this repository.
- Deno (v1.x)
To perform a one-time data fetch, clone the repository and run:
deno run -A makeData.jsYou can use the getNearest.js module in your own projects to find the closest water level sensor and its latest reading for a given latitude and longitude.
import { getNearest } from "https://code4fukui.github.io/waterlevel_fukui/getNearest.js";
// Example: Find the nearest sensor to your current location
const nearestSensor = await getNearest(35.943, 136.188);
console.log(nearestSensor);
/*
Outputs an object with sensor metadata and the latest water level reading:
{
id: "1",
観測所名: "九十九橋",
河川名: "足羽川",
// ... other sensor metadata
geo3x3: "E9138735961882",
distance: 2453.9, // distance in meters
日時: "2023-09-14T10:10",
河川水位: