Created
March 30, 2015 07:33
-
-
Save oscarperpinan/504ce14e320d21e1644c to your computer and use it in GitHub Desktop.
Respuesta a comentario en blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(sp) | |
## Grabar tabla excel en formato CSV usando ; como separador | |
## Leemos saltando dos primeras líneas | |
pts <- read.csv2('/tmp/listado-longitud-latitud-municipios-espana.csv', skip = 2) | |
## Transformamos a SPDF usando columnas de longitud-latitud como coordenadas | |
munPts <- SpatialPointsDataFrame(pts[, c(5, 4)], pts[,-c(4, 5)], | |
proj4string = CRS('+proj=longlat +datum=WGS84')) | |
## Pintamos el resultado para comprobar | |
spplot(munPts["Altitud"]) | |
## Ahora se puede añadir a otra capa "trellis" existente | |
p + layer(sp.points(munPts)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Comentario