[R-sig-Geo] Create Kernel image results in *tif format

Florian Betz flobetz @ending from web@de
Thu Sep 27 10:01:27 CEST 2018


Dear Alexandre,

instead of converting the image to a SpatialPixelDataFrame converting to 
a raster object might be an alternative.

r_pines<-raster(d_pines)
writeRaster(r_pines, "Pines.tif")

Regards,
Florian

Am 26.09.2018 um 22:25 schrieb ASANTOS via R-sig-Geo:
> Dear R-sig-geo Members,
>
>       I've like to create Kernel image results as *tif using an object of
> density() function output in spatstat package. But in my example,
> doesn't work when I try:
>
> #Packages
> library(spatstat)
> library(raster)
> library(rgdal)
>
>
> #Swedishpines's data set in spatstat package
> data(swedishpines)
> plot(swedishpines)
>
> #CSR with K-Ripley test
> csr_pines <- envelope(swedishpines, Kest, nsim=99)
> plot(csr_pines)
> # r=0.75 is outside CSR
>
> #Kernel representation using 0.75 as bandwidth
> d_pines<-density(swedishpines, bw=0.75)
> plot(d_pines)
>
> #Create TIFF image
> r_pines <- as(d_pines, "SpatialPixelsDataFrame")
> writeGDAL(r_pines, "Pines.tif")
> #
>
>> r_pines <- as(d_pines, "SpatialPixelsDataFrame") Error in as(d_pines,
> "SpatialPixelsDataFrame") : no method or default for coercing “im” to
> “SpatialPixelsDataFrame”
>
> Please any ideas for corrected this?
>
> Thanks in advanced,
>
> Alexandre
>

-- 
Florian Betz
Gartenstraße 13
86152 Augsburg, Deutschland

Tel.: 0176 20344096
Mail: flobetz using web.de



More information about the R-sig-Geo mailing list