Skip to content

dbWriteTable() command (package RPostgreSQL) does not accept append=TRUE statement

1 message · Cornelius Senf

#
Hey everyone!

I try to convert severall raster files into a dataframe and then store 
them in a postegresql database using the RPostgreSQL package (see code 
example below). The for loop below should ideally attach each rasters 
dataframe to the existing table "modis" created with the first raster 
(therefore append=TRUE). However, if the program has finished, only the 
first raster has been stored. Any ideas why this does not work?

Code:

for (i in tar){
     raster<-raster(i)
     data<-as.data.frame(raster)
     dbWriteTable(con,"modis",data,append=TRUE)
}

Where: "tar" is a list of raster files, "con" a database connection file 
and "modis" the database table to be created.

Thanks!

Cornelius