Dear List, I've calculated a kernel density estimation (splancs function) and now I want to export the result as a kml-file to open it in the google earth viewer, but I get stuck at converting the SpatialGridDataFrame to a SpatialPixelDataFrame...
here (http://www.zshare.net/download/689742375ef5fb/) you can download some testdata and my R-code so far: ########### data.shp <- readOGR("C:/", layer="events") prj <- data.shp@ proj4string@ projargs dat <- data.shp str(dat) poly.shp <- readOGR("C:/", layer="hull") str(poly.shp) dat.SP <- as(dat, "SpatialPoints") str(dat.SP) pp_poi <- as.points([EMAIL PROTECTED],1], [EMAIL PROTECTED],2]) poly <- getPolygonCoordsSlot(getPolygonsPolygonsSlot(getSpPpolygonsSlot(poly.shp)[[1]])[[1]]) polymap(poly) points(pp_poi) grd <- GridTopology(cellcentre.offset=c(590511, 396191), cellsize=c(2000, 2000), cells.dim=c(30,25)) kbw2000 <- spkernel2d(pp_poi, poly, h0=2000, grd) spplot(SpatialGridDataFrame(grd, data=data.frame(kbw2000)), col.regions=terrain.colors(16)) test <- SpatialGridDataFrame(grd, data=data.frame(kbw2000)) proj4string(test) <- CRS(prj) str(test) test1 <- spTransform(test, CRS("+proj=longlat +datum=WGS84")) ## here I got following error message: # validityMethod(as(object, superClass)): Geographical CRS given to non-conformant data test2 <- spsample(test1, type="regular", cellsize=c(2000,2000)) # export the SpatialPixelDataFrame (Code (not testet) from the help-file) tf <- tempfile() SGxx <- GE_SpatialGrid(test2) png(file=paste(tf, ".png", sep=""), width=SGxx$width, height=SGxx$height, bg="transparent") par(mar=c(0,0,0,0), xaxs="i", yaxs="i") plot(x, xlim=SGxx$xlim, ylim=SGxx$ylim, setParUsrBB=TRUE) dev.off() kmlOverlay(SGxx, paste(tf, ".kml", sep=""), paste(tf, ".png", sep="")) ########### I appreciate every hint! Thanks. Marco -- Marco Helbich Institute for Urban and Regional Research Austrian Academy of Sciences Postgasse 7/4/2, A-1010 Vienna, Austria (EU) e-mail: marco.helbich(at)oeaw.ac.at _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo