imd_stations: IMD weather stations with coordinates

View source: R/imd_stations.R

IMDStationsR Documentation

IMD weather stations with coordinates

Description

Gets the India Meteorological Department (IMD) city-weather station list. As an option, it also gets the latitude and longitude of each station. The legacy IMD endpoints give only the station names. The responsive IMD site gives a JSON record for each station (api/fetchCity_static.php). This record contains lat and lon. The function adds these values to the station list. You can use the returned coordinates directly as input to era5ify_point(). You can also use them to make maps.

Usage

IMDStations(...)

imd_stations(
  with_coordinates = TRUE,
  cores = if (.Platform$OS.type == "windows") 1L else 2L
)

Arguments

...

Not used. This argument is necessary for compatibility with the aliases.

with_coordinates

Logical. If TRUE (default), the function gets latitude and longitude for each station (one request for each station). If FALSE, the function returns only station_id and name.

cores

Integer. The number of parallel workers that get the coordinates (the function sends this value to parallel::mclapply()). The default is 2 (1 on Windows, where forking is not available).

Value

A data.frame with the columns station_id and name. If with_coordinates = TRUE, the data frame also has the columns latitude and longitude. The value is NA if IMD has no coordinate for a station.

Examples


stations <- tryCatch(
  imd_stations(with_coordinates = FALSE),
  error = function(e) message("IMD server unavailable: ", conditionMessage(e))
)


varunayan documentation built on Oct. 30, 2026, 1:07 a.m.