This function supports both geographic and non-geographic tile generation.
When file
is a simple image file such as png
, tile()
generates
non-geographic, simple CRS tiles. Files that can be loaded by the raster
package yield geographic tiles as long as file
has projection information.
If the raster object's Proj4 string is NA
, it falls back on non-geographic
tile generation and a warning is thrown.
Choice of appropriate zoom levels for non-geographic image files may depend
on the size of the image. A zoom
value may be partially ignored for image
files under certain conditions. For instance using the example map.png
below, when passing strictly zoom = n
where n
is less than 3, this still
generates tiles for zoom n
up through 3.
Supported file types
Supported simple CRS/non-geographic image file types include png
, jpg
and
bmp
. For projected map data, supported file types include three types
readable by the raster
package: grd
, tif
, and nc
(requires ncdf4
).
Other currently unsupported file types passed to file
throw an error.
Tiles and Leaflet
gdal2tiles
generates TMS tiles. If expecting XYZ, for example when using
with Leaflet, you can change the end of the URL to your hosted tiles from
{z}/{x}/{y}.png
to {z}/{x}/{-y}.png
.
This function is supported by two different versions of gdal2tiles
. There
is the standard version, which generates geospatial tiles in TMS format. The
other version of gdal2tiles} handles basic image files like a matrix of rows and columns, using a simple Cartesian coordinate system based on pixel dimensions of the image file. See the Leaflet JS library and
leaflet`
package documentation for working with custom tiles in Leaflet.