I have csv data that extend beyond the area I want for an existing map. I want 
using the boundaries of the polygon shape file as a cookie cutter so that I can 
overlay the csv data on map without including anything outside the map 
boundaries and create a dbf file or shapefile of the clipped data .  The 
reproducible example:
###############################################
library(RColorBrewer)
library(RColorBrewer)
library(sp)
require(foreign)
require(latticeExtra)
reguire(lattice)
#Example data
lat <- seq(-12, -1, 0.1)
lon <- seq(28, 45, 0.1)
data <- expand.grid(lat=lat, lon=lon)
n <- nrow(data)
data$X <- runif(n, 0, 250)
#Read map boundaries
TZA_adm2 <- url("http://gadm.org/data/rda/TZA_adm2.RData";)
print(load(TZA_adm2))
close(TZA_adm2)
col = rainbow(length(levels(gadm$NAME_2)))
spplot(gadm, "NAME_2", col.regions=col, auto.key = FALSE, main="TZA Regions")
#How do I clipp or overaly X in data on TZA_adm2 polygon?
#Also how to remove the legent or putting the names in the map. auto.key=FALSE 
does not work.

 

Peter Maclean
Department of Economics
UDSM
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to