Skip to content

Google earth

image image image

Create raster tiles for rendering in Google Earth

Create raster tiles for rendering in Google Earth at https://earth.google.com.

Uncomment the following line to install leafmap if needed.

1
# %pip install leafmap geemap
1
2
3
import os
import ee
from leafmap import get_ee_tile_url, cog_tile
1
2
ee.Authenticate()
ee.Initialize(project="your-ee-project")
1
2
3
4
esa_dataset = ee.ImageCollection("ESA/WorldCover/v200").first()
vis_params = {"bands": ["Map"]}
tile_url = get_ee_tile_url(esa_dataset, vis_params)
print(tile_url)
1
2
3
4
dem_dataset = ee.Image("NASA/NASADEM_HGT/001").select("elevation")
vis_params = {"min": 0, "max": 4000, "palette": "terrain"}
tile_url = get_ee_tile_url(dem_dataset, vis_params)
print(tile_url)
1
os.environ["TITILER_ENDPOINT"] = "https://titiler.opengeos.org"
1
2
3
dem_url = "https://github.com/opengeos/datasets/releases/download/raster/dem_90m.tif"
tile_url = cog_tile(dem_url, colormap_name="terrain")
print(tile_url)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
nlcd_url = "https://github.com/opengeos/datasets/releases/download/raster/nlcd_2021_land_cover_30m.tif"
colormap = {
    "11": "#466b9f",
    "12": "#d1def8",
    "21": "#dec5c5",
    "22": "#d99282",
    "23": "#eb0000",
    "24": "#ab0000",
    "31": "#b3ac9f",
    "41": "#68ab5f",
    "42": "#1c5f2c",
    "43": "#b5c58f",
    "51": "#af963c",
    "52": "#ccb879",
    "71": "#dfdfc2",
    "72": "#d1d182",
    "73": "#a3cc51",
    "74": "#82ba9e",
    "81": "#dcd939",
    "82": "#ab6c28",
    "90": "#b8d9eb",
    "95": "#6c9fb8",
}
tile_url = cog_tile(nlcd_url, colormap=colormap)
print(tile_url)