#####Exercício 1: Utilizando qualquer recurso apresentado em aula, faça um mapa destacando ou mostrando o estado e município que você nasceu.
library(rgdal)
Loading required package: sp
Please note that rgdal will be retired during 2023,
plan transition to sf/stars/terra functions using GDAL and PROJ
at your earliest convenience.
See https://r-spatial.org/r/2022/04/12/evolution.html and https://github.com/r-spatial/evolution
rgdal: version: 1.6-6, (SVN revision 1201)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
Path to GDAL shared files: C:/Users/lisa1/AppData/Local/R/win-library/4.3/rgdal/gdal
GDAL does not use iconv for recoding strings.
GDAL binary built with GEOS: TRUE
Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
Path to PROJ shared files: C:/Users/lisa1/AppData/Local/R/win-library/4.3/rgdal/proj
PROJ CDN enabled: FALSE
Linking to sp version:1.6-0
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
library(ggplot2)library(maptools)
Checking rgeos availability: TRUE
Please note that 'maptools' will be retired during 2023,
plan transition at your earliest convenience;
some functionality will be moved to 'sp'.
rgeos version: 0.6-3, (SVN revision 696)
GEOS runtime version: 3.11.2-CAPI-1.17.2
Please note that rgeos will be retired during October 2023,
plan transition to sf or terra functions using GEOS at your earliest convenience.
See https://r-spatial.org/r/2023/05/15/evolution4.html for details.
GEOS using OverlayNG
Linking to sp version: 1.6-0
Polygon checking: TRUE
col_mun@data$id =rownames(col_mun@data)municipios.points <-fortify(col_mun,region ="id")#transformar o shape de municipios em dataframemunicipios.df <-join(municipios.points,col_mun@data,by ="id")library(maps)library(ggmap)library(tidyverse)
Attaching package: 'cowplot'
The following object is masked from 'package:lubridate':
stamp
The following object is masked from 'package:ggmap':
theme_nothing
Coordinate system already present. Adding new coordinate system, which will
replace the existing one.
#####Exercício 2: Utilizando os recursos do banco de dados do GBIF e utilizando o pacote rgbif, apresente a localização de alguma espécie que você estude ou goste. Lembre-se que se a distribuição é muito ampla, os dados vão demorar a carregar, então limitar o número de observações ou escolher uma espécie de distribuição restrita pode ser uma opção!
library(tidyverse)library(ggmap)library(maps)##tem alguns mapas já previamente feitoslibrary(rgbif)ocorrencia<-occ_search(scientificName="Butia exilata", hasCoordinate=T)local<-as.data.frame(ocorrencia$data)library(jpeg)setwd("C:/Users/lisa1/Documents/UFPR/Doutorado/Disci_dados_R/")butia <-readJPEG("butia_exilata.jpg")butiar<-as.raster(butia)library(geobr)
Rows: 805 Columns: 16
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (6): scientificName, taxonConceptID, recordID, dataResourceName, month,...
dbl (7): decimalLatitude, decimalLongitude, year, hour, prcp, tmax, tmin
lgl (1): dryandra
dttm (1): eventDate
date (1): day
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#write.table(numbats,"numbats.csv")#Faço o mapa da regiao de estudomapa_aus<-map_data("world", region="Australia")#Faco mapa da regiao de estudo mais pontos de ocorrenciamap_numbats<-ggplot(data=numbats, aes(x=decimalLongitude, y=decimalLatitude))+coord_equal()+geom_map(data=mapa_aus, map=mapa_aus, aes(x=long, y=lat, map_id=region), fill="brown",alpha=0.5, color="black")+stat_density2d(aes(fill = ..level..), alpha = .8,geom ="polygon", data = numbats)+geom_point(aes(color=year))+facet_wrap(~year)+theme_void()+labs(title ="Pontos de corrência de numbats na Australia entre 1856-2023")+theme(axis.title =element_blank(),axis.text =element_blank(),legend.position ="none",plot.background =element_rect(fill="white", color=NA),panel.background =element_rect(fill="white", color=NA),strip.background =element_rect(fill="white", color="darkgray"),plot.title =element_text(size =14, margin=margin(3,3,25,1)))
Warning in geom_map(data = mapa_aus, map = mapa_aus, aes(x = long, y = lat, :
Ignoring unknown aesthetics: x and y
map_numbats
Warning: The dot-dot notation (`..level..`) was deprecated in ggplot2 3.4.0.
ℹ Please use `after_stat(level)` instead.
Warning: Computation failed in `stat_density2d()`
Computation failed in `stat_density2d()`
Computation failed in `stat_density2d()`
Caused by error in `if (any(h <= 0)) ...`:
! valor ausente donde TRUE/FALSE es necesario
Warning: Computation failed in `stat_density2d()`
Computation failed in `stat_density2d()`
Caused by error in `MASS::kde2d()`:
! bandwidths must be strictly positive
Warning: Computation failed in `stat_density2d()`
Caused by error in `if (any(h <= 0)) ...`:
! valor ausente donde TRUE/FALSE es necesario
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: Computation failed in `stat_density2d()`
Computation failed in `stat_density2d()`
Computation failed in `stat_density2d()`
Caused by error in `if (any(h <= 0)) ...`:
! valor ausente donde TRUE/FALSE es necesario
Warning: Computation failed in `stat_density2d()`
Computation failed in `stat_density2d()`
Caused by error in `MASS::kde2d()`:
! bandwidths must be strictly positive
Warning: Computation failed in `stat_density2d()`
Caused by error in `if (any(h <= 0)) ...`:
! valor ausente donde TRUE/FALSE es necesario
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
Warning: `stat_contour()`: Zero contours were generated
Warning in min(x): ningún argumento finito para min; retornando Inf
Warning in max(x): ningun argumento finito para max; retornando -Inf
#####Exercício 4: Utilizando os dados de [Culturas agrícolas do passado, faça um mapa mostrando a ocorrência das diferentes famílias de culturas agrícolas. (um mapa ou vários mapas)
Rows: 4490 Columns: 24
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (18): source, source_id, source_site_name, site_name, phase, phase_descr...
dbl (6): latitude, longitude, age_start, age_end, n, prop
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#write.table(culturas,"culturas.csv")##mudo o nome das variáveis dentro da coluna categoryculturas2<-mutate(culturas,`category`=recode(`category`, `Fruits/nuts`="Frutas/nueces", Grasses="Gramineas", Pulses="Leguminosas",`Wild plants`="Plantas selvagens"))library(tidyverse)library(ggplot2)culturasgraf<-ggplot()+borders("world", fill ="lightgray", colour ="gray")+geom_point(data =filter(culturas2, (!is.na(category))), aes(x= longitude, y= latitude, color=category), alpha=0.5)+coord_fixed(xlim=c(20, 60), ylim=c(20, 50))+facet_wrap(~category)+theme_void()+labs(title ="Culturas agrícolas do passado")+scale_fill_brewer(palette="YlGnBu")+theme(panel.grid =element_blank(), plot.background =element_rect(fill ="#FFFFD9" , color=NA),plot.title =element_text(colour ="#081D58", size=18),legend.position="none",strip.background =element_rect(fill ="#FFFFD9"),strip.text =element_text(colour ="#081D58", size=14))culturasgraf