Skip to content

thutil/OpenTH-Radar

Repository files navigation

OpenTH-Radar

Overview

An open-source tool for converting radar images to map tiles.

TMD Map TMD Output

Get Started

Based on your request, you want to modify the execution frequency of the automatic image download from every 15 minutes to a different interval. The modification needs to be done in the Dockerfile section that sets up the cron job. Here is the explanation and the suggested change.

Modifying the Execution Frequency

The part of your Dockerfile that controls the 15-minute interval is this line:

RUN echo "*/15 * * * * cd /app && ./main.sh >> /app/logs/cron.log 2>&1" | crontab -

The string "_/15 _ * * *" is the cron expression which currently means "execute the command at every 15th minute (0, 15, 30, 45) of every hour, every day."

Example: Changing to Every 5 Minutes

If you want the job to run every 5 minutes, you would change _/15 to _/5.

Modified Dockerfile

Here is the Dockerfile with the automatic download frequency changed to run every 5 minutes (you can replace _/5 with any interval you prefer, e.g., _/10 for every 10 minutes).

RUN sed -i 's/\r$//' main.sh && chmod +x main.sh
RUN sed -i 's/\r$//' clear_radar.sh && chmod +x clear_radar.sh
RUN mkdir -p /app/radar /app/out /app/logs
RUN echo "*/5 * * * * cd /app && ./main.sh >> /app/logs/cron.log 2>&1" | crontab - # <-- MODIFIED HERE
RUN echo "0 0 * * * cd /app && ./clear_radar.sh >> /app/logs/cron.log 2>&1" | crontab -l | { cat; } | crontab -
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

Usage

After modifying the Dockerfile, you must rebuild and restart the Docker container for the changes to take effect:

  1. build image docker compose build
  2. Restart the service docker compose up -d

Configuration Files (No Changes Needed)

This file is fine and does not need modification to change the cron schedule.

services:
  radar-service:
    build: .
    container_name: openth-radar
    ports:
      - "8000:8000"
    volumes:
      - ./radar:/app/radar
      - ./geotif:/app/geotif
      - ./logs:/app/logs
      - ./out:/app/out
    environment:
      - PYTHONPATH=/app
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

Important Folders

  • radar: Stores map tiles, grouped by time.
  • logs: Stores the log files for the scheduled job (cron.log).
  • geotif: (Mounted, presumably for source data).
  • out: (Mounted, presumably for output files).

API

Provides a simple API to serve radar images as map tiles, making it easy to integrate with mapping libraries like Maplibre or OpenLayers and Thailand map providers such as Longdo Map, sphere Map.

JSON Response Example

{
  "version": "1.0",
  "generated": 1758806914,
  "host": "http://localhost:8000",
  "radar": {
    "past": [
      {
        "time": 1758801000,
        "path": "/radar/1758801000"
      }
    ]
  }
}

Tile URL Example

<BASE_URL>/radar/<PATH>/{z}/{x}/{y}.png

ROADMAPS

1. Heatmap Visualization

Added a heatmap feature to enhance the visual representation of radar data. The heatmap makes patterns and intensity levels more apparent, resulting in a more attractive and informative display.

TMDRawRadar TMDHeatmap

2. Forecast

Implemented a forecasting feature that predicts future radar images based on historical data. This allows users to visualize potential weather developments and plan accordingly.

License

This project is licensed under the MIT License.