A. Poulton
A. Poulton

Reputation: 45

Error using fortify function on rasters in R

After updating several of my packages yesterday, the fortify function no longer works on rasters for me. The following error is produced when I attempt to fortify a raster:

Error: data must be a data frame, or other object coercible by fortify(), not an S4 object with class RasterLayer Trying to fortify a raster brick/stack produces similar errors.

Anyone else having the same issue? Thanks!

Upvotes: 1

Views: 900

Answers (1)

Heidi Rodenhizer
Heidi Rodenhizer

Reputation: 119

I'd like to comment rather than posting an answer, because I am not sure that what worked to solve a similar issue for me will work for you, but the lacking reputation points to comment, this will have to do...

As far as I can tell, fortify within ggplot2 does not support raster input, but the package RStoolbox allows you to use fortify on raster data. If you haven't figured this issue out yet, try loading RStoolbox and see if it works.

Upvotes: 1

Related Questions