D.J
D.J

Reputation: 1339

Supress rgdal warnings in R

i have some working code that, all of a sudden, shows a lot of warning messages (which it didn't do before). they do not hinder the execution of the code but are very annoying. i have around 2000 tif's i want to convert to rasters. to do so i load them into a list like so:

tif_list<-list.files(pattern = "*.tif$")
tif_list<-lapply(tif_list, raster) 

the first thing i tried was the rgdal suggestion of

options("rgdal_show_exportToProj4_warnings"="none") # using it before loading the library as rgdal suggests
library(rgdal)

this didn't work so next i've tried global disabeling of warnings with options(warn=-1) this also didn't help.

next i tired suppressWarnings(lapply(tif_list, raster)) but again no luck. in a bit of desperation i tried to set all rgdal warnings to false:

set_thin_PROJ6_warnings(FALSE)
set_rgdal_show_exportToProj4_warnings(FALSE)

which of course did not do anything.

i also tried to do set warnings invisible

invisible(capture.output(lapply(tif_list, raster))) # although just not outputting them would be better 

this also didn't do anything and i am running out of ideas.

on a quick side note, 2 things. when i subset the list to less than 4-5 tifs to be converted the warnings don't show. also up to 40 tifs the warnings only show up every 2nd time i run the code.

the warnings look like this:

proj_create_from_database: datum not found
proj_create_from_database: ellipsoid not found
proj_create_from_database: prime meridian not found
proj_create_from_database: datum not found
proj_create_from_database: ellipsoid not found
proj_create_from_database: prime meridian not found
proj_create_from_database: datum not found
proj_create_from_database: ellipsoid not found
proj_create_from_database: prime meridian not found
proj_create_from_database: datum not found
proj_create_from_database: ellipsoid not found
proj_create_from_database: prime meridian not found
proj_create_from_database: datum not found
proj_create_from_database: ellipsoid not found
proj_create_from_database: prime meridian not found
proj_create_from_database: datum not found
proj_create_from_database: ellipsoid not found
proj_create_from_database: prime meridian not found

ps:

i also updated to the last rgdal version 1.5-16

Upvotes: 3

Views: 619

Answers (1)

quantoid6969
quantoid6969

Reputation: 37

This is a temporary solution but uninstall/reinstalling rgdal does the trick.

There must be a ceiling on the number of times you can run whatever command produces the warning before it turns into an error, maybe it's on their GitHub page.

Upvotes: 1

Related Questions