background-image: url(file:///home/gabriel/suporte/ciencia_de_dados/projeto/mapa_flipbook/img/capa_mapa.jpg) background-size: cover <h2 style="font-size: 97px; position: relative;top: 225px; color: white;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;text-align: center;"> Visualização GeoEspacial com R </h2> <br><br><br> <h2 style="font-size: 47px; position: relative;top: 300px; color: white;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;text-align: center;"> Gabriel Sartori </h2> <!-- --- --> <!-- # Diferentes Mapas --> --- # Bibliotecas R <br> <div class="img_center"> <img src = "https://www.rstudio.com/wp-content/uploads/2014/04/ggplot2.png" alt = "gif2" width = "290px" /> </div> -- + Plus ```r devtools::install_github("yutannihilation/gghighlight") ``` --- background-image: url(file:///home/gabriel/suporte/ciencia_de_dados/projeto/mapa_flipbook/img/mercado_imobiliario.jpg) background-size: cover --- ## Dados Imobiliários + Curitiba + Valor Locação + Apartamento/Casa + Quartos: 2 ``` # A tibble: 75 x 5 regional bairro quarto apartamento casa <chr> <chr> <dbl> <dbl> <dbl> 1 PORTÃO ÁGUA VERDE 2 1100 675 2 MATRIZ JARDIM SOCIAL NA NA NA 3 BOQUEIRÃO XAXIM 2 950 750 4 CAJURU JARDIM DAS AMÉRICAS 2 950 1500 5 PORTÃO GUAÍRA 2 1100 550 6 BOA VISTA BAIRRO ALTO 2 750 700 7 MATRIZ SÃO FRANCISCO 2 1280 1238. 8 MATRIZ ALTO DA GLÓRIA NA NA NA 9 BOA VISTA ATUBA 2 750 900 10 MATRIZ CABRAL NA NA NA # … with 65 more rows ``` --- class: split-40 count: false .column[.content[ ```r *ggplot(data = moradia_quarto2) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_1-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + * aes(x = apartamento) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_2-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + * aes(y = casa) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_3-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + * geom_point(colour = "purple") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_4-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + * labs(x = "Apartamento") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_5-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + * labs(y = "Casa") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_6-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + labs(y = "Casa") + * labs(title = "Relação Valor Locação Casa e Apartamento") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_7-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + labs(y = "Casa") + labs(title = "Relação Valor Locação Casa e Apartamento") + * geom_vline(xintercept = media_ap, linetype = "dashed") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_8-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + labs(y = "Casa") + labs(title = "Relação Valor Locação Casa e Apartamento") + geom_vline(xintercept = media_ap, linetype = "dashed") + * geom_hline(yintercept = media_casa, linetype = "dashed") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_9-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + labs(y = "Casa") + labs(title = "Relação Valor Locação Casa e Apartamento") + geom_vline(xintercept = media_ap, linetype = "dashed") + geom_hline(yintercept = media_casa, linetype = "dashed") + * gghighlight(apartamento > media_ap & casa > media_casa, unhighlighted_params = list(colour = "white", fill = "white")) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_10-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + labs(y = "Casa") + labs(title = "Relação Valor Locação Casa e Apartamento") + geom_vline(xintercept = media_ap, linetype = "dashed") + geom_hline(yintercept = media_casa, linetype = "dashed") + gghighlight(apartamento > media_ap & casa > media_casa, unhighlighted_params = list(colour = "white", fill = "white")) + * geom_text_repel(aes(label = tolower(bairro)), colour = "darkred") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_11-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + labs(y = "Casa") + labs(title = "Relação Valor Locação Casa e Apartamento") + geom_vline(xintercept = media_ap, linetype = "dashed") + geom_hline(yintercept = media_casa, linetype = "dashed") + gghighlight(apartamento > media_ap & casa > media_casa, unhighlighted_params = list(colour = "white", fill = "white")) + geom_text_repel(aes(label = tolower(bairro)), colour = "darkred") + * theme_bw() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_12-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + labs(y = "Casa") + labs(title = "Relação Valor Locação Casa e Apartamento") + geom_vline(xintercept = media_ap, linetype = "dashed") + geom_hline(yintercept = media_casa, linetype = "dashed") + gghighlight(apartamento > media_ap & casa > media_casa, unhighlighted_params = list(colour = "white", fill = "white")) + geom_text_repel(aes(label = tolower(bairro)), colour = "darkred") + theme_bw() + * theme(plot.title = element_text(hjust = 0.5)) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_13-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + labs(y = "Casa") + labs(title = "Relação Valor Locação Casa e Apartamento") + geom_vline(xintercept = media_ap, linetype = "dashed") + geom_hline(yintercept = media_casa, linetype = "dashed") + gghighlight(apartamento > media_ap & casa > media_casa, unhighlighted_params = list(colour = "white", fill = "white")) + geom_text_repel(aes(label = tolower(bairro)), colour = "darkred") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + * scale_y_continuous(labels= number_br) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_14-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2) + aes(x = apartamento) + aes(y = casa) + geom_point(colour = "purple") + labs(x = "Apartamento") + labs(y = "Casa") + labs(title = "Relação Valor Locação Casa e Apartamento") + geom_vline(xintercept = media_ap, linetype = "dashed") + geom_hline(yintercept = media_casa, linetype = "dashed") + gghighlight(apartamento > media_ap & casa > media_casa, unhighlighted_params = list(colour = "white", fill = "white")) + geom_text_repel(aes(label = tolower(bairro)), colour = "darkred") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + scale_y_continuous(labels= number_br)+ * scale_x_continuous(labels= number_br) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_first_ggplot2_15-1.png" style="display: block; margin: auto;" /> ]] --- ## Dados Imobiliários com Polígono + Somente Apartamento ``` Simple feature collection with 75 features and 4 fields geometry type: POLYGON dimension: XY bbox: xmin: -49.3888 ymin: -25.64456 xmax: -49.18322 ymax: -25.34636 epsg (SRID): 4326 proj4string: +proj=longlat +datum=WGS84 +no_defs # A tibble: 75 x 5 regional bairro quarto apartamento geometry <chr> <chr> <dbl> <dbl> <POLYGON [°]> 1 PORTÃO ÁGUA VE… 2 1100 ((-49.27066 -25.45263, -49.27037 … 2 MATRIZ JARDIM … NA NA ((-49.22951 -25.41608, -49.22951 … 3 BOQUEIRÃO XAXIM 2 950 ((-49.26449 -25.48781, -49.26363 … 4 CAJURU JARDIM … 2 950 ((-49.22732 -25.47163, -49.22832 … 5 PORTÃO GUAÍRA 2 1100 ((-49.28195 -25.47656, -49.28304 … 6 BOA VISTA BAIRRO … 2 750 ((-49.20701 -25.39856, -49.20701 … 7 MATRIZ SÃO FRA… 2 1280 ((-49.27193 -25.42794, -49.27266 … 8 MATRIZ ALTO DA… NA NA ((-49.26295 -25.4153, -49.26295 -… 9 BOA VISTA ATUBA 2 750 ((-49.20707 -25.37203, -49.20706 … 10 MATRIZ CABRAL NA NA ((-49.24056 -25.40934, -49.24056 … # … with 65 more rows ``` --- class: split-40 count: false .column[.content[ ```r *ggplot(data = moradia_quarto2 ) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_firstmapa_1-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2 ) + * geom_sf() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_firstmapa_2-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2 ) + geom_sf() + * coord_sf() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_firstmapa_3-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2 ) + geom_sf() + coord_sf() + * aes(fill = apartamento) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_firstmapa_4-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2 ) + geom_sf() + coord_sf() + aes(fill = apartamento) + * theme_void() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_firstmapa_5-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2 ) + geom_sf() + coord_sf() + aes(fill = apartamento) + theme_void() + * theme(panel.grid.major = element_line(colour = "transparent")) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_firstmapa_6-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2 ) + geom_sf() + coord_sf() + aes(fill = apartamento) + theme_void() + theme(panel.grid.major = element_line(colour = "transparent")) + * scale_fill_gradientn(colours = brewer.pal(5, "Oranges"), na.value = "white", labels = number_br) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_firstmapa_7-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2 ) + geom_sf() + coord_sf() + aes(fill = apartamento) + theme_void() + theme(panel.grid.major = element_line(colour = "transparent")) + scale_fill_gradientn(colours = brewer.pal(5, "Oranges"), na.value = "white", labels = number_br) + * gghighlight(!is.na(apartamento), unhighlighted_params = list(colour = "gray70", fill = "gray90")) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_firstmapa_8-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = moradia_quarto2 ) + geom_sf() + coord_sf() + aes(fill = apartamento) + theme_void() + theme(panel.grid.major = element_line(colour = "transparent")) + scale_fill_gradientn(colours = brewer.pal(5, "Oranges"), na.value = "white", labels = number_br) + gghighlight(!is.na(apartamento), unhighlighted_params = list(colour = "gray70", fill = "gray90")) + * labs(fill = "Valor") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_firstmapa_9-1.png" style="display: block; margin: auto;" /> ]] --- # Qual paleta Escolher ? <img src="./img/gg_cor.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- # Paleta Sequencial + Adequado para variáveis numérica que mantém um mesmo matriz de cor, apenas com incrementos de brilho, do mais claro para o mais escuro, que indicam o quão menor ou maior é o valor. + Exemplo: Indicadores de Saúde, Segurança <img src="mapa_flipbook_files/figure-html/unnamed-chunk-11-1.png" style="display: block; margin: auto;" /> + Pacote `RColorBrewer`, veja todas as opções em `display.brewer.all()` --- # Divergente + Indicado para valores que refletem a natureza de duas posições extremas + Adequado para variáveis em que o valor central é neutro, ou represente equilíbrio entre duas partes + Exemplo: Correlação Pearson [-1; 1]; Razão entre as ideologias políticas <img src="mapa_flipbook_files/figure-html/unnamed-chunk-12-1.png" style="display: block; margin: auto;" /> --- # Paleta Qualitativa + Adequado para variáveis categóricas na qual deseja distingui-las + Não é adequado usar para representar variáveis numéricas + Exemplo: Partido político de cada município <img src="mapa_flipbook_files/figure-html/unnamed-chunk-13-1.png" style="display: block; margin: auto;" /> <!-- --- --> <!-- ## Escala --> --- # Escala (Qual paletta descreve melhor ) <img src="./img/gg_escala.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- # Distribuição dos grupos por Escala <img src="./img/grupos_escala.png" width="100%" height="100%" style="display: block; margin: auto;" /> --- # Considerações Escala + Definir escalas, consiste em criar grupos distintos + Prefira escalas que remetam a interpretações práticas dos grupos + As escalas quantílicas e kmeans, ou qualquer método de agrupamento são critérios estatísticos + Na dúvida, ou sem uma escala pré-existente da área, exponha diferentes escalas que podem ser feitas + Número impar de grupos, sugere que o grupo intermediário tenha uma interpretação neutra --- ## Mercado Imobiliário + Curitiba + Valor Locação + Apartamento + Quartos: 1 e 2 ``` Simple feature collection with 99 features and 3 fields geometry type: POLYGON dimension: XY bbox: xmin: -49.38664 ymin: -25.63296 xmax: -49.18322 ymax: -25.34663 epsg (SRID): 4326 proj4string: +proj=longlat +datum=WGS84 +no_defs # A tibble: 99 x 4 bairro quarto apartamento geometry <chr> <chr> <dbl> <POLYGON [°]> 1 ABRANCHES Quarto:… 650 ((-49.2705 -25.34667, -49.27038 -25.3467… 2 ÁGUA VER… Quarto:… 1150 ((-49.27066 -25.45263, -49.27037 -25.453… 3 ÁGUA VER… Quarto:… 1100 ((-49.27066 -25.45263, -49.27037 -25.453… 4 AHÚ Quarto:… 1200 ((-49.25776 -25.39402, -49.25732 -25.394… 5 ALTO BOQ… Quarto:… 600 ((-49.24899 -25.51736, -49.24869 -25.517… 6 ALTO BOQ… Quarto:… 750 ((-49.24899 -25.51736, -49.24869 -25.517… 7 ALTO DA … Quarto:… 1094. ((-49.25457 -25.43278, -49.25521 -25.433… 8 ATUBA Quarto:… 770 ((-49.20707 -25.37203, -49.20706 -25.372… 9 ATUBA Quarto:… 750 ((-49.20707 -25.37203, -49.20706 -25.372… 10 AUGUSTA Quarto:… 670 ((-49.38558 -25.44318, -49.38465 -25.443… # … with 89 more rows ``` --- class: split-40 count: false .column[.content[ ```r *ggplot() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_facetmapa_1-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + * geom_sf(data = cwb, fill = "gray80", colour = "white") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_facetmapa_2-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray80", colour = "white") + * geom_sf(data = moradia_quarto2_1, aes(fill = apartamento)) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_facetmapa_3-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray80", colour = "white") + geom_sf(data = moradia_quarto2_1, aes(fill = apartamento)) + * facet_wrap(~quarto, ncol = 2) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_facetmapa_4-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray80", colour = "white") + geom_sf(data = moradia_quarto2_1, aes(fill = apartamento)) + facet_wrap(~quarto, ncol = 2) + * scale_fill_gradientn(colours = brewer.pal(5, "Oranges"), na.value = "white", labels = number_br) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_facetmapa_5-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray80", colour = "white") + geom_sf(data = moradia_quarto2_1, aes(fill = apartamento)) + facet_wrap(~quarto, ncol = 2) + scale_fill_gradientn(colours = brewer.pal(5, "Oranges"), na.value = "white", labels = number_br) + * labs(fill = "Valor") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_facetmapa_6-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray80", colour = "white") + geom_sf(data = moradia_quarto2_1, aes(fill = apartamento)) + facet_wrap(~quarto, ncol = 2) + scale_fill_gradientn(colours = brewer.pal(5, "Oranges"), na.value = "white", labels = number_br) + labs(fill = "Valor") + * theme_void() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_facetmapa_7-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray80", colour = "white") + geom_sf(data = moradia_quarto2_1, aes(fill = apartamento)) + facet_wrap(~quarto, ncol = 2) + scale_fill_gradientn(colours = brewer.pal(5, "Oranges"), na.value = "white", labels = number_br) + labs(fill = "Valor") + theme_void() + * theme(legend.key.size = unit(0.5, "cm")) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_facetmapa_8-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray80", colour = "white") + geom_sf(data = moradia_quarto2_1, aes(fill = apartamento)) + facet_wrap(~quarto, ncol = 2) + scale_fill_gradientn(colours = brewer.pal(5, "Oranges"), na.value = "white", labels = number_br) + labs(fill = "Valor") + theme_void() + theme(legend.key.size = unit(0.5, "cm")) + * theme(panel.grid.major = element_line(colour = "transparent")) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_facetmapa_9-1.png" style="display: block; margin: auto;" /> ]] --- background-image: url(file:///home/gabriel/suporte/ciencia_de_dados/projeto/mapa_flipbook/img/evento.jpg) background-size: cover --- # [Evertbrite](https://www.eventbrite.com.br/) <img src="./img/evertbrite.png" width="95%" height="100%" style="display: block; margin: auto;" /> --- # Eventos Curitiba + Livres/Pagos + Extração dos eventos 08/03 ``` Simple feature collection with 107 features and 4 fields geometry type: POINT dimension: XY bbox: xmin: -49.36726 ymin: -25.56672 xmax: -49.22387 ymax: -25.38577 epsg (SRID): 4326 proj4string: +proj=longlat +datum=WGS84 +no_defs # A tibble: 107 x 5 title data tag_category gratuito geometry <chr> <date> <chr> <chr> <POINT [°]> 1 PALESTRA GRA… 2019-04-08 Negócios Sim (-49.28203 -25.4494) 2 Workshop de … 2019-03-23 Saúde Não (-49.29301 -25.44788) 3 Maquiagem e … 2019-03-09 Moda e Beleza Sim (-49.2754 -25.45029) 4 EMC Concept … 2019-06-03 Moda e Beleza Não (-49.27912 -25.44277) 5 Empreenda Ma… 2019-03-14 Negócios Sim (-49.27718 -25.44322) 6 Formação Mov… 2019-06-08 Saúde Não (-49.23334 -25.45988) 7 WORKSHOP ENT… 2019-07-14 Moda e Beleza Não (-49.23162 -25.45632) 8 Yôga (100% G… 2019-03-10 Saúde Sim (-49.27644 -25.42139) 9 Open Data Da… 2019-03-09 Ciência e Te… Sim (-49.27224 -25.42481) 10 PALESTRA | C… 2019-03-30 Negócios Sim (-49.2722 -25.42782) # … with 97 more rows ``` --- class: split-40 count: false .column[.content[ ```r *ggplot() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapaevento_1-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + * geom_sf(data = cwb, fill = "gray90", colour = "white") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapaevento_2-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray90", colour = "white") + * geom_sf(data = evento, show.legend = "point", size = 2) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapaevento_3-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray90", colour = "white") + geom_sf(data = evento, show.legend = "point", size = 2) + * aes(colour = gratuito) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapaevento_4-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray90", colour = "white") + geom_sf(data = evento, show.legend = "point", size = 2) + aes(colour = gratuito) + * theme_void() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapaevento_5-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray90", colour = "white") + geom_sf(data = evento, show.legend = "point", size = 2) + aes(colour = gratuito) + theme_void() + * theme(legend.key.size = unit(1.15, "cm")) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapaevento_6-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb, fill = "gray90", colour = "white") + geom_sf(data = evento, show.legend = "point", size = 2) + aes(colour = gratuito) + theme_void() + theme(legend.key.size = unit(1.15, "cm")) + * theme(panel.grid.major = element_line(colour = 'transparent')) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapaevento_7-1.png" style="display: block; margin: auto;" /> ]] --- # Basemaps <img src="./img/basemaps.jpg" width="85%" height="90%" style="display: block; margin: auto;" /> --- class: split-40 count: false .column[.content[ ```r *ggplot() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapabg_1-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + * geom_sf(data = cwb) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapabg_2-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + * annotation_map_tile(type = "cartolight", zoom = 12) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapabg_3-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "cartolight", zoom = 12) + * geom_sf(data = evento, aes(colour = gratuito), show.legend = "point") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapabg_4-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "cartolight", zoom = 12) + geom_sf(data = evento, aes(colour = gratuito), show.legend = "point") + * geom_sf(data = cwb_union, fill = "transparent", colour = "gray40") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapabg_5-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "cartolight", zoom = 12) + geom_sf(data = evento, aes(colour = gratuito), show.legend = "point") + geom_sf(data = cwb_union, fill = "transparent", colour = "gray40") + * theme_void() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapabg_6-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "cartolight", zoom = 12) + geom_sf(data = evento, aes(colour = gratuito), show.legend = "point") + geom_sf(data = cwb_union, fill = "transparent", colour = "gray40") + theme_void() + * theme(panel.grid.major = element_line(colour = 'transparent')) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_mapabg_7-1.png" style="display: block; margin: auto;" /> ]] --- # Opções de Mapas + Opções do pacote, mude o argumento `type` da função `annotation_map_tile` ```r rosm::osm.types() # Alguns precisam de api ``` ``` [1] "osm" "opencycle" [3] "hotstyle" "loviniahike" [5] "loviniacycle" "hikebike" [7] "hillshade" "osmgrayscale" [9] "stamenbw" "stamenwatercolor" [11] "osmtransport" "thunderforestlandscape" [13] "thunderforestoutdoors" "cartodark" [15] "cartolight" ``` + registrar base map ```r rosm::register_tile_source(mapa_wiki = "https://maps.wikimedia.org/osm-intl/${z}/${x}/${y}.png") ``` + Sites que disponibilizam basemaps <a href= http://leaflet-extras.github.io/leaflet-providers/preview/index.html/> leaflet </a> <br> <a href=https://www.thunderforest.com/> thunder forest</a> <br> <a href=https://www.xyht.com/spatial-itgis/using-openstreetmap-basemaps-qgis-3-0/> WikiMaps</a> --- # Leitura Objeto Espacial <br> <div class="img_center"> <img src = "https://user-images.githubusercontent.com/520851/34887433-ce1d130e-f7c6-11e7-83fc-d60ad4fae6bd.gif" style = "width: 270px;" alt = "gif" /> </div> --- # Formatos Geográficos <br> <img src = "./img/shapefile.png" style = "width: 259px;" alt = "shapefile" /> <img src = "./img/geojson.png" style = "width: 261px;" alt = "geojson" /> <img src = "./img/kml.png" style = "width: 197px;" alt = "kml" /> <img src = "./img/tiff.png" style = "width: 261px;" alt = "tiff" /> --- ## Ênfase <br> <img src = "./img/shapefile.png" style = "width: 259px;" alt = "shapefile" /> <img src = "./img/geojson.png" style = "width: 261px;" alt = "geojson" /> --- # Shapefile e Geojson *Shapefile* + .shp; .shx; .dbf (devem estar na mesma pasta) + .prj - opcional ```r require(sf) cwb <- read_sf( dsn = "/home/gabriel/suporte/ciencia_de_dados/base_de_dado/ipppuc/bairro_sirgas", # caminho do arquivo layer = "DIVISA_DE_BAIRROS") # nome do arquivo ``` -- *Geojson* + .geojson ```r require(geojsonsf) cwb <- geojson_sf("https://raw.githubusercontent.com/gustavokira/geo-curitiba/master/json/bairros.geo.json") ``` --- # Resultado ```r cwb ``` ``` Simple feature collection with 75 features and 6 fields geometry type: POLYGON dimension: XY bbox: xmin: -49.3888 ymin: -25.64447 xmax: -49.18323 ymax: -25.34628 epsg (SRID): 4326 proj4string: +proj=longlat +datum=WGS84 +no_defs First 10 features: nome_regional codigo_regional area nome codigo 1 REGIONAL PORTÃO 7 4773046.2 ÁGUA VERDE 9 2 REGIONAL MATRIZ 1 1958421.9 JARDIM SOCIAL 18 3 REGIONAL BOQUEIRÃO 2 9085388.0 XAXIM 57 4 REGIONAL CAJURU 3 3859033.4 JARDIM DAS AMÉRICAS 22 5 REGIONAL PORTÃO 7 2311397.6 GUAÍRA 26 6 REGIONAL BOA VISTA 4 7201072.4 BAIRRO ALTO 36 7 REGIONAL MATRIZ 1 1354451.4 SÃO FRANCISCO 2 8 REGIONAL MATRIZ 1 875482.7 ALTO DA GLÓRIA 4 9 REGIONAL BOA VISTA 4 4159365.1 ATUBA 55 10 REGIONAL MATRIZ 1 2026591.0 CABRAL 16 geometry tipo 1 POLYGON ((-49.27067 -25.452... bairro 2 POLYGON ((-49.22952 -25.415... bairro 3 POLYGON ((-49.2645 -25.4877... bairro 4 POLYGON ((-49.22733 -25.471... bairro 5 POLYGON ((-49.28196 -25.476... bairro 6 POLYGON ((-49.20702 -25.398... bairro 7 POLYGON ((-49.27194 -25.427... bairro 8 POLYGON ((-49.26296 -25.415... bairro 9 POLYGON ((-49.20708 -25.371... bairro 10 POLYGON ((-49.24056 -25.409... bairro ``` --- # Bases de Dados Espaciais <br> **Explore as bases de dados espaciais** + [IPPUC][ippuc] + [estados do Brasil][brasil-geojson] + [Instituto de Terras, Cartografia e Geologia do Paraná][itcg] + [data-gov][data-energy] + [EUA][data-gov] + [energia][data-energy] + [World Resource Institute][world-resource-institute] --- # Criando Objeto Espacial <br> + Vamos considerar que você recebeu um conjunto de latitude e longitude (ponto) e deseja transformar em objeto espacial! + Dados de Monitoramento de Qualidade da água em Curitiba ``` Observations: 6 Variables: 4 $ id_estacao <chr> "65007010", "65007020", "65007022", "65007030", "6501… $ ph <dbl> 7.8, 7.8, 7.4, 7.7, 7.4, 7.6 $ latitude <dbl> -25.38, -25.38, -25.39, -25.40, -25.37, -25.43 $ longitude <dbl> -49.19, -49.23, -49.22, -49.21, -49.26, -49.26 ``` + Formato do Dado ```r qualidade_agua %>% class() ``` ``` [1] "tbl_df" "tbl" "data.frame" ``` -- + *Se você tentar um plot.. vai acontecer isso* --- ```r plot(qualidade_agua) ``` <img src="mapa_flipbook_files/figure-html/unnamed-chunk-31-1.png" style="display: block; margin: auto;" /> --- # Transformando em objeto espacial ```r sf_qualidade_agua <- sf::st_as_sf(x = qualidade_agua, # base de dados coords = c("longitude", "latitude"), # Variáveis espaciais agr = "identity", # Atributo identidade crs = 4326) # Sistema de referência geografica ``` + Formato do Dado ```r sf_qualidade_agua %>% head(n = 1) ``` ``` Simple feature collection with 1 feature and 2 fields Attribute-geometry relationship: 0 constant, 0 aggregate, 2 identity geometry type: POINT dimension: XY bbox: xmin: -49.19 ymin: -25.38 xmax: -49.19 ymax: -25.38 epsg (SRID): 4326 proj4string: +proj=longlat +datum=WGS84 +no_defs # A tibble: 1 x 3 id_estacao ph geometry <chr> <dbl> <POINT [°]> 1 65007010 7.8 (-49.19 -25.38) ``` + <a href = "https://bookdown.org/robinlovelace/geocompr/spatial-class.html#crs-intro"> detalhes crs </a> --- class: split-40 count: false .column[.content[ ```r *ggplot() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_1-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + * geom_sf(data = cwb) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_2-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + * annotation_map_tile(type = "hydra_base", zoom = 12) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_3-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "hydra_base", zoom = 12) + * geom_sf(data = cwb_union, fill = "transparent", colour = "white") ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_4-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "hydra_base", zoom = 12) + geom_sf(data = cwb_union, fill = "transparent", colour = "white") + * geom_sf(data = sf_qualidade_agua, colour = "black", size = 2.5) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_5-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "hydra_base", zoom = 12) + geom_sf(data = cwb_union, fill = "transparent", colour = "white") + geom_sf(data = sf_qualidade_agua, colour = "black", size = 2.5) + * geom_sf(data = sf_qualidade_agua, aes(colour = ph) , size = 2) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_6-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "hydra_base", zoom = 12) + geom_sf(data = cwb_union, fill = "transparent", colour = "white") + geom_sf(data = sf_qualidade_agua, colour = "black", size = 2.5) + geom_sf(data = sf_qualidade_agua, aes(colour = ph) , size = 2) + * scale_colour_gradientn(colours = brewer.pal(5, "Blues")) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_7-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "hydra_base", zoom = 12) + geom_sf(data = cwb_union, fill = "transparent", colour = "white") + geom_sf(data = sf_qualidade_agua, colour = "black", size = 2.5) + geom_sf(data = sf_qualidade_agua, aes(colour = ph) , size = 2) + scale_colour_gradientn(colours = brewer.pal(5, "Blues")) + * theme_void() ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_8-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "hydra_base", zoom = 12) + geom_sf(data = cwb_union, fill = "transparent", colour = "white") + geom_sf(data = sf_qualidade_agua, colour = "black", size = 2.5) + geom_sf(data = sf_qualidade_agua, aes(colour = ph) , size = 2) + scale_colour_gradientn(colours = brewer.pal(5, "Blues")) + theme_void() + * theme(panel.grid.major = element_line(colour = 'transparent')) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_9-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "hydra_base", zoom = 12) + geom_sf(data = cwb_union, fill = "transparent", colour = "white") + geom_sf(data = sf_qualidade_agua, colour = "black", size = 2.5) + geom_sf(data = sf_qualidade_agua, aes(colour = ph) , size = 2) + scale_colour_gradientn(colours = brewer.pal(5, "Blues")) + theme_void() + theme(panel.grid.major = element_line(colour = 'transparent')) + * theme(legend.key.size = unit(0.75, "cm")) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_10-1.png" style="display: block; margin: auto;" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot() + geom_sf(data = cwb) + annotation_map_tile(type = "hydra_base", zoom = 12) + geom_sf(data = cwb_union, fill = "transparent", colour = "white") + geom_sf(data = sf_qualidade_agua, colour = "black", size = 2.5) + geom_sf(data = sf_qualidade_agua, aes(colour = ph) , size = 2) + scale_colour_gradientn(colours = brewer.pal(5, "Blues")) + theme_void() + theme(panel.grid.major = element_line(colour = 'transparent')) + theme(legend.key.size = unit(0.75, "cm")) + * theme(legend.text = element_text(size = 8)) ``` ]] .column[.content.center[ <img src="mapa_flipbook_files/figure-html/output_qualidade_agua_11-1.png" style="display: block; margin: auto;" /> ]] --- # Referência <a href="https://geocompr.robinlovelace.net/"> <img bordxer="0" alt="tops" src="./img/geocomputing.jpeg" width="399" height="520"> </a> --- # Agradecimentos <br> + Daniel Ruffasto, scrapping dos eventos no site Evertbrite + Equipe MAPI --- # Contato <br> + gsartorik@gmail.com + [gsartorik.com][site-pessoal] + Todo material está disponível em no [github][github-gabriel] <style type="text/css"> .remark-code{ line-height: 1.25; # Espaçamento das linhas nos códigos font-size: 45% # tamanho da fonte nos códigos } </style> [ippuc]: http://ippuc.org.br/geodownloads/geo.htm [brasil-geojson]: https://github.com/tbrugz/geodata-br [data-gov]: https://catalog.data.gov/organization/01ca8df8-6248-41e6-baa2-8b682e4b5a08?res_format=SHP&_res_format_limit=0 [data-energy]: https://energydata.info/dataset?res_format=GeoJSON&page=1 [data-gov]: http://dados.gov.br/dataset?res_format=ZIP+SHP&_res_format_limit=0 [itcg]: http://www.itcg.pr.gov.br/modules/faq/category.php?categoryid=9# [world-resource-institute]: http://datasets.wri.org/dataset?q=Forests&res_format=GeoJSON [site-pessoal]: https://gsartorik.com/pt/ [github-gabriel]: https://github.com/GabrielSartori/mapa_flipbook <!-- https://geocompr.robinlovelace.net/images/cover.png -->