Python toolkit for downloading historical daily climatological records from Mexico's National Meteorological Service (SMN).
Spanish version: README_ES.md
SMN Climate Data Downloader is a lightweight Python toolkit designed to download historical daily climatological records from the Mexican National Meteorological Service (SMN).
The project consists of two complementary utilities:
parse_kml.pyextracts climatological station metadata from the official SMN KMZ file and generates a CSV database of available stations.downloader.pyautomatically downloads daily climatological records for every station within a selected Mexican state.
This repository was originally developed to support hydrological and hydroinformatics research, but it can also be used in environmental studies, water resources management, agriculture, and geospatial analysis. The code is intentionally simple, making it easy to understand, modify, and adapt to different research needs.
- Install the required Python packages.
- Download the official SMN climatological station KMZ file.
- Run
parse_kml.pyto generatestations_data.csv. - Set the desired state in
downloader.py. - Run
downloader.pyto download historical climatological records.
- Download historical daily climatological records directly from the official SMN website.
- Automatically retrieve data for all climatological stations within a selected Mexican state.
- Generate a station database from the official SMN KMZ file.
- Save each station's records as individual text files for further processing and analysis.
- Lightweight implementation with minimal dependencies and an easy-to-understand codebase.
- Download the official climatological station KMZ file from the SMN website.
- Run
parse_kml.pyto generate the station database (stations_data.csv). - Select the desired Mexican state in
downloader.py. - Run the downloader to retrieve historical daily climatological records for every station in that state.
Note
This repository contains only the source code. The official SMN station KMZ file must be downloaded separately from the Mexican National Meteorological Service (SMN) website. This ensures that the station database is always generated from the most up-to-date information available.
Before using this project, make sure you have:
- Python 3.9 or later
- An internet connection
- The official SMN climatological station KMZ file
The required Python packages can be installed using the provided requirements.txt file.
Clone the repository using Git:
git clone https://github.com/ximenaanell86/smn-climate-data-downloader.git
cd smn-climate-data-downloaderIf you prefer not to use Git, download the repository as a ZIP file from GitHub and extract it to your preferred working directory.
Install the project dependencies using:
pip install -r requirements.txtDownload the latest climatological station KMZ file from the official website of the Mexican National Meteorological Service (SMN):
Save the downloaded file in the root directory of the project with the following name:
EstacionesClimatologicas.kmz
Your project folder should now look similar to this:
smn-climate-data-downloader/
│
├── EstacionesClimatologicas.kmz
├── downloader.py
├── parse_kml.py
├── requirements.txt
└── ...
Run:
python parse_kml.pyThis will generate:
stations_data.csv
containing the metadata for all climatological stations available in the official SMN KMZ file.
The project is now ready to download historical climatological records.
Open downloader.py and modify the configuration variables according to the state you want to download.
For example:
STATE = "VERACRUZ DE IGNACIO DE LA LLAVE"
STATE_ABBR = "ver"The state name must match the corresponding entry in stations_data.csv.
Execute:
python downloader.pyThe script will:
- Read the station database (
stations_data.csv). - Filter stations belonging to the selected state.
- Download the historical daily climatological records for each station.
- Save the downloaded files in the
downloaded_data/directory.
During execution, the script displays the download progress in the terminal, indicating:
- Current station
- Station identifier
- Download status
- Existing files that are skipped
Example:
Downloading data for station 30003...
✓ Download completed.
Downloading data for station 30021...
✓ Download completed.
Downloading data for station 30068...
File already exists. Skipping download.
The downloaded files are stored in the downloaded_data/ directory.
Example:
downloaded_data/
│
├── 30003.txt
├── 30021.txt
├── 30068.txt
├── ...
Each file contains the historical daily climatological records provided by the Mexican National Meteorological Service (SMN).
| File | Description |
|---|---|
downloader.py |
Downloads historical daily climatological records for all stations within a selected Mexican state. |
parse_kml.py |
Extracts station metadata from the official SMN KMZ file and generates the station database. |
stations_data.csv |
CSV file containing metadata for all climatological stations. |
requirements.txt |
Lists the Python packages required to run the project. |
.gitignore |
Specifies files and directories that should not be tracked by Git. |
LICENSE |
MIT License. |
README.md |
Project documentation. |
This project is designed to work with publicly available climatological data provided by the Mexican National Meteorological Service (SMN), operated by the National Water Commission (CONAGUA).
The official climatological station catalog can be downloaded from:
This repository does not distribute or modify official SMN datasets. Users are responsible for downloading the latest station catalog directly from the official SMN website.
If you use this project in academic research, teaching, or professional work, please consider citing this repository:
Anell Parra, X. (2026). SMN Climate Data Downloader [Computer software]. GitHub. https://github.com/ximenaanell86/smn-climate-data-downloader
Possible future enhancements include:
- Support downloading data for multiple states in a single execution.
- Command-line interface (CLI) to simplify execution.
- Progress bar for large downloads.
- Automatic detection of updates to the official SMN station catalog.
- Additional export formats such as CSV or Parquet.
- Support downloading data from individual stations by station ID.
This project is distributed under the terms of the MIT License.
See the LICENSE file for more information.
This project is an independent open-source utility and is not affiliated with, endorsed by, or maintained by the Mexican National Meteorological Service (SMN) or the National Water Commission (CONAGUA).
Although every effort has been made to ensure the correctness of the code, users are encouraged to verify downloaded data and results before using them for research or operational applications.
This project was originally developed as part of hydrological and hydroinformatics research involving climatological data from the Mexican National Meteorological Service (SMN).
It is released as an open-source tool to facilitate access to historical climatological records for researchers, students, and professionals working in hydrology, environmental sciences, agriculture, water resources, and geospatial analysis.