diegovalle / rsinaica

R package for downloading air quality data from the Mexican National Air Quality Information System (SINAICA)
https://hoyodesmog.diegovalle.net/rsinaica/
Other
7 stars 3 forks source link

update stations_sinaica #2

Closed yosukefk closed 7 months ago

yosukefk commented 2 years ago

Thank you for great tool.

I am thinking though, it is better to have mecahnism to grab latest set of stations, like code below. I got methods in here https://datos.gob.mx/blog/ventilando-datos-abiertos-sobre-calidad-del-aire , may not be using same API as rsinaica. I got

get_stations_sinaica <- function()
{
  url <- 'https://api.datos.gob.mx/v2/sinaica-estaciones?pageSize=5000'
  result = GET(url)
  json_text <- content(result, "text", encoding = "UTF-8")
  o <- fromJSON(json_text)
  df <- data.frame(o$result)
  df <- df %>% rename(
    station_id = id,
    station_name = nombre,
    station_code = codigo,
    lat = lat,
    lon = long) %>% 
    select(station_id, station_name, station_code, lat, lon)
  df
}

I found following stations added on top of stations_sinaica table. I also noticed that some of lon/lat value got changed, and if they are corrections...?

station_id station_name station_code lat lon
427 Escuela Primaria 1° de mayo PRIM 22.15944 -100.95333
428 Instituto de Ingeniería y Tecnología IIT 31.74333 -106.43167
430 Parque La Esperanza ESP 25.57192 -103.49781
431 FES Aragón FAR 19.47369 -99.04618
432 Santiago Acahualtepec SAC 19.34561 -99.00938
435 Campus II Esc. Prep. Dr. Nazario Víctor Montejo Godoy - Universidad Autónoma de Campeche. PRE 19.84978 -90.53065
diegovalle commented 2 years ago

Hi, I've updated the stations_sinaica data.frame with the latest available stations

yosukefk commented 2 years ago

Thanks! I will test out