Export an Earth Engine Image as Local Tiles
export_local_tile.RdDownloads an Earth Engine image by splitting it into a grid of tiles and saving each tile as a separate GeoTIFF file on the local machine.
Usage
export_local_tile(
image,
region,
scale,
crs = "EPSG:4326",
name = "Image_",
rows = 2,
cols = 2,
folder = "TIF"
)Arguments
- image
The `ee.Image` to export.
- region
The `ee.Geometry` that defines the export area. The function will fail if a FeatureCollection is provided without extracting its geometry first.
- scale
The spatial resolution in meters.
- crs
The coordinate reference system as an EPSG string (e.g., 'EPSG:4326').
- name
A prefix for the name of the output tile files.
- rows
The number of rows to split the region into.
- cols
The number of columns to split the region into.
- folder
The local folder where the tile files will be saved.
Examples
if (FALSE) { # \dontrun{
# Initialize GEE
py_env_path <- "C:/Users/pulak/anaconda3/envs/maps/python.exe"
activate_rpygee(project_id = "spatialgeography", python_path = py_env_path)
# Define a Region of Interest using the Delhi asset
roi <- rgee::ee$FeatureCollection("projects/spatialgeography/assets/delhi")$geometry()
# --- Example 1: Nighttime Lights ---
viirs <- rgee::ee$ImageCollection("NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG")$
filterDate("2019-01-01", "2019-01-31")$
first()$
select("avg_rad")
export_local_tile(
image = viirs,
region = roi,
scale = 500,
name = "VIIRS_Delhi_",
rows = 2,
cols = 2,
folder = "output/viirs_delhi_tiles"
)
# --- Example 2: Land Cover (ESA WorldCover) ---
esa_lc <- rgee::ee$ImageCollection("ESA/WorldCover/v100")$
first()
export_local_tile(
image = esa_lc,
region = roi,
scale = 100,
name = "ESA_LC_Delhi_",
rows = 2,
cols = 2,
folder = "output/esa_lc_delhi_tiles"
)
} # }