Coder Social home page Coder Social logo

lhmet / inmetr Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 11.0 60.17 MB

DEPRECATED A R-package to Import Historical Data from Brazilian Meteorological Stations

License: Other

R 100.00%
data-access climate-data meteorological-stations r brazil weather-station weather-data inmet bdmep deprecated-repo

inmetr's Introduction

DEPRECATED - no longer actively maintained

Due to changes in access to the BDMEP-INMET data acquisition system, {inmetr} is no longer supported. See https://portal.inmet.gov.br/noticias/inmet-lan%C3%A7a-novo-portal and consider using https://bdmep.inmet.gov.br/ instead.

inmetr: Historical Data from Brazilian Meteorological Stations in R

DOI Build Status

Overview

inmetr provide access to historical data measured by meteorological stations available in the Meteorological Database for Education and Research (BDMEP) from National Institute of Meteorology (Instituto Nacional de Meteorologia - INMET), Brazil.

Installation

inmetr is easy to install from Git Hub using the devtools package.

library(devtools)
install_github('lhmet/inmetr')

Load package

library(inmetr)

Stations ID

To search a meteorological station from INMET we can use metadata of INMET stations included in inmetr package as bdmep_meta.

head(bdmep_meta)
tail(bdmep_meta)

bdmep_meta is a data frame providing the id of stations, a numeric code defined by OMM. This id is a necessary argument to bdmep_import() function which allows to download data from meteorological stations into R.

Here, we show how to find the OMM code for meteorological stations at two cities (randomly sampled).

#stations <- c("Santa Maria", "Macapá")
stations <- c("Rio de Janeiro", "Goiás")
# random sample of two stations names 
#stations <- sample(bdmep_meta$name, 2)
stations_rows <- pmatch(stations, bdmep_meta$name)
bdmep_meta[stations_rows, ]
stns_codes <- bdmep_meta[stations_rows, "id"] 
stns_codes

Import data

Now we can import data for the two cities from 1961 to the current date.

start_date <- "01/01/1961"
end_date <- format(Sys.Date(), "%d/%m/%Y")
met_data <- bdmep_import(id = stns_codes,
                         sdate = start_date, 
                         edate = end_date, 
                         email = "your-email",
                         passwd = "your-password",
                         verbose = TRUE)
# check de start date
head(met_data)
# check de end date
tail(met_data)

You can save data in a CSV file setting argument destdir = "path/to/write/files" in bdmep_import function. Data will be save one file per station.

A description of meteorological variables can be obtained by:

bdmep_description()

Eventually, if the request failed a message will be prompted with the HTTP status code, for example:

------------------------
station: `r stns_codes[1]`
Bad Gateway (HTTP 502).
------------------------
station: `r stns_codes[2]`
Bad Gateway (HTTP 502).

In this case the outcome data frame will be filled with NA, except for request_status which will return information on the request status.

To cite this software

citation("inmetr")

To cite package 'inmetr' in publications use:

  Tatsch, J.D. 2020. inmetr R package (v 0.2.5): Historical Data from
  Brazilian Meteorological Stations in R. Zenodo.
  https://doi.org/10.5281/zenodo.580813.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {inmetr: Historical Data from Brazilian Meteorological Stations in R},
    author = {Jonatan Tatsch},
    year = {2020},
    note = {R package version 0.2.5},
    doi = {https://doi.org/10.5281/zenodo.580813},
    institution = {Universidade Federal de Santa Maria-UFSM},
    url = {https://github.com/lhmet/inmetr},
  }

inmetr's People

Contributors

jdtatsch avatar lhmet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

inmetr's Issues

Failed to connect to www.inmet.gov.br port 80: Timed out

Hello!

This code it's awesome! It's work to get some information about two stations.

However, when I try to get informations about 10 stations, I received this text:

Error in curl::curl_fetch_memory(url, handle = handle) :
Failed to connect to www.inmet.gov.br port 80: Timed out

Now I can't get mor informations.

Do you know how can I solve this?

Thanks!

Downloading daily or monthly data

Hello,
Is there a way to tweek a function or a configuration available to download daily or monthly data instead of hourly?

Thanks!

Error in (rowheader + 1):(length(x) - 1) : argument of length 0

Hi,

I'm trying to run the README.md example but I got this error wen trying to import data:

------------------------------
station: 83936
OK (HTTP 200).
Error in (rowheader + 1):(length(x) - 1) : argument of length 0

My code is:

stations <- c("Santa Maria", "Macapá")
stations_rows <- pmatch(stations, bdmep_meta$name)
stns_codes <- bdmep_meta[stations_rows, "id"] 
# the line that returns this error
met_data <- bdmep_import(id      = stns_codes,
                         sdate   = "01/01/2012", 
                         edate   = "01/02/2012",
                         destdir = 'C:/',
                         email   = "[email protected]",
                         passwd  = "666",
                         verbose = T)

Is this problem related to the code (in the example)? or with any change in the location or format of the data (I saw that the site has changed its address)?

Thank you,
Daniel

Can't seem to import BDMEP data

I'm getting this message when I try to import:


station: 83579
Bad Request (HTTP 400).

my script:
library(inmetr)
head(bdmep_meta)
sort(unique(bdmep_meta$name))
stations<-c("Araxá")
stations_rows<-pmatch(stations, bdmep_meta$name)
bdmep_meta[stations_rows,]

stns_cods<- bdmep_meta[stations_rows,'id']
start_date <- "01/01/1961"
end_date <- format(Sys.Date(),' %d/%m/%Y')
met_data <- bdmep_import(id=stns_cods, sdate = start_date, edate = end_date, email= "myemail", passwd='mypass', verbose=T)
(just to be clear, my e-mail and password work fine on the BDMEP website)

I get bad request for all stations I've tried.
I followed the instructions, which were very clear... what I am doing wrong?
Thanks

Erro: `replacement` must be a character vector

Erro ao tentar puxar os dados da estação da cidade do Rio de Janeiro.

info <- bdmep_stations()

start_date <- "01/01/1961"
end_date <- format(Sys.Date(), "%d/%m/%Y")
sm <- import_bdmep(id = 83743,
                   sdate = start_date, 
                   edate = end_date, 
                   email = "[email protected]",
                   passwd = "minhasenha")
Login sucessfull.
Erro: `replacement` must be a character vector

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.