[R] HELP DATA CLIPPING AND DATA OVERLAY ON A MAP

MacQueen, Don macqueen1 at llnl.gov
Thu Nov 17 02:15:42 CET 2011


I would suggest starting by taking a look at the overlay() function in the
sp package.

(also suggest follow up questions to to R-sig-geo)

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 11/16/11 11:30 AM, "Peter Maclean" <pmaclean2011 at yahoo.com> wrote:

>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]]
>



More information about the R-help mailing list