suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(leaflet))
suppressPackageStartupMessages(library(leaflet))
suppressPackageStartupMessages(library(sf))
#suppressPackageStartupMessages(library(rgdal))
#suppressPackageStartupMessages(library(rayshader))
suppressPackageStartupMessages(library(ggspatial))
suppressPackageStartupMessages(library(leaflet.extras))
suppressPackageStartupMessages(library(leafem))
suppressPackageStartupMessages(library(ggmap))
# read data
bairros <- read_rds("data/sf/bairros.rds")
limites <- read_rds("data/sf/limites.rds")
quadras <- read_rds("data/sf/quadras.rds")
quadras_crop <- read_rds("data/sf/quadras_crop.rds")
quadras_intersects <- read_rds("data/sf/quadras_intersects.rds")
clarissa <- read_rds("data/sf/clarissa.rds")
circle_500m <- read_rds("data/sf/circle_500m.rds") A New Output Format
clarissa.center <- st_transform(st_centroid(st_transform(clarissa$geometry, 3857)), 4326)
quadra39 <- quadras %>% filter(SETOR == 38)
lote39 <- quadra39 %>% filter(QD_ATUAL == 39)
quadra39 <- quadra39 %>%
mutate(centroid = st_transform(st_centroid(st_transform(geometry,3857)), 4326))
quadras <- quadras %>%
mutate(centroid = st_transform(st_centroid(st_transform(geometry,3857)), 4326))
quadras_crop <- quadras_crop %>%
mutate(centroid = st_transform(st_centroid(st_transform(geometry,3857)), 4326))
quadras_intersects <- quadras_intersects %>%
mutate(centroid = st_transform(st_centroid(st_transform(geometry,3857)), 4326))Mapas
ggplot() +
geom_sf(data = quadra39 %>% st_transform(3857)) +
geom_sf(data = clarissa, fill = "red") +
geom_sf_text(aes(label = label),
data = quadra39 %>% rename(label = QD_ATUAL) %>% mutate(area = st_area(geometry), geometry = centroid, txt = st_as_text(geometry)) %>%
select(label, geometry, txt, area) %>%
filter(!str_detect(txt, "EMPTY"), as.numeric(area) > 4000) %>%
st_transform(3857),
size = 3) +
xlab("Longitude")+ ylab("Latitude")+
annotation_north_arrow(location = "tr", which_north = "true", height = unit(1, 'cm'), width = unit(1, 'cm')) +
annotation_scale(location = "tl", pad_x = unit(.5, 'cm'), pad_y = unit(.5, 'cm'), bar_cols = c("white", "black"))ggplot() +
geom_sf(data = quadras_crop %>% st_transform(3857)) +
geom_sf(data = clarissa, fill = "red") +
geom_sf_text(aes(label = label),
data = quadras_crop %>% rename(label = QD_ATUAL) %>%
mutate(area = st_area(geometry), geometry = centroid, txt = st_as_text(geometry)) %>%
select(label, geometry, txt, area) %>%
filter(!str_detect(txt, "EMPTY"), as.numeric(area) > 4000) %>%
st_transform(3857),
size = 3) +
xlab("Longitude")+ ylab("Latitude")+
geom_sf(data = circle_500m, color = alpha("darkgreen",1), fill = alpha("white",0), size = 1.5) +
annotation_north_arrow(location = "tr", which_north = "true", height = unit(1, 'cm'), width = unit(1, 'cm')) +
annotation_scale(location = "tl", pad_x = unit(.5, 'cm'), pad_y = unit(.5, 'cm'), bar_cols = c("white", "black"))ggplot() +
geom_sf(data = quadras_intersects %>% st_transform(3857)) +
geom_sf(data = clarissa, fill = "red") +
geom_sf_text(aes(label = label),
data = quadras_intersects %>% rename(label = QD_ATUAL) %>% mutate(area = st_area(geometry), geometry = centroid, txt = st_as_text(geometry)) %>%
select(label, geometry, txt, area) %>%
filter(!str_detect(txt, "EMPTY"), as.numeric(area) > 4000) %>%
st_transform(3857),
size = 3) +
xlab("Longitude")+ ylab("Latitude") +
geom_sf(data = circle_500m, color = alpha("darkgreen",1), fill = alpha("white",0), size = 1.5) +
annotation_north_arrow(location = "tr", which_north = "true", height = unit(1, 'cm'), width = unit(1, 'cm')) +
annotation_scale(location = "tl", pad_x = unit(.5, 'cm'), pad_y = unit(.5, 'cm'), bar_cols = c("white", "black"))get_googlemap(center = c(st_coordinates(clarissa.center)),
zoom = 16,
maptype = "roadmap") %>%
ggmap() +
geom_sf(data = quadras_crop, inherit.aes = FALSE, fill = alpha("white", 0)) +
geom_sf(data = circle_500m, inherit.aes = FALSE, color = alpha("red", 0.5), fill = alpha("red", 0.2), size = 1.5) +
geom_sf(data = clarissa, color = alpha("darkgreen", 0.75), fill = alpha("darkgreen", 0.1), inherit.aes = FALSE, size = 1.5) +
geom_sf_text(aes(label = label),
data = quadras_crop %>%
rename(label = QD_ATUAL) %>%
mutate(area = st_area(geometry), geometry = centroid, txt = st_as_text(geometry)) %>%
select(label, geometry, txt, area) %>%
filter(!str_detect(txt, "EMPTY"), as.numeric(area) > 4000),
size = 3, inherit.aes = FALSE) +
xlab("Longitude")+ ylab("Latitude")+
annotation_north_arrow(location = "tr", which_north = "true", height = unit(1, 'cm'), width = unit(1, 'cm')) +
annotation_scale(location = "tl", pad_x = unit(.5, 'cm'), pad_y = unit(.5, 'cm'), bar_cols = c("white", "black"))## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data
get_googlemap(center = c(st_coordinates(clarissa.center)),
zoom = 16,
maptype = "satellite") %>%
ggmap() +
geom_sf(data = quadras_crop, inherit.aes = FALSE, fill = alpha("white", 0)) +
geom_sf(data = circle_500m, inherit.aes = FALSE, color = alpha("red", 0.5), fill = alpha("red", 0.2), size = 1.5) +
geom_sf(data = clarissa, color = alpha("darkgreen", 0.75), fill = alpha("darkgreen", 0.1), inherit.aes = FALSE, size = 1.5) +
geom_sf_text(aes(label = label),
data = quadras_crop %>%
rename(label = QD_ATUAL) %>%
mutate(area = st_area(geometry), geometry = centroid, txt = st_as_text(geometry)) %>%
select(label, geometry, txt, area) %>%
filter(!str_detect(txt, "EMPTY"), as.numeric(area) > 4000),
size = 3, inherit.aes = FALSE) +
xlab("Longitude")+ ylab("Latitude")+
annotation_north_arrow(location = "tr", which_north = "true", height = unit(1, 'cm'), width = unit(1, 'cm')) +
annotation_scale(location = "tl", pad_x = unit(.5, 'cm'), pad_y = unit(.5, 'cm'), bar_cols = c("white", "black"))## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data
get_googlemap(center = c(st_coordinates(clarissa.center)),
zoom = 16,
maptype = "hybrid") %>%
ggmap() +
geom_sf(data = quadras_crop, inherit.aes = FALSE, fill = alpha("white", 0)) +
geom_sf(data = circle_500m, inherit.aes = FALSE, color = alpha("red", 0.5), fill = alpha("red", 0.2), size = 1.5) +
geom_sf(data = clarissa, color = alpha("darkgreen", 0.75), fill = alpha("darkgreen", 0.1), inherit.aes = FALSE, size = 1.5) +
geom_sf_text(aes(label = label),
data = quadras_crop %>%
rename(label = QD_ATUAL) %>%
mutate(area = st_area(geometry), geometry = centroid, txt = st_as_text(geometry)) %>%
select(label, geometry, txt, area) %>%
filter(!str_detect(txt, "EMPTY"), as.numeric(area) > 4000),
size = 3, inherit.aes = FALSE) +
xlab("Longitude")+ ylab("Latitude")+
annotation_north_arrow(location = "tr", which_north = "true", height = unit(1, 'cm'), width = unit(1, 'cm')) +
annotation_scale(location = "tl", pad_x = unit(.5, 'cm'), pad_y = unit(.5, 'cm'), bar_cols = c("white", "black"))## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data
get_googlemap(center = c(st_coordinates(clarissa.center)),
zoom = 16,
maptype = "roadmap") %>%
ggmap() +
geom_sf(data = quadras_intersects, inherit.aes = FALSE, fill = alpha("white", 0)) +
geom_sf(data = circle_500m, inherit.aes = FALSE, color = alpha("red", 0.5), fill = alpha("red", 0.2), size = 1.5) +
geom_sf(data = clarissa, color = alpha("darkgreen", 0.75), fill = alpha("darkgreen", 0.1), inherit.aes = FALSE, size = 1.5) +
geom_sf_text(aes(label = label),
data = quadras_intersects %>%
rename(label = QD_ATUAL) %>%
mutate(area = st_area(geometry), geometry = centroid, txt = st_as_text(geometry)) %>%
select(label, geometry, txt, area) %>%
filter(!str_detect(txt, "EMPTY"), as.numeric(area) > 4000),
size = 3, inherit.aes = FALSE) +
xlab("Longitude")+ ylab("Latitude")+
annotation_north_arrow(location = "tr", which_north = "true", height = unit(1, 'cm'), width = unit(1, 'cm')) +
annotation_scale(location = "tl", pad_x = unit(.5, 'cm'), pad_y = unit(.5, 'cm'), bar_cols = c("white", "black"))## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data
get_googlemap(center = c(st_coordinates(clarissa.center)),
zoom = 16,
maptype = "satellite") %>%
ggmap() +
geom_sf(data = quadras_intersects, inherit.aes = FALSE, fill = alpha("white", 0)) +
geom_sf(data = circle_500m, inherit.aes = FALSE, color = alpha("red", 0.5), fill = alpha("red", 0.2), size = 1.5) +
geom_sf(data = clarissa, color = alpha("darkgreen", 0.75), fill = alpha("darkgreen", 0.1), inherit.aes = FALSE, size = 1.5) +
geom_sf_text(aes(label = label),
data = quadras_intersects %>%
rename(label = QD_ATUAL) %>%
mutate(area = st_area(geometry), geometry = centroid, txt = st_as_text(geometry)) %>%
select(label, geometry, txt, area) %>%
filter(!str_detect(txt, "EMPTY"), as.numeric(area) > 4000),
size = 3, inherit.aes = FALSE) +
xlab("Longitude")+ ylab("Latitude")+
annotation_north_arrow(location = "tr", which_north = "true", height = unit(1, 'cm'), width = unit(1, 'cm')) +
annotation_scale(location = "tl", pad_x = unit(.5, 'cm'), pad_y = unit(.5, 'cm'), bar_cols = c("white", "black"))## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data
get_googlemap(center = c(st_coordinates(clarissa.center)),
zoom = 16,
maptype = "hybrid") %>%
ggmap() +
geom_sf(data = quadras_intersects, inherit.aes = FALSE, fill = alpha("white", 0)) +
geom_sf(data = circle_500m, inherit.aes = FALSE, color = alpha("red", 0.5), fill = alpha("red", 0.2), size = 1.5) +
geom_sf(data = clarissa, color = alpha("darkgreen", 0.75), fill = alpha("darkgreen", 0.1), inherit.aes = FALSE, size = 1.5) +
geom_sf_text(aes(label = label),
data = quadras_intersects %>%
rename(label = QD_ATUAL) %>%
mutate(area = st_area(geometry), geometry = centroid, txt = st_as_text(geometry)) %>%
select(label, geometry, txt, area) %>%
filter(!str_detect(txt, "EMPTY"), as.numeric(area) > 4000),
size = 3, inherit.aes = FALSE) +
xlab("Longitude")+ ylab("Latitude")+
annotation_north_arrow(location = "tr", which_north = "true", height = unit(1, 'cm'), width = unit(1, 'cm')) +
annotation_scale(location = "tl", pad_x = unit(.5, 'cm'), pad_y = unit(.5, 'cm'), bar_cols = c("white", "black"))## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data
content <- paste(sep = "<br/>",
"<b style='color:darkgreen'>Hospital Veterinário</b>",
"Endereço...."
)
leaflet() %>%
addTiles() %>%
addPolygons(data = quadras_crop, fillOpacity = .2, color = "blue", weight = 2) %>%
addPolygons(data = lote39, fillColor = "red", color = "red", weight = 2) %>%
addPolygons(data = clarissa, color = "green", fillColor = "green", weight = 2) %>%
addPopups(st_coordinates(clarissa.center)[1,"X"], st_coordinates(clarissa.center)[1,"Y"], content,
options = popupOptions(closeButton = FALSE, keepInView = TRUE)) %>%
addPolygons(data = circle_500m, color = "black", fillColor = "white", fillOpacity = 0, weight = 2) %>%
addScaleBar(position = "bottomleft") %>%
addControl(html = '<img src="https://image.flaticon.com/icons/svg/731/731590.svg" alt="Direction free icon" title="North Direction" width="64" height="64">',
position = "bottomright", className = "")leaflet() %>%
addPolygons(data = quadras_crop, fillOpacity = 0, color = "blue", weight = 2) %>%
addPolygons(data = lote39, fillColor = "red", color = "red", weight = 2) %>%
addPolygons(data = clarissa, color = "green", fillColor = "green", weight = 2) %>%
addPopups(st_coordinates(clarissa.center)[1,"X"], st_coordinates(clarissa.center)[1,"Y"], content,
options = popupOptions(closeButton = FALSE, keepInView = TRUE)) %>%
addPolygons(data = circle_500m, color = "black", fillColor = "white", fillOpacity = 0, weight = 2) %>%
addScaleBar(position = "bottomleft") %>%
addControl(html = '<img src="https://image.flaticon.com/icons/svg/731/731590.svg" alt="Direction free icon" title="North Direction" width="64" height="64">',
position = "bottomright", className = "") %>%
addBingTiles(apikey = 'AksJv5jrxIbI0Kg6lwLHinlM9v13WgaEyaFzH15mv_XO_Cb1i6euO5srgp5gpzF0',
imagerySet = c("Aerial", "AerialWithLabels", "CanvasDark", "CanvasLight",
"CanvasGray", "Road")[6]) leaflet() %>%
addPolygons(data = quadras_crop, fillOpacity = .2, color = "blue", weight = 2) %>%
addPolygons(data = lote39, fillColor = "red", color = "red", weight = 2) %>%
addPolygons(data = clarissa, color = "green", fillColor = "green", weight = 2) %>%
addPopups(st_coordinates(clarissa.center)[1,"X"], st_coordinates(clarissa.center)[1,"Y"], content,
options = popupOptions(closeButton = FALSE, keepInView = TRUE)) %>%
addPolygons(data = circle_500m, color = "black", fillColor = "white", fillOpacity = 0, weight = 2) %>%
addScaleBar(position = "bottomleft") %>%
addControl(html = '<img src="https://image.flaticon.com/icons/svg/731/731590.svg" alt="Direction free icon" title="North Direction" width="64" height="64">',
position = "bottomright", className = "") %>%
addBingTiles(apikey = 'AksJv5jrxIbI0Kg6lwLHinlM9v13WgaEyaFzH15mv_XO_Cb1i6euO5srgp5gpzF0',
imagerySet = c("Aerial", "AerialWithLabels", "CanvasDark", "CanvasLight",
"CanvasGray", "Road")[1]) leaflet() %>%
addPolygons(data = quadras_crop, fillOpacity = .2, color = "blue", weight = 2) %>%
addPolygons(data = lote39, fillColor = "red", color = "red", weight = 2) %>%
addPolygons(data = clarissa, color = "green", fillColor = "green", weight = 2) %>%
addPopups(st_coordinates(clarissa.center)[1,"X"], st_coordinates(clarissa.center)[1,"Y"], content,
options = popupOptions(closeButton = FALSE, keepInView = TRUE)) %>%
addPolygons(data = circle_500m, color = "black", fillColor = "white", fillOpacity = 0, weight = 2) %>%
addScaleBar(position = "bottomleft") %>%
addControl(html = '<img src="https://image.flaticon.com/icons/svg/731/731590.svg" alt="Direction free icon" title="North Direction" width="64" height="64">',
position = "bottomright", className = "") %>%
addBingTiles(apikey = 'AksJv5jrxIbI0Kg6lwLHinlM9v13WgaEyaFzH15mv_XO_Cb1i6euO5srgp5gpzF0',
imagerySet = c("Aerial", "AerialWithLabels", "CanvasDark", "CanvasLight",
"CanvasGray", "Road")[2])leaflet() %>%
addPolygons(data = quadras_crop, fillOpacity = .2, color = "blue", weight = 2) %>%
addPolygons(data = lote39, fillColor = "red", color = "red", weight = 2) %>%
addPolygons(data = clarissa, color = "green", fillColor = "green", weight = 2) %>%
addPopups(st_coordinates(clarissa.center)[1,"X"], st_coordinates(clarissa.center)[1,"Y"], content,
options = popupOptions(closeButton = FALSE, keepInView = TRUE)) %>%
addPolygons(data = circle_500m, color = "black", fillColor = "white", fillOpacity = 0, weight = 2) %>%
addScaleBar(position = "bottomleft") %>%
addControl(html = '<img src="https://image.flaticon.com/icons/svg/731/731590.svg" alt="Direction free icon" title="North Direction" width="64" height="64">',
position = "bottomright", className = "") %>%
addBingTiles(apikey = 'AksJv5jrxIbI0Kg6lwLHinlM9v13WgaEyaFzH15mv_XO_Cb1i6euO5srgp5gpzF0',
imagerySet = c("Aerial", "AerialWithLabels", "CanvasDark", "CanvasLight",
"CanvasGray", "Road")[5]) Please visit the development page of the prettydoc package for latest updates and news. Comments, bug reports and pull requests are always welcome.