I used R to make density surface models of whales in GGPLOT. However, l can not work out how to get the model into a raster so i can use it in QGIS. I have been trying as below but the squares of the model become stretched and it is not in the right place on the coastline.
#remove the back ground final <- p + theme(legend.position = "none", panel.grid = element_blank(), axis.title = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), panel.background = element_blank()) #make raster ggsave(plot=final, "XY.tiff", device = "tiff") raster <- stack("XY.tiff") lat_long <- ggplot_build(p)$layout$panel_params[][c("x.range","y.range")] extent(raster) <- c(lat_long$x.range,lat_long$y.range) crs(raster) <-"+proj=utm +zone=13 +datum=WGS84" writeRaster(raster,"abundance.tif", overwrite=TRUE)
When i change the position "x.range" and "y.range" in the extent line, the model is the right shape but the lat lon has been reversed and the model is no where near Mexico anymore.
Does anyone have any idea how to get this map out of R and into QGIS?
l did not use a stack but instead used a prediction grid in the format of CSV file.