Skip to content

Commit bfcd5bb

Browse files
Add indigenous_lands as geo_level (#260)
* Add indigenous_lands as geo_level Add to mapbiomas_cover the download of the indigenous_lands table as geo_level * small tweaks --------- Co-authored-by: IgorRigolon <77173467+IgorRigolon@users.noreply.github.com>
1 parent 7e7233c commit bfcd5bb

File tree

7 files changed

+131
-114
lines changed

7 files changed

+131
-114
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# datazoom.amazonia 1.1.2.9000 (development version)
22

3-
* Updated `load_mapbiomas` to download the newest Mapbiomas Collections and to warn about the currently unavailable download URL of the datasets water and irrigation.
3+
* Updated `load_mapbiomas` to download the newest Mapbiomas Collections and to warn about the currently unavailable download URL of the datasets water and irrigation. Also added the Indigenous Lands option to the `"mapbiomas_cover"` dataset.
44

55
# datazoom.amazonia 1.1.1.9000
66

R/download.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ external_download <- function(dataset = NULL, source = NULL, year = NULL,
365365
# Download path depends on dataset and geo_level
366366

367367
if (source == "mapbiomas") {
368+
if (dataset == "mapbiomas_cover") {
369+
if(param$geo_level == "indigenous_land") {
370+
path <- "https://brasil.mapbiomas.org/wp-content/uploads/sites/4/2024/08/MAPBIOMAS_BRAZIL-COL.9-INDIGENOUS_LANDS-1.xlsx"
371+
}
372+
}
368373
if (dataset == "mapbiomas_transition") {
369374
if (param$geo_level == "biome") {
370375
path <- "https://brasil.mapbiomas.org/wp-content/uploads/sites/4/2024/08/MAPBIOMAS_BRAZIL-COL.9-BIOMES.xlsx"
@@ -713,11 +718,11 @@ datasets_link <- function(source = NULL, dataset = NULL, url = FALSE) {
713718

714719
## MapBiomas
715720

716-
"mapbiomas", "mapbiomas_cover", NA, "1985-2023", "Municipality" , "https://storage.googleapis.com/mapbiomas-public/initiatives/brasil/collection_9/statistics/mapbiomas_brazil_col_coverage_biome_state_municipality.xlsx",
721+
"mapbiomas", "mapbiomas_cover", NA, "1985-2023", "Municipality, indigenous_land", "https://storage.googleapis.com/mapbiomas-public/initiatives/brasil/collection_9/statistics/mapbiomas_brazil_col_coverage_biome_state_municipality.xlsx",
717722
"mapbiomas", "mapbiomas_transition", NA, "1985-2023", "Municipality, Biome", "https://brasil.mapbiomas.org/estatisticas/",
718723
"mapbiomas", "mapbiomas_deforestation_regeneration", NA, "1985-2023", "Municipality", "https://storage.googleapis.com/mapbiomas-public/initiatives/brasil/collection_9/downloads/mapbiomas_brasil_col9_deforestation_and_secondary_vegetation_state_municipality.xlsx",
719724
"mapbiomas", "mapbiomas_irrigation", NA, "2000-2019", "State, Biome", "https://mapbiomas-br-site.s3.amazonaws.com/downloads/Estatisticas%20/Colecao_7_Irrigacao_Biomes_UF.xlsx",
720-
"mapbiomas", "mapbiomas_mining", NA, "1985-2022", "Municipality, Indigenous_Land", "https://brasil.mapbiomas.org/wp-content/uploads/sites/4/2023/09/TABELA-MINERACAO-MAPBIOMAS-COL8.0.xlsx",
725+
"mapbiomas", "mapbiomas_mining", NA, "1985-2022", "Municipality, indigenous_land", "https://brasil.mapbiomas.org/wp-content/uploads/sites/4/2023/09/TABELA-MINERACAO-MAPBIOMAS-COL8.0.xlsx",
721726
"mapbiomas", "mapbiomas_fire", NA, "1985-2023", "State", "https://storage.googleapis.com/mapbiomas-public/brasil/fire/collection_3_stats/MB-Fogo-3-Biome-State.xlsx",
722727
"mapbiomas", "mapbiomas_water", NA, "1985-2022", "State, Municipality, Biome", "https://mapbiomas-br-site.s3.amazonaws.com/Estat%C3%ADsticas/Estatisticas_Superficie%C3%81gua_Col2_SITE.xlsx",
723728

R/mapbiomas.R

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,24 @@ load_mapbiomas <- function(dataset, raw_data = FALSE, geo_level = "municipality"
157157
}
158158
if (param$geo_level == "biome") {
159159
dat <- dat %>%
160-
dplyr::rename(
161-
"biome_code" = "code", "biome" = "name"
162-
)
160+
dplyr::rename("biome_code" = "code", "biome" = "name")
163161
}
164162
if (param$geo_level == "state") {
165163
dat <- dat %>%
166-
dplyr::rename(
167-
"state_code" = "code", "state" = "name"
168-
)
164+
dplyr::rename("state_code" = "code", "state" = "name")
169165
}
170166
}
171167

168+
169+
if (param$dataset == "mapbiomas_cover" & param$geo_level == "indigenous_land") {
170+
dat <- dat %>%
171+
tidyr::extract(
172+
col = 2,
173+
into = c("territory_name", "territory_sub_name", "territory_code"),
174+
regex = "^(.*?)\\s*(?:\\(([^()]+)\\))?\\s*\\((\\d+)\\)$"
175+
)
176+
}
177+
172178
################################
173179
## Harmonizing Variable Names ##
174180
################################
@@ -199,9 +205,11 @@ load_mapbiomas <- function(dataset, raw_data = FALSE, geo_level = "municipality"
199205
"il" ~ "terra_indigena",
200206
"municipality_code" ~ "cod_municipio",
201207
"biome_code" ~ "cod_bioma",
202-
"biome" ~ "bioma",
203208
"state_code" ~ "cod_uf",
204209
"state" ~ "uf",
210+
"territory_name" ~ "nome_territorio",
211+
"territory_subname" ~ "sub_nome_territorio",
212+
"territory_code" ~ "cod_territorio",
205213
.default = .
206214
)) %>%
207215
dplyr::rename_with(~ stringr::str_replace(., "to_level", "para_level")) %>%

README.md

Lines changed: 103 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ devtools::install_github("datazoompuc/datazoom.amazonia")
8080
<tr>
8181
<td>
8282

83-
| | |
84-
|----|----|
85-
| **[IPS](#ips)** | *Amazon Social Progress Index* |
86-
| **[DATASUS](#datasus)** | *Causes of mortality and availability of hospital beds* |
87-
| **[IEMA](#iema)** | *Access to electricity in the Amazon region* |
88-
| **[Population](#population)** | *Population* |
83+
| | |
84+
|-------------------------------|---------------------------------------------------------|
85+
| **[IPS](#ips)** | *Amazon Social Progress Index* |
86+
| **[DATASUS](#datasus)** | *Causes of mortality and availability of hospital beds* |
87+
| **[IEMA](#iema)** | *Access to electricity in the Amazon region* |
88+
| **[Population](#population)** | *Population* |
8989

9090
</td>
9191
</tr>
@@ -126,10 +126,10 @@ devtools::install_github("datazoompuc/datazoom.amazonia")
126126
<tr>
127127
<td>
128128

129-
| | |
130-
|----|----|
129+
| | |
130+
|-----------------------------------------------------------------|-----------------------------------------------------------------------------|
131131
| **[Legal Amazon Municipalities](#legal-amazon-municipalities)** | *Dataset with brazilian cities and whether they belong to the Legal Amazon* |
132-
| **[The ‘googledrive’ package](#googledrive)** | *Troubleshooting and information for downloads from Google Drive* |
132+
| **[The ‘googledrive’ package](#googledrive)** | *Troubleshooting and information for downloads from Google Drive* |
133133

134134
</table>
135135

@@ -403,7 +403,8 @@ For all datasets, areas are measured in hectares (ha).
403403

404404
3. **geo_level**:
405405

406-
- For dataset `"mapbiomas_cover"`, can only be `"municipality"`
406+
- For dataset `"mapbiomas_cover"`, can be `"municipality"` or
407+
`"indigenous_land"`
407408
- For dataset `"mapbiomas_transition"`, can be `"municipality"` or
408409
`"biome"` (faster download)
409410
- For dataset `"mapbiomas_deforestation_regeneration"`, can only be
@@ -455,22 +456,22 @@ web server, as recommended for rectangular subsets of the global data.
455456
Click to see all dataset options
456457
</summary>
457458

458-
| Dataset | Code | Description | Units |
459-
|:---|:--:|:---|:--:|
460-
| max_temperature | tmax | Maximum 2-m Temperature | degC |
461-
| min_temperature | tmin | Minimum 2-m Temperature | degC |
462-
| wind_speed | ws | Wind Speed at 10-m | m/s |
463-
| vapor_pressure_deficit | vpd | Vapor Pressure Deficit | kPa |
464-
| vapor_pressure | vap | 2-m Vapor Pressure | kPa |
465-
| snow_water_equivalent | swe | Snow Water Equivalent at End of Month | mm |
466-
| shortwave_radiation_flux | srad | Downward Shortwave Radiation Flux at the Surface | W/m^2 |
467-
| soil_moisture | soil | Soil Moisture at End of Month | mm |
468-
| runoff | q | Runoff | mm |
469-
| precipitation | ppt | Accumulated Precipitation | mm |
470-
| potential_evaporation | pet | Reference Evapotranspiration | mm |
471-
| climatic_water_deficit | def | Climatic Water Deficit | mm |
472-
| water_evaporation | aet | Actual Evapotranspiration | mm |
473-
| palmer_drought_severity_index | PDSI | Palmer Drought Severity Index | unitless |
459+
| Dataset | Code | Description | Units |
460+
|:------------------------------|:----:|:-------------------------------------------------|:--------:|
461+
| max_temperature | tmax | Maximum 2-m Temperature | degC |
462+
| min_temperature | tmin | Minimum 2-m Temperature | degC |
463+
| wind_speed | ws | Wind Speed at 10-m | m/s |
464+
| vapor_pressure_deficit | vpd | Vapor Pressure Deficit | kPa |
465+
| vapor_pressure | vap | 2-m Vapor Pressure | kPa |
466+
| snow_water_equivalent | swe | Snow Water Equivalent at End of Month | mm |
467+
| shortwave_radiation_flux | srad | Downward Shortwave Radiation Flux at the Surface | W/m^2 |
468+
| soil_moisture | soil | Soil Moisture at End of Month | mm |
469+
| runoff | q | Runoff | mm |
470+
| precipitation | ppt | Accumulated Precipitation | mm |
471+
| potential_evaporation | pet | Reference Evapotranspiration | mm |
472+
| climatic_water_deficit | def | Climatic Water Deficit | mm |
473+
| water_evaporation | aet | Actual Evapotranspiration | mm |
474+
| palmer_drought_severity_index | PDSI | Palmer Drought Severity Index | unitless |
474475

475476
</details>
476477

@@ -1283,90 +1284,90 @@ Full datasets provided by IBGE:
12831284
Datasets generated from Temporary Crops:
12841285
</summary>
12851286

1286-
| dataset | Name (pt) | Name (eng) |
1287-
|:---|:--:|:--:|
1288-
| pineapple | Abacaxi | Pineapple |
1289-
| alfafa | Alfafa Fenada | Alfafa Fenada |
1287+
| dataset | Name (pt) | Name (eng) |
1288+
|:------------------|:----------------------------:|:-----------------------------:|
1289+
| pineapple | Abacaxi | Pineapple |
1290+
| alfafa | Alfafa Fenada | Alfafa Fenada |
12901291
| cotton_herbaceous | Algodao Herbaceo (em Caroco) | Herbaceous Cotton (in Caroco) |
1291-
| garlic | Alho | Garlic |
1292-
| peanut_temporary | Amendoim (em Casca) | Peanuts (in Shell) |
1293-
| rice | Arroz (em Casca) | Rice (in husk) |
1294-
| oats | Aveia (em Grao) | Oats (in grain) |
1295-
| sweet_potato | Batata Doce | Sweet potato |
1296-
| potato_temporary | Batata Inglesa | English potato |
1297-
| sugar_cane | Cana de Acucar | Sugar cane |
1298-
| forage_cane | Cana para Forragem | Forage cane |
1299-
| onion | Cebola | Onion |
1300-
| rye | Centeio (em Grao) | Rye (in grain) |
1301-
| barley | Cevada (em Grao) | Barley (in Grain) |
1302-
| pea | Ervilha (em Grao) | Pea (in Grain) |
1303-
| broad_bean | Fava (em Grao) | Broad Bean (in Grain) |
1304-
| beans_temporary | Feijao (em Grao) | Beans (in Grain) |
1305-
| tobacco | Fumo (em Folha) | Smoke (in Sheet) |
1306-
| sunflower_seeds | Girassol (em Grao) | Sunflower (in Grain) |
1307-
| jute_fiber | Juta (Fibra) | Jute (Fiber) |
1308-
| linen_seeds | Linho (Semente) | Linen (Seed) |
1309-
| malva_fiber | Malva (Fibra) | Malva (Fiber) |
1310-
| castor_bean | Mamona (Baga) | Castor bean (Berry) |
1311-
| cassava | Mandioca | Cassava |
1312-
| watermelon | Melancia | watermelon |
1313-
| melon | Melao | Melon |
1314-
| corn_temporary | Milho (em Grao) | corn (in grain) |
1315-
| ramie_fiber | Rami (Fibra) | Ramie (Fiber) |
1316-
| soybean | Soja (em Grao) | Soybean (in grain) |
1317-
| sorghum | Sorgo (em Grao) | Sorghum (in Grain) |
1318-
| tomato | Tomate | Tomato |
1319-
| wheat | Trigo (em Grao) | Wheat in grain) |
1320-
| triticale | Triticale (em Grao) | Triticale (in grain) |
1321-
| temporary_total | Total | Total |
1292+
| garlic | Alho | Garlic |
1293+
| peanut_temporary | Amendoim (em Casca) | Peanuts (in Shell) |
1294+
| rice | Arroz (em Casca) | Rice (in husk) |
1295+
| oats | Aveia (em Grao) | Oats (in grain) |
1296+
| sweet_potato | Batata Doce | Sweet potato |
1297+
| potato_temporary | Batata Inglesa | English potato |
1298+
| sugar_cane | Cana de Acucar | Sugar cane |
1299+
| forage_cane | Cana para Forragem | Forage cane |
1300+
| onion | Cebola | Onion |
1301+
| rye | Centeio (em Grao) | Rye (in grain) |
1302+
| barley | Cevada (em Grao) | Barley (in Grain) |
1303+
| pea | Ervilha (em Grao) | Pea (in Grain) |
1304+
| broad_bean | Fava (em Grao) | Broad Bean (in Grain) |
1305+
| beans_temporary | Feijao (em Grao) | Beans (in Grain) |
1306+
| tobacco | Fumo (em Folha) | Smoke (in Sheet) |
1307+
| sunflower_seeds | Girassol (em Grao) | Sunflower (in Grain) |
1308+
| jute_fiber | Juta (Fibra) | Jute (Fiber) |
1309+
| linen_seeds | Linho (Semente) | Linen (Seed) |
1310+
| malva_fiber | Malva (Fibra) | Malva (Fiber) |
1311+
| castor_bean | Mamona (Baga) | Castor bean (Berry) |
1312+
| cassava | Mandioca | Cassava |
1313+
| watermelon | Melancia | watermelon |
1314+
| melon | Melao | Melon |
1315+
| corn_temporary | Milho (em Grao) | corn (in grain) |
1316+
| ramie_fiber | Rami (Fibra) | Ramie (Fiber) |
1317+
| soybean | Soja (em Grao) | Soybean (in grain) |
1318+
| sorghum | Sorgo (em Grao) | Sorghum (in Grain) |
1319+
| tomato | Tomate | Tomato |
1320+
| wheat | Trigo (em Grao) | Wheat in grain) |
1321+
| triticale | Triticale (em Grao) | Triticale (in grain) |
1322+
| temporary_total | Total | Total |
13221323

13231324
</details>
13241325
<details>
13251326
<summary>
13261327
Datasets generated from Permanent Crops:
13271328
</summary>
13281329

1329-
| dataset | Name (pt) | Name (eng) |
1330-
|:---|:--:|:--:|
1331-
| avocado | Abacate | Avocado |
1332-
| cotton_arboreo | Algodao Arboreo (em Caroco) | Arboreo cotton (in Caroco) |
1333-
| acai | Acai | Acai |
1334-
| olive | Azeitona | Olive |
1335-
| banana | Banana (Cacho) | Banana (Bunch) |
1336-
| rubber_coagulated_latex | Borracha (Latex Coagulado) | Rubber (Coagulated Latex) |
1337-
| rubber_liquid_latex | Borracha (Latex Liquido) | Rubber (Liquid Latex) |
1338-
| cocoa_beans | Cacau (em Amendoa) | Cocoa (in Almonds) |
1339-
| coffee_total | Cafe (em Grao) Total | Coffee (in Grain) Total |
1340-
| coffee_arabica | Cafe (em Grao) Arabica | Cafe (in Grao) Arabica |
1341-
| coffee_canephora | Cafe (em Grao) Canephora | Cafe (in Grain) Canephora |
1342-
| cashew | Caju | Cashew |
1343-
| khaki | Caqui | Khaki |
1344-
| cashew_nut | Castanha de Caju | Cashew Nuts |
1345-
| india_tea | Cha da India (Folha Verde) | India Tea (Leaf) |
1346-
| coconut | Coco da Baia | Coconut |
1347-
| coconut_bunch | Dende (Cacho de Coco) | Coconut Bunch |
1348-
| yerba_mate | Erva Mate (Folha Verde) | Mate Herb (Leaf) |
1349-
| fig | Figo | Fig |
1350-
| guava | Goiaba | Guava |
1351-
| guarana_seeds | Guarana (Semente) | Guarana (Seed) |
1352-
| orange | Laranja | Orange |
1353-
| lemon | Limao | Lemon |
1354-
| apple | Maca | Apple |
1355-
| papaya | Mamao | Papaya |
1356-
| mango | Manga | Mango |
1357-
| passion_fruit | Maracuja | Passion fruit |
1358-
| quince | Marmelo | Quince |
1359-
| walnut | Noz (Fruto Seco) | Walnut (Dry Fruit) |
1360-
| heart_of_palm | Palmito | Palm heart |
1361-
| pear | Pera | Pear |
1362-
| peach | Pessego | Peach |
1363-
| black_pepper | Pimenta do Reino | Black pepper |
1364-
| sisal_or_agave | Sisal ou Agave (Fibra) | Sisal or Agave (Fiber) |
1365-
| tangerine | Tangerina | Tangerine |
1366-
| tung | Tungue (Fruto Seco) | Tung (Dry Fruit) |
1367-
| annatto_seeds | Urucum (Semente) | Annatto (Seed) |
1368-
| grape | Uva | Grape |
1369-
| permanent_total | Total | Total |
1330+
| dataset | Name (pt) | Name (eng) |
1331+
|:------------------------|:---------------------------:|:--------------------------:|
1332+
| avocado | Abacate | Avocado |
1333+
| cotton_arboreo | Algodao Arboreo (em Caroco) | Arboreo cotton (in Caroco) |
1334+
| acai | Acai | Acai |
1335+
| olive | Azeitona | Olive |
1336+
| banana | Banana (Cacho) | Banana (Bunch) |
1337+
| rubber_coagulated_latex | Borracha (Latex Coagulado) | Rubber (Coagulated Latex) |
1338+
| rubber_liquid_latex | Borracha (Latex Liquido) | Rubber (Liquid Latex) |
1339+
| cocoa_beans | Cacau (em Amendoa) | Cocoa (in Almonds) |
1340+
| coffee_total | Cafe (em Grao) Total | Coffee (in Grain) Total |
1341+
| coffee_arabica | Cafe (em Grao) Arabica | Cafe (in Grao) Arabica |
1342+
| coffee_canephora | Cafe (em Grao) Canephora | Cafe (in Grain) Canephora |
1343+
| cashew | Caju | Cashew |
1344+
| khaki | Caqui | Khaki |
1345+
| cashew_nut | Castanha de Caju | Cashew Nuts |
1346+
| india_tea | Cha da India (Folha Verde) | India Tea (Leaf) |
1347+
| coconut | Coco da Baia | Coconut |
1348+
| coconut_bunch | Dende (Cacho de Coco) | Coconut Bunch |
1349+
| yerba_mate | Erva Mate (Folha Verde) | Mate Herb (Leaf) |
1350+
| fig | Figo | Fig |
1351+
| guava | Goiaba | Guava |
1352+
| guarana_seeds | Guarana (Semente) | Guarana (Seed) |
1353+
| orange | Laranja | Orange |
1354+
| lemon | Limao | Lemon |
1355+
| apple | Maca | Apple |
1356+
| papaya | Mamao | Papaya |
1357+
| mango | Manga | Mango |
1358+
| passion_fruit | Maracuja | Passion fruit |
1359+
| quince | Marmelo | Quince |
1360+
| walnut | Noz (Fruto Seco) | Walnut (Dry Fruit) |
1361+
| heart_of_palm | Palmito | Palm heart |
1362+
| pear | Pera | Pear |
1363+
| peach | Pessego | Peach |
1364+
| black_pepper | Pimenta do Reino | Black pepper |
1365+
| sisal_or_agave | Sisal ou Agave (Fibra) | Sisal or Agave (Fiber) |
1366+
| tangerine | Tangerina | Tangerine |
1367+
| tung | Tungue (Fruto Seco) | Tung (Dry Fruit) |
1368+
| annatto_seeds | Urucum (Semente) | Annatto (Seed) |
1369+
| grape | Uva | Grape |
1370+
| permanent_total | Total | Total |
13701371

13711372
</details>
13721373

datazoom.amazonia.Rproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Version: 1.0
2+
ProjectId: beca8242-1d10-4af4-bb80-a2c0877d958e
23

34
RestoreWorkspace: No
45
SaveWorkspace: No

0 commit comments

Comments
 (0)