2

I have some code here that reprojects raster files. However, once in a while, I get these errors and I am not sure how to interpret the error messages.

Here is my code:

library(rgdal)
library(raster)

##PROJECT RASTER 
# Create RasterLayer object
r <- stack('Fil1_0.tif')
# Define the Proj.4 spatial reference 
# http://spatialreference.org/ref/epsg/26915/proj4/
sr <- "+proj=utm +zone=31 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" 

# Project Raster
projected_raster <- projectRaster(r, crs = sr)

And here is the error message I get:

Error in projectExtent(from, projto) : cannot do this transformation
In addition: Warning message:
In rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[,  :
  25028 projected point(s) not finite

This is a single band raster so I don't understand how there can be a problem with the extent.

4
  • 1
    It doesn't like the extent of the input data. Perhaps you were trying to project a worldwide raster to UTM zone 31N?
    – mkennedy
    Dec 22, 2016 at 21:09
  • 2
    The extent is the spatial extent in coordinate system units - whether its a single band or 26 bands doesn't make any difference. Are you sure the extent and CRS of the failing rasters is correct and appropriate for transforming to UTM 31? We can't reproduce this without your data.
    – Spacedman
    Dec 23, 2016 at 14:21
  • Hey guys- thanks for your input. I confirmed that it is something unique with this particular dataset- which seems to have issues. Thanks for your help however
    – Alexander
    Dec 23, 2016 at 15:02
  • Have you searched our site? This question has been asked six times before, so likely you can find useful information among their answers.
    – whuber
    Dec 23, 2016 at 23:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.