When computing an iso-elevation line in a digital elevation model (DEM) with my_line = terra::as.contour(dem, levels=single_elev)
, I noticed that the accuracy of the result, i.e. the level of details of the linestring it generates depends on the size of dem
. With a large dem
, typically a 4000x6000 pixels SRTM image, my_line
only has very coarse features.
The same command on a small portion of the same image
cropped_dem = terra::crop(dem, my_small_polygon)
my_detailed_line = terra::as.contour(cropped_dem, levels=single_elev)
yields a linestring with much finer details.
Is it possible to alter this behavior of terra::as.contour()
so as to generate a fine-detailed contour line on a large raster ?
?terra::as.contours
, you can increase maxcells =, which by default is set to 100,000, hence 'course' in context of 2.4te+07 cells to higher value depending on how much memory you can devote.