Skip to content

Commit 0359469

Browse files
committed
1 parent f40e6a1 commit 0359469

File tree

73 files changed

+198
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+198
-176
lines changed

r-package/NEWS.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# geobr v1.9.1999999999 dev
22

3-
- fix url redundancy
4-
3+
- Now all functions download data from the latest year available, by default.
4+
- Fix url redundancy to avoid internet connection problems.
55

66
# geobr v1.9.1
77

r-package/R/read_amazon.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' federal law n. 12.651/2012). The original data comes from the Brazilian
66
#' Ministry of Environment (MMA) and can be found at "http://mapas.mma.gov.br/i3geo/datadownload.htm".
77
#'
8-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2012`.
8+
#' @template year
99
#' @template simplified
1010
#' @template showProgress
1111
#' @template cache
@@ -19,7 +19,7 @@
1919
#' # Read Brazilian Legal Amazon
2020
#' a <- read_amazon(year = 2012)
2121
#'
22-
read_amazon <- function(year = 2012,
22+
read_amazon <- function(year = NULL,
2323
simplified = TRUE,
2424
showProgress = TRUE,
2525
cache = TRUE){

r-package/R/read_biomes.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' scale 1:250.000. The 2004 data set is at the scale 1:5.000.000. The original
77
#' data comes from IBGE. More information at \url{https://www.ibge.gov.br/apps/biomas/}
88
#'
9-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2019`.
9+
#' @template year
1010
#' @template simplified
1111
#' @template showProgress
1212
#' @template cache
@@ -20,7 +20,7 @@
2020
#' # Read biomes
2121
#' b <- read_biomes(year = 2019)
2222
#'
23-
read_biomes <- function(year = 2019,
23+
read_biomes <- function(year = NULL,
2424
simplified = TRUE,
2525
showProgress = TRUE,
2626
cache = TRUE){

r-package/R/read_census_tract.R

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
#' @description
44
#' Download spatial data of census tracts of the Brazilian Population Census
55
#'
6+
#' @template year
67
#' @param code_tract The 7-digit code of a Municipality. If the two-digit code
78
#' or a two-letter uppercase abbreviation of a state is passed, (e.g. 33
89
#' or "RJ") the function will load all census tracts of that state. If
910
#' `code_tract="all"`, the function downloads all census tracts of the
1011
#' country.
11-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2010`.
1212
#' @param zone For census tracts before 2010, 'urban' and 'rural' census tracts
1313
#' are separate data sets.
1414
#' @template simplified
@@ -36,8 +36,8 @@
3636
#' # Read all census tracts of the country at a given year
3737
#' c <- read_census_tract(code_tract="all", year=2010)
3838
#'
39-
read_census_tract <- function(code_tract,
40-
year = 2010,
39+
read_census_tract <- function(year = NULL,
40+
code_tract,
4141
zone = "urban",
4242
simplified = TRUE,
4343
showProgress = TRUE,
@@ -50,7 +50,7 @@ read_census_tract <- function(code_tract,
5050
if (is.null(temp_meta)) { return(invisible(NULL)) }
5151

5252
# Check zone input urban and rural inputs if year <=2007
53-
if (year<=2007){
53+
if ( temp_meta$year[1] <= 2007){
5454

5555
if (zone == "urban") {message("Using data of Urban census tracts\n")
5656
temp_meta <- temp_meta[substr(temp_meta[,3],1,1)== "U", ] }
@@ -96,12 +96,12 @@ read_census_tract <- function(code_tract,
9696
} else{
9797

9898
# list paths of files to download
99-
if (year<=2007 & zone == "urban") {
99+
if (temp_meta$year[1] <= 2007 & zone == "urban") {
100100

101101
if (is.numeric(code_tract)){ file_url <- as.character(subset(temp_meta, code==paste0("U",substr(code_tract, 1, 2)))$download_path) }
102102
if (is.character(code_tract)){ file_url <- as.character(subset(temp_meta, code_abbrev==toupper(substr(code_tract, 1, 2)))$download_path) }
103103

104-
} else if (year<=2007 & zone == "rural") {
104+
} else if (temp_meta$year[1] <= 2007 & zone == "rural") {
105105

106106
if (is.numeric(code_tract)){ file_url <- as.character(subset(temp_meta, code==paste0("R",substr(code_tract, 1, 2)))$download_path) }
107107
if (is.character(code_tract)){ file_url <- as.character(subset(temp_meta, code_abbrev==toupper(substr(code_tract, 1, 2)))$download_path) }

r-package/R/read_conservation_units.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' conservation units present in Brazilian territory. The last update of the data
66
#' was 09-2019. The original data comes from MMA and can be found at "http://mapas.mma.gov.br/i3geo/datadownload.htm".
77
#'
8-
#' @param date Numeric. Date of the data in YYYYMM format. Defaults to `201909`.
8+
#' @template date
99
#' @template simplified
1010
#' @template showProgress
1111
#' @template cache
@@ -19,7 +19,7 @@
1919
#' # Read conservation_units
2020
#' b <- read_conservation_units(date = 201909)
2121
#'
22-
read_conservation_units <- function(date = 201909,
22+
read_conservation_units <- function(date = NULL,
2323
simplified = TRUE,
2424
showProgress = TRUE,
2525
cache = TRUE){

r-package/R/read_country.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @description
44
#' Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674).
55
#'
6-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2010`.
6+
#' @template year
77
#' @template simplified
88
#' @template showProgress
99
#' @template cache
@@ -17,7 +17,7 @@
1717
#' # Read specific year
1818
#' br <- read_country(year = 2018)
1919
#'
20-
read_country <- function(year = 2010,
20+
read_country <- function(year = NULL,
2121
simplified = TRUE,
2222
showProgress = TRUE,
2323
cache = TRUE){

r-package/R/read_disaster_risk_area.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#' 'num'). Original data were generated by IBGE and CEMADEN. For more information
1212
#' about the methodology, see deails at \url{https://www.ibge.gov.br/geociencias/organizacao-do-territorio/tipologias-do-territorio/21538-populacao-em-areas-de-risco-no-brasil.html}
1313
#'
14-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2010`.
14+
#' @template year
1515
#' @template simplified
1616
#' @template showProgress
1717
#' @template cache
@@ -25,7 +25,7 @@
2525
#' # Read all disaster risk areas in an specific year
2626
#' d <- read_disaster_risk_area(year=2010)
2727
#'
28-
read_disaster_risk_area <- function(year = 2010,
28+
read_disaster_risk_area <- function(year = NULL,
2929
simplified = TRUE,
3030
showProgress = TRUE,
3131
cache = TRUE){

r-package/R/read_health_facilities.R

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#' `year_update`. More information in the CNES data set available at \url{https://dados.gov.br/}.
1818
#' These data use Geodetic reference system "SIRGAS2000" and CRS(4674).
1919
#'
20-
#' @param date Numeric. Date of the data in YYYYMM format. Defaults to `202303`,
21-
#' which was the latest data available by the time of this update.
20+
#' @template date
2221
#' @template showProgress
2322
#' @template cache
2423
#'
@@ -31,7 +30,7 @@
3130
#' # Read all health facilities of the whole country
3231
#' h <- read_health_facilities( date = 202303)
3332
#'
34-
read_health_facilities <- function(date = 202303,
33+
read_health_facilities <- function(date = NULL,
3534
showProgress = TRUE,
3635
cache = TRUE){
3736

r-package/R/read_health_region.R

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#' few municipalities because they are generally more technology intensive, costly and face
88
#' shortages of specialized professionals. A macro region comprises one or more health regions.
99
#'
10-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2013`, the
11-
#' latest available.
10+
#' @template year
1211
#' @param macro Logic. If `FALSE` (default), the function downloads health
1312
#' regions data. If `TRUE`, the function downloads macro regions data.
1413
#' @template simplified
@@ -27,7 +26,7 @@
2726
#' # Read all macro health regions
2827
#' mhr <- read_health_region( year=2013, macro =TRUE)
2928
#'
30-
read_health_region <- function(year = 2013,
29+
read_health_region <- function(year = NULL,
3130
macro = FALSE,
3231
simplified = TRUE,
3332
showProgress = TRUE,

r-package/R/read_immediate_region.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' The Immediate Geographic Areas are part of the geographic division of Brazil created in 2017 by IBGE. These regions
55
#' were created to replace the "Micro Regions" division. Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
66
#'
7-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2019`.
7+
#' @template year
88
#' @param code_immediate 6-digit code of an immediate region. If the two-digit
99
#' code or a two-letter uppercase abbreviation of a state is passed, (e.g.
1010
#' 33 or "RJ") the function will load all immediate regions of that state.
@@ -31,8 +31,8 @@
3131
#' im <- read_immediate_region()
3232
#' im <- read_immediate_region(code_immediate="all")
3333
#'
34-
read_immediate_region <- function(code_immediate = "all",
35-
year = 2019,
34+
read_immediate_region <- function(year = NULL,
35+
code_immediate = "all",
3636
simplified = TRUE,
3737
showProgress = TRUE,
3838
cache = TRUE){

r-package/R/read_indigenous_land.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#' updated monthly, the geobr package will only keep the data for a few months
99
#' per year.
1010
#'
11-
#' @param date Numeric. Date of the data in YYYYMM format. Defaults to `201907`.
11+
#' @template date
1212
#' @template simplified
1313
#' @template showProgress
1414
#' @template cache
@@ -22,7 +22,7 @@
2222
#' # Read all indigenous land in an specific date
2323
#' i <- read_indigenous_land(date=201907)
2424
#'
25-
read_indigenous_land <- function(date = 201907,
25+
read_indigenous_land <- function(date = NULL,
2626
simplified = TRUE,
2727
showProgress = TRUE,
2828
cache = TRUE){

r-package/R/read_intermediate_region.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' "Meso Regions" division. Data at scale 1:250,000, using Geodetic reference
77
#' system "SIRGAS2000" and CRS(4674)
88
#'
9-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2019`.
9+
#' @template year
1010
#' @param code_intermediate 4-digit code of an intermediate region. If the
1111
#' two-digit code or a two-letter uppercase abbreviation of a state is
1212
#' passed, (e.g. 33 or "RJ") the function will load all intermediate
@@ -33,8 +33,8 @@
3333
#' im <- read_intermediate_region()
3434
#' im <- read_intermediate_region(code_intermediate="all")
3535
#'
36-
read_intermediate_region <- function(code_intermediate = "all",
37-
year = 2019,
36+
read_intermediate_region <- function(year = NULL,
37+
code_intermediate = "all",
3838
simplified = TRUE,
3939
showProgress = TRUE,
4040
cache = TRUE){

r-package/R/read_meso_region.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @description
44
#' Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
55
#'
6-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2010`.
6+
#' @template year
77
#' @param code_meso The 4-digit code of a meso region. If the two-digit code or
88
#' a two-letter uppercase abbreviation of a state is passed, (e.g. 33 or
99
#' "RJ") the function will load all meso regions of that state. If
@@ -29,8 +29,8 @@
2929
#' # Read all meso regions of the country at a given year
3030
#' meso <- read_meso_region(code_meso="all", year=2010)
3131
#'
32-
read_meso_region <- function(code_meso = "all",
33-
year = 2010,
32+
read_meso_region <- function(year = NULL,
33+
code_meso = "all",
3434
simplified = TRUE,
3535
showProgress = TRUE,
3636
cache = TRUE){

r-package/R/read_metro_area.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#' generated by Institute of Geography. Data at scale 1:250,000, using Geodetic
99
#' reference system "SIRGAS2000" and CRS(4674).
1010
#'
11-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2018`.
11+
#' @template year
1212
#' @param code_state The two-digit code of a state or a two-letter uppercase
1313
#' abbreviation (e.g. 33 or "RJ"). If `code_state="all"` (the
1414
#' default), the function downloads all states.
@@ -26,7 +26,7 @@
2626
#' m <- read_metro_area(2005)
2727
#'
2828
#' m <- read_metro_area(2018)
29-
read_metro_area <- function(year = 2018,
29+
read_metro_area <- function(year = NULL,
3030
code_state = "all",
3131
simplified = TRUE,
3232
showProgress = TRUE,

r-package/R/read_micro_region.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @description
44
#' Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674)
55
#'
6-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2010`.
6+
#' @template year
77
#' @param code_micro 5-digit code of a micro region. If the two-digit code or a
88
#' two-letter uppercase abbreviation of a state is passed, (e.g. 33 or
99
#' "RJ") the function will load all micro regions of that state. If
@@ -29,8 +29,8 @@
2929
#' # Read all micro regions at a given year
3030
#' micro <- read_micro_region(code_micro="all", year=2010)
3131
#'
32-
read_micro_region <- function(code_micro = "all",
33-
year = 2010,
32+
read_micro_region <- function(year = NULL,
33+
code_micro = "all",
3434
simplified = TRUE,
3535
showProgress = TRUE,
3636
cache = TRUE){

r-package/R/read_municipal_seat.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' seats for various years between 1872 and 2010. Original data were generated by
77
#' Brazilian Institute of Geography and Statistics (IBGE).
88
#'
9-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2010`.
9+
#' @template year
1010
#' @template showProgress
1111
#' @template cache
1212
#'
@@ -19,7 +19,7 @@
1919
#' # Read municipal seats in an specific year
2020
#' m <- read_municipal_seat(year = 1991)
2121
#'
22-
read_municipal_seat <- function(year = 2010,
22+
read_municipal_seat <- function(year = NULL,
2323
showProgress = TRUE,
2424
cache = TRUE){
2525

r-package/R/read_municipality.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @description
44
#' Data at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674).
55
#'
6-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2010`.
6+
#' @template year
77
#' @param code_muni The 7-digit identification code of a municipality. If
88
#' `code_muni = "all"` (Default), the function downloads all
99
#' municipalities of the country. Alternatively, if a two-digit
@@ -34,8 +34,8 @@
3434
#' # Read all municipalities of the country at a given year
3535
#' mun <- read_municipality(code_muni = "all", year = 2018)
3636
#'
37-
read_municipality <- function(code_muni = "all",
38-
year = 2010,
37+
read_municipality <- function(year = NULL,
38+
code_muni = "all",
3939
simplified = TRUE,
4040
showProgress = TRUE,
4141
cache = TRUE,
@@ -56,13 +56,13 @@ read_municipality <- function(code_muni = "all",
5656
code_muni %in% temp_meta$code |
5757
substring(code_muni, 1, 2) %in% temp_meta$code |
5858
code_muni %in% temp_meta$code_abbrev |
59-
(year < 1992 & temp_meta$code %in% "mu")
59+
(temp_meta$year[1] < 1992 & temp_meta$code %in% "mu")
6060
)) {
6161
stop("Error: Invalid Value to argument code_muni.")
6262
}
6363

6464
# get file url
65-
if (code_muni=="all" | year < 1992) {
65+
if (code_muni=="all" | temp_meta$year[1] < 1992) {
6666
file_url <- as.character(temp_meta$download_path)
6767

6868
} else if (is.numeric(code_muni)) { # if using numeric code_muni

r-package/R/read_neighborhood.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' It is based on aggregations of the census tracts from the Brazilian
66
#' census. Only 2010 data is currently available.
77
#'
8-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2010`.
8+
#' @template year
99
#' @template simplified
1010
#' @template showProgress
1111
#' @template cache
@@ -19,7 +19,7 @@
1919
#' # Read neighborhoods of Brazilian municipalities
2020
#' n <- read_neighborhood(year=2010)
2121
#'
22-
read_neighborhood <- function(year = 2010,
22+
read_neighborhood <- function(year = NULL,
2323
simplified = TRUE,
2424
showProgress = TRUE,
2525
cache = TRUE){

r-package/R/read_pop_arrangements.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' Geography and Statistics (IBGE) For more information about the methodology,
77
#' see details at \url{https://www.ibge.gov.br/apps/arranjos_populacionais/2015/pdf/publicacao.pdf}
88
#'
9-
#' @param year Numeric. Year of the data in YYYY format. Defaults to `2015`.
9+
#' @template year
1010
#' @template simplified
1111
#' @template showProgress
1212
#' @template cache
@@ -20,7 +20,7 @@
2020
#' # Read urban footprint of Brazilian cities in an specific year
2121
#' uc <- read_pop_arrangements(year=2015)
2222
#'
23-
read_pop_arrangements <- function(year = 2015,
23+
read_pop_arrangements <- function(year = NULL,
2424
simplified = TRUE,
2525
showProgress = TRUE,
2626
cache = TRUE){

0 commit comments

Comments
 (0)