AgrDataSci / gdistance

Calculate distances and routes on geographic grids.
https://agrdatasci.github.io/gdistance/
15 stars 6 forks source link

Mosaic TransitionLayers? #7

Closed pairsa closed 1 year ago

pairsa commented 3 years ago

Hello! I am attempting to produce a transition layer from a very large raster, and am (expectedly) running into memory issues in R. Is there a work-around for using the "transition" function on large raster layers? My instinct is to tile the raster, produce smaller transition layers from these tiles, then mosaic them together somehow. Is there a way mosaic objects of class "TransitionLayer" in R?

kauedesousa commented 3 years ago

Hi @pairsa

There was an on-going (a bit in stand by) discussion about the computational costs of computing the transitions. This is because gdistance depends a lot on the packages raster and Matrix. We think that with the new package terra and with data.table we could solve or reduce the computational cost. But this will take some time to implement. Meanwhile, I quote a text send by Andy Nelson (UTwente) as his work around to produce the data for this publication https://doi.org/10.1038/s41597-019-0265-5

"I did not mosaic transition matrices, I mosaiced the resulting travel time surfaces. I cut up my study area (the world) into overlapping tiles, generating matrices for each one, ran the cost distance function on each one, and merged the outputs of that to get a global map"

I hope this can offer to you a solution in the short run, while we study the opportunities to implement a faster gdistance

K

andrewmarx commented 1 year ago

I will be rewriting the transition() and geoCorrection() functions to be substantially more memory efficient. I'm going to go ahead and close this for now, and in the future, it can be revisited if the plan advancements fail to meet people's needs.