knitr::opts_chunk$set(echo = FALSE, fig.align = "center", out.width = "75%", warning = FALSE, message = FALSE) knitr::knit_hooks$set(mysize = function(before, options, envir) { if (before) return(options$size) }) library(sf) library(leaflet) library(leafem) library(lwgeom) library(raster) library(knitr) library(kableExtra) library(appraiseR) library(units) install_symbolic_unit(name = "Reais", warn = TRUE, dimensionless = TRUE) library(geosphere) library(GeoNUDEPU)
# 1. Digitação das Coordenadas # # E N coords <- matrix(data = c(733314.8343, 6925664.5164, # VT-01 733309.8336, 6925642.9108, # VT-02 733306.6148, 6925619.5272, # VT-03 733306.3085, 6925608.1096, # VT-04 733306.3775, 6925595.2041, # VT-05 733306.6345, 6925582.8906, # VT-06 733307.1473, 6925571.2114, # VT-07 733348.1286, 6925551.4944, # VT-08 733351.9514, 6925547.3030, # VT-09 733427.3666, 6925508.8163, # VT-10 733428.0364, 6925510.1773, # VT-11 733429.2674, 6925509.7568, # VT-12 733430.9938, 6925508.2240, # VT-13 733432.4604, 6925506.3071, # VT-14 733457.5095, 6925494.7292, # VT-15 733463.9436, 6925561.4700, # VT-16 733465.1922, 6925582.9527, # VT-17 733467.3729, 6925594.7859, # VT-18 733439.9858, 6925607.6677, # VT-19 733314.8343, 6925664.5164),# VT-01 ncol = 2, byrow = TRUE) # # # 2. Criação da feição # # Atentar para a definição do crs apropriado # # # Exemplos: # WGS 84 = 4326 # SAD 69 22S = 29192 # SIRGAS 2000 22S = 31982 # #pl1 <- st_sf(geom = st_sfc(st_polygon(list(area1)))) #pl2 <- st_sf(geom = st_sfc(st_polygon(list(area2)))) #spl <- st_sfc(geom = st_combine(rbind(pl1, pl2)), crs = 29192) spl <- st_sfc(geom = st_polygon(list(coords)), crs = 31982) # # 2. Leitura Polígonos da União para separar área de marinha de área alodial # data("polUniao") # # Transformar camada de polígonos da União para mesmo CRS dos dados em análise # polUniao <- st_transform(polUniao, 31982) # # # 3. Criação dos metadados # attr <- data.frame( destinacao = "cessao", tipo = "aquatica", rip = NA, interessado = "Prefeitura Municipal de Palhoça", area = st_area(spl), area_uniao = st_area(st_intersection(spl, st_geometry(polUniao))), inicio = NA, prazo = NA, vigencia = NA, cnpj = " 82.892.316/0001-08", nup = "10154.143536/2019-37", protocolo = "SC04008/2019", ref = 5010861, concedida = FALSE, municipio = 8185, logradouro = NA, trecho = NA, aval = NA, dataaval = NA, refaval = NA, onerosa = FALSE, geometriaAproximada = FALSE) # # 4. União dos atributos à geometria # # spl_df <- st_sf(attr, geometry = spl) %>% st_transform(crs = 4326) # Transforma para WGS84.
# Leitura de dados da SPU-SC-NUDEM polUniao <- polUniao %>% st_transform(4326) data("lpmHomologada") data("lpmDermarcada") data("lpmPresumida") data("lltmHomologada") data("lltmDemarcada") data("lltmPresumida") # # Leitura de dados das camadas existentes ocupacoes <- st_read("https://raw.githubusercontent.com/geoSPU/SPU-SC-NUPRIV/master/ocupacoes.geojson") autobras <- st_read("https://github.com/geoSPU/SPUData/raw/master/autobras.geojson") cessoes <- st_read("https://raw.githubusercontent.com/geoSPU/SPUData/master/cessoes.geojson") entregas <- st_read("https://raw.githubusercontent.com/geoSPU/SPUData/master/entregas.geojson") certdisp <- st_read("https://github.com/geoSPU/SPUData/raw/master/certdisp.geojson") ranchos <- st_read("https://raw.githubusercontent.com/geoSPU/SPUData/master/ranchos_de_pesca.geojson") aeroportos <- st_read("https://github.com/geoSPU/SPUData/raw/master/aeroportos.geojson") portos <- st_read("https://github.com/Cadastro-Marinho/BrasilData/raw/master/portos.geojson")
ext <- extent(spl_df) m <- spl_df %>% leaflet() %>% # Adiciona ortofotos do Estado de SC (SIG-SC) como base addWMSTiles(baseUrl = "http://sigsc.sc.gov.br/sigserver/SIGSC/wms", layers = list("OrtoRGB-Landsat-2012")) %>% # Adiciona como camada de base Fotos de satélite da ESRI # addProviderTiles(providers$Esri.WorldImagery) %>% # Adiciona o(s) polígono(s) em análise addPolygons(stroke = TRUE, weight = 2, color = "blue", group = "Em análise") %>% # Adiciona outras camadas existentes # addPolygons(data = cessoes, color = "red") %>% # addPolygons(data = certdisp, color = "white", fillColor = "blue", # dashArray = "10 10") %>% # addPolygons(data = autobras, color = "white", fillColor = "grey", # dashArray = "10 10") %>% # addPolygons(data = entregas, color = "white", fillColor = "white", # dashArray = "10 10") %>% # Adiciona polígonos da União addPolygons(data = polUniao, color = "yellow", group = "Terras de Marinha") %>% # Adiciona Linhas de Marinha addPolylines(data = lltmHomologada, color = "red") %>% addPolylines(data = lpmHomologada, color = "blue") %>% # addPolylines(data = lltmDemarcada, color = "red", dashArray = "10 10") %>% # addPolylines(data = lpmDemarcada, color = "blue", dashArray = "10 10") %>% # addPolylines(data = lltmPresumida, color = "red", dashArray = "10 10", # opacity = .2, weight = 3) %>% # addPolylines(data = lpmPresumida, color = "blue", dashArray = "10 10", # opacity = .2, weight = 3) %>% # Zoom no imóvel em análise fitBounds(lng1 = ext[1], lat1 = ext[3], lng2 = ext[2], lat2 = ext[4]) %>% # Adiciona Legendas addLegend(labels = "Terras de Marinha", colors = "blue", group = "Terras de Marinha", position = "topright") %>% addLegend(labels = "Em análise", colors = "red", group = "Em análise", position = "topright") %>% # Adiciona Minimapa addMiniMap(position = "topleft", tiles = providers$Esri.WorldGrayCanvas) %>% addMouseCoordinates() %>% addLogo("SPU.jpg", src = "local", position = "bottomleft", offset.x = 15, offset.y = 15, width = 75, height = 75) name <- paste(st_geohash(spl_df, 10), ".png", sep = "") mapview::mapshot(m, file = name, remove_url = FALSE) knitr::include_graphics(name)
spl_df_Uniao <- st_intersection(spl_df, polUniao) spl_df_Uniao$area <- st_area(spl_df_Uniao) spl_df_Uniao$perimetro <- st_length(spl_df_Uniao)
ext <- extent(spl_df_Uniao) m <- spl_df_Uniao %>% leaflet() %>% # Adiciona ortofotos do Estado de SC (SIG-SC) como base addWMSTiles(baseUrl = "http://sigsc.sc.gov.br/sigserver/SIGSC/wms", layers = list("OrtoRGB-Landsat-2012")) %>% # Adiciona como camada de base Fotos de satélite da ESRI # addProviderTiles(providers$Esri.WorldImagery) %>% # Adiciona o(s) polígono(s) em análise addPolygons(stroke = TRUE, weight = 2, color = "blue", group = "Em análise") %>% # Adiciona outras camadas existentes # addPolygons(data = cessoes, color = "red") %>% # addPolygons(data = certdisp, color = "white", fillColor = "blue", # dashArray = "10 10") %>% # addPolygons(data = autobras, color = "white", fillColor = "grey", # dashArray = "10 10") %>% # addPolygons(data = entregas, color = "white", fillColor = "white", # dashArray = "10 10") %>% # Adiciona polígonos da União addPolygons(data = polUniao, color = "yellow", group = "Terras de Marinha") %>% # Adiciona Linhas de Marinha addPolylines(data = lltmHomologada, color = "red") %>% addPolylines(data = lpmHomologada, color = "blue") %>% # addPolylines(data = lltmDemarcada, color = "red", dashArray = "10 10") %>% # addPolylines(data = lpmDemarcada, color = "blue", dashArray = "10 10") %>% # addPolylines(data = lltmPresumida, color = "red", dashArray = "10 10", # opacity = .2, weight = 3) %>% # addPolylines(data = lpmPresumida, color = "blue", dashArray = "10 10", # opacity = .2, weight = 3) %>% # Zoom no imóvel em análise fitBounds(lng1 = ext[1], lat1 = ext[3], lng2 = ext[2], lat2 = ext[4]) %>% # Adiciona Legendas addLegend(labels = "Terras de Marinha", colors = "blue", group = "Terras de Marinha", position = "topright") %>% addLegend(labels = "Em análise", colors = "red", group = "Em análise", position = "topright") %>% # Adiciona Minimapa addMiniMap(position = "topleft", tiles = providers$Esri.WorldGrayCanvas) %>% addMouseCoordinates() %>% addLogo("SPU.jpg", src = "local", position = "bottomleft", offset.x = 15, offset.y = 15, width = 75, height = 75) name <- paste("Uniao-", st_geohash(spl_df, 10), ".png", sep = "") mapview::mapshot(m, file = name, remove_url = FALSE) knitr::include_graphics(name)
df <- st_coordinates(spl_df_Uniao)[, c(1, 2)] df_SIRGAS <- st_coordinates(st_transform(spl_df_Uniao, crs = 31982))[, c(1, 2)] vertices <- paste("VT", seq_len(dim(df_SIRGAS)[1] - 1), sep = "") row.names(df_SIRGAS) <- make.names(c(vertices, vertices[1]), unique = TRUE) # kable(df, # format.args = list(nsmall = 2), # col.names = c("E", "N")) #df_SIRGAS azimutes <- vector(mode = "numeric", length = dim(df)[1]-1) distances <- vector(mode = "numeric", length = dim(df)[1]-1) # Curso é o azimute de 0 a 360 for (i in seq_len(dim(df)[1])) { if (i != dim(df)[1]){ azimutes[[i]] <- st_geod_azimuth(st_sfc(st_point(df[i, ]), st_point(df[i + 1, ]), crs = 4326)) distances[[i]] <- st_distance(st_point(df_SIRGAS[i, ]), st_point(df_SIRGAS[i + 1, ])) } } azimutes <- set_units(azimutes, rad) azimutes_deg <- set_units(azimutes, degrees) course <- (as.vector(azimutes_deg) + 360) %% 360 conv_merid <- -1.06277192089 planar_course <- course - conv_merid df_SIRGAS <- cbind(df_SIRGAS, AzReal = c(course, NA), AzPlano = c(planar_course, NA), Dist = c(distances, NA)) df_SIRGAS <- as.data.frame(df_SIRGAS) # Para grau, minutos e segundos #sp::dd2dms(as.vector(course[c(7, 8, 1, 2, 3, 4, 5, 6)])) kable(df_SIRGAS, digits = 2, format.args = list(nsmall = 2, decimal.mark = ",", big.mark = "."), col.names = c("E", "N", "Real", "Plano", "(m)"), longtable = TRUE, booktabs = TRUE) %>% add_header_above(c("Vértice", "Coordenadas" = 2, "Azimutes" = 2, "Distância")) %>% kable_styling(font_size = 3)
kable(t(st_drop_geometry(spl_df_Uniao)), col.names = NULL, booktabs = TRUE)%>% kable_styling(font_size = 6)
writeLines("Inicia-se este memorial pelo vertice ", con = 'memorial.md', sep = "") for (i in seq_len(nrow(df_SIRGAS))) { cat("**", rownames(df_SIRGAS)[i], "** com coordenadas **N ", brf(df_SIRGAS[i, 2]), "** e **E ", brf(df_SIRGAS[i, 1]), "**. Deste segue com azimute ", brf(df_SIRGAS[i, 4]), " graus e distancia ", brf(df_SIRGAS[i, 5]), "m ate o vertice ", sep = "", file = 'memorial.md', append = TRUE) }
readLines('memorial.md')
# Escrever no disco em formato geojson st_write(spl_df, "10154.143536.2019-37.geojson", delete_dsn = TRUE) # Escrever em kml #st_write(spl_df, "PMPalhoca.kml", delete_dsn = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.