makeNiceTif | R Documentation |
makeNiceTif()
creates a compressed copy of a TIFF with LZW compression,
stats, and internal tiling. It will optionally build overviews and add a VAT.
The output should be ready to view quickly and easily in interactive GIS
software.
makeNiceTif(
source,
destination,
type,
overwrite = FALSE,
buildOverviews = TRUE,
overviewResample = "nearest",
vat = FALSE,
stats = TRUE,
noDataValue
)
source |
(character) path to a raster file readable by GDAL. |
destination |
(character) path to a TIFF file to be created for viewing with GIS software. |
type |
(character) If the |
overwrite |
(logical) if |
buildOverviews |
(logical) if |
overviewResample |
(character) one of |
vat |
(logical) if |
stats |
(logical) if |
noDataValue |
Only used if |
makeNiceTif()
is intended to be called after analysis to prepare result
rasters so they can be viewed easily in GIS software. Because it creates
tiled TIFF files it is not a good idea to run on files in preparation for
analysis with the terra package as it reads by lines, and does not
benefit from overviews.
type
is currently passed to gdal_translate
which will reset the
type to the desired value but will NOT update no data values of cells.
One of two things will happen. If the existing no data value is within the
values supported by the output type they will retain that value. Otherwise
they will be assigned the closest supported value in the output type.
Thus changing type may still work out if you (1) are not converting between
signed and unsigned types and (2) are moving to a smaller bit depth.
makeNiceTif
will attempt to select a new no data value that works out.
For example moving from an Int32 to and Int16 will probably work if the
initial NA value is high because it will will be truncated to the highest
value in the Int16 and which is what the new no data value will be set to.
The default noDataValue
of the output when using type
and not
specifying the noDataValue
is determined by assessType.
If you use type
and your output raster ends up with values cells that were
originally no data you might be able to remedy this by setting
noDataValue
to that value.
If you want to change the type you can do so safely in a call to
warpToReference()
prior to using this function as gdalwarp can reset
the type and reset the values of the NA cell to the new noDataValue
.
This is a wrapper to the gdaltranslate
command line utility coupled with
addOverviews()
and addVat()
. For finer control over
translation see gdalUtilities::gdal_translate()
.
If you intend to create a color table for a categorical raster first call
addColorTable()
and then pass the .vrt
file it creates to this function.
This function creates a copy of the source raster at the destination path that is formatted to facilitate viewing in GIS software. It does not return anything.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.