1

I started out with a shape file of points data. I then converted this format to ppp format to use some spatstat functions.

The code to do this is listed below:

sp_points_df_al <- rgdal::readOGR(dsn = shape_path, layer = "aland_points")
# convert the spatial points data.frame to just plain ol spatial points
sp_points_al <- as(sp_points_df_al, "SpatialPoints")
# now convert the spatial points to ppp 
ppp_al <- as(sp_points_al, "ppp")
# estimate the window from the points data
wind_rr <- spatstat::ripras(ppp_al)
ppp_al_constr <- spatstat::ppp(ppp_al$x, ppp_al$y, window = wind_rr)

I then wanted to do some point-pattern analysis and so used the following spatstat function:

image <- spatstat::density.ppp(ppp_al_constr, sigma = 0.004, dimyx=c(512, 512))

I then display the image using the following:

bias_palette <- colorRampPalette(c("blue", "magenta", "red", "yellow", "white"), bias=2, space="Lab")
spatstat::plot.im(k, col=bias_palette(256), ribbon = FALSE)

What I want to do next is create a Geotiff image from the above. I want to do this as I want to overlay the tiff image on top of some vector data.

My question is:

How do I convert the image above into a Geotiff format...?

markthekoala
  • 1,065
  • 1
  • 11
  • 24
  • Can't test this on your code, but this link might help http://neondataskills.org/R/Image-Raster-Data-In-R/ – wololo Jun 09 '16 at 04:06

1 Answers1

0

The result of spatstat::density.ppp is an object of class im. If you do as.matrix of this object, you get a matrix containing the pixel entries. You can then convert this to any other type of image. Also as.data.frame(Frame(..)) of the image object will retrieve the bounding box.

Or, go to the maptools package, which handles spatstat objects, and look for a function to convert a spatstat class im object to the desired class.

Adrian Baddeley
  • 1,956
  • 1
  • 8
  • 7