USEPA/elevatr

`get_elev_raster()` leads to R running out of memory and subsequently crashing

Closed this issue · 3 comments

I followed this tutorial as a guideline https://milospopovic.net/crisp-topography-map-with-r/ to visualize raster data for the whole country of Italy. Have to admit my laptop is not the most RAM-heavy. When using get_elev_raster() , during the "Clipping DEM to location" step, R is running out of memory and just crashes. If I chose a smaller country than Italy, such as Luxemburg, everything works fine. Is there a user-friendly way to split up each country, run get_elev_raster() and merge everything back again eventually?

@tifa365 I was able to run the code in that tutorial with out issue. But as you point out it might be a local RAM limit. I have 16gb on the laptop I ran it on.

While there isn't anything built into elevatr that would split up the input polygons, that is something you could do with other packages or perhaps other data (e.g. regions of italy or some other geographic units). That being said, if you wanted to merge those together at the end, you might still have memory issues.

One thing you can try is to alter the z value in get_elev_raster. The z value will impact the resolution of the elevation data. The code in the tutorial is using a z value of 9. Anything smaller than 9 will result in a coarser resolution. For instance, the z of 9 has a DEM that is ~385MB, a z of 8 reduces that to ~95MB, and a z of 7 gets you to ~25 MB. If you are using this for a national scale map, then these smaller z values would still look pretty good, I think.

Hope that helps.

Thanks for the help. Dialing down the z value to 7 helped (seems to be the maximum working resolution for me) and the resulting map still looks great.

Glad to hear it worked out for you! I will go ahead and close this. If you have other issues, feel free to open a new one.