Search code examples
rtiffrgdal

Read TIF file error "Geographical CRS given to non-conformant data"


I'm trying to read in a TIF file as follows:

d = readGDAL('F182013.v4c.stable_lights.avg_vis.tif')
Error in validityMethod(as(object, superClass)) : 
  Geographical CRS given to non-conformant data: -180.004166667

The file is night light data from US National Oceanic and Atmospheric Administration, so it should be a valid file. Maybe the problem relates to a numerical floating point issue.

Grateful for any advice how to workaround.


Solution

  • readGDAL calls the error-checking function validityMethod, which checks that the longitude is within +/- 180 degrees for WGS84. Non-fatal errors and messages can be suppressed with:

    d = readGDAL('F182013.v4c.stable_lights.avg_vis.tif', silent = TRUE)
    

    so that the file can at least be read in as a SpatialGridDataFrame. The corresponding geographic range of the object is still beyond +/-180 deg, but the error may be within the tolerance you're willing to accept.

    bbox(d)
             min       max
    x -180.00417 180.00417
    y  -65.00417  75.00417