[R-sig-Geo] clip a SpatialPolygonsDataFrame

Laetitia Blanc blanc.laetitia.esr34 at gmail.com
Fri Aug 6 11:35:39 CEST 2010

Can the KDE be run with the correct coordinates in the specified 
projection on the input data, so that thw window matches the outlines? Can 
you re-write the code making res to generate a SpatialGridDataFrame? The 
input points must have a projection. Without a shared projection (CRS, 
coordinate reference system) this is not possible.


>I have taken into account your advice.
>I have loaded my input data with the correct CRS (lambert II) in order to
match with the map :

d <- read.csv('total.csv', header = TRUE) #, sep = ",", quote="\"",
dec=".",fill = TRUE, comment.char="", ...)

d <- d[-(1:10),]

d2 <- data.frame (d)
spd2 <- d2

#transformation into SpatialPointDataFrame
coordinates ( spd2 ) <- ~ x + y
proj4string ( spd2 ) <- CRS("+init=epsg:27572")

>Then, i have realised my KDE :


res <- array(0,c(20,20,length(unique(spd2$an)))) # créer 30
(length(unique(d$an))) tableaux de 20x20.
for (i in 1:length(unique(spd2$an))) { 
spd3 <- subset(spd2,spd2$an == 1979+i) # résumé en conservant que 1973+i où
i=30 donc en gardant que 2009
lynxkde<-stkde(xlong=spd3$x, ylat=spd3$y, ztime=spd3$an,
res[,,i] <- lynxkde$dens

>At that moment, the window where the KDE is running has te correct unit
(meters) (xrange : >from 823 000 to 981 000 ; yrange : from 2 079 500 to 2
305 500)

>But then, when i create my animation, the window has the x and y ranges :
0:1. I think the >probleme comes from my animation. Moreover, when i try to
insert my map in my animation, i still >have an alternation between the map
and the kernel >rather than the kernel ON the map (like
>overlay/superposition...) :


# create a HTML page from my animation :
pres.ani <- function() 
for (i in 1:length(unique(spd2$an))) { 

ani.start(interval=.5,title = "movie presence lynx", outdir = getwd()) 


>I think i must solve the problem by changing my animation but i don't know
how. Do you have an >idea ? Do you think that it can be because i have
spatial objects ?
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/clip-a-SpatialPolygonsDataFrame-tp5376909p5379892.html
Sent from the R-sig-geo mailing list archive at Nabble.com.

More information about the R-sig-Geo mailing list