[GIS] faster – a matrix, raster or a dataframe

data-framerraster

I have rasters over which I am performing mathematical operations. For example, where I need to calculate flow distance or distance between two grid points.

What format is generally considered faster for such operations?

Should I work directly on the raster format, instead?

I also converted the data to matrix and dataframe

as.matrix and as.data.frame

The raster has entirely numeric values.
Not sure which is faster. I am new to raster package in R, and I have mostly only worked in dataframes.

Best Answer

"Faster" is relative. Faster to upload? Faster to access and run calculations? Because so many variables exist between systems and data, the best way to get a guaranteed answer for your processes and data is to run it using each of the three formats.

A similar Stack Exchange Answer can be found here: Data frame or matrix?

The answer depends on what you are going to do with the data in data.frame/matrix. If it is going to be passed to other functions then the expected type of the arguments of these functions determine the choice.

Related Question