setwd("C:/Users/frank/Desktop")
library(readxl)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(rgdal)
## Loading required package: sp
## rgdal: version: 1.5-23, (SVN revision 1121)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.2.1, released 2020/12/29
## Path to GDAL shared files: C:/Users/frank/Documents/R/win-library/4.1/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721]
## Path to PROJ shared files: C:/Users/frank/Documents/R/win-library/4.1/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:1.4-5
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
## Overwritten PROJ_LIB was C:/Users/frank/Documents/R/win-library/4.1/rgdal/proj
library(rgeos)
## rgeos version: 0.5-5, (SVN revision 640)
## GEOS runtime version: 3.8.0-CAPI-1.13.1
## Linking to sp version: 1.4-5
## Polygon checking: TRUE
library(maptools)
## Checking rgeos availability: TRUE
library(ggplot2)
library(sf)
## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
list.files()
## [1] "~$allpa_Tesis2.docx"
## [2] "~$allpaFrank_Tesis PRIMER CAPITULO.docx"
## [3] "~$allpaFrank_Tesis PRIMER CAPITULO_OBSERVACIONES.docx"
## [4] "~WRL0005.tmp"
## [5] "1-Link_Geoportales de Perú.pdf"
## [6] "Capitulo 1"
## [7] "Capitulo 2"
## [8] "codigomapas.R"
## [9] "ComitesUPP.html"
## [10] "ComitesUPP.nb.html"
## [11] "ComitesUPP.Rmd"
## [12] "Diseño Investigación-x"
## [13] "ELECCIONES2006.xlsx"
## [14] "Entregas"
## [15] "Entrevistas"
## [16] "Limite_departamental.rar"
## [17] "Limite_provincial.rar"
## [18] "MapaElecciones2006.nb.html"
## [19] "MapaElecciones2006.Rmd"
## [20] "MapaElecciones2011.nb.html"
## [21] "MapaElecciones2011.Rmd"
## [22] "Provincias2011.xlsx"
## [23] "rsconnect"
## [24] "Seminario 1-x"
## [25] "SEMINARIO 2"
Abrimos el archivo
departamento <- st_read("C:/Users/frank/Desktop/MAPAS/BAS_LIM_DEPARTAMENTO.shp")
## Reading layer `BAS_LIM_DEPARTAMENTO' from data source `C:\Users\frank\Desktop\MAPAS\BAS_LIM_DEPARTAMENTO.shp' using driver `ESRI Shapefile'
## Simple feature collection with 25 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -203260.8 ymin: 7964769 xmax: 1190991 ymax: 9995733
## Projected CRS: WGS 84 / UTM zone 18S
plot(st_geometry(departamento))
Exportation la data
setwd("C:/Users/frank/Desktop")
Comites <- read_excel("ANEXOS.xlsx")
Merge
ComiteMapa <- merge(departamento,Comites, by.x = "NOMBDEP", by.y="Departamento")
Creamos Mapa
Mapa <- ggplot(data = ComiteMapa) +
geom_sf(aes(fill=`Comites` ), data = ComiteMapa, color='black', size=0.3) +
guides(fill=guide_colorbar(title = "Cantidad de Comites")) +
scale_fill_gradient(limits= c(0,13), high = "blue", low = "white", guide = "colorbar") +
ggtitle("Comites UPP")+
theme_bw()+
theme(
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()
)
Mapa