139 layer to image
Converting an Earth Engine layer to an image
This notebook demonstrates how to convert an Earth Engine layer to an image. It can very useful when you want to export an Earth Engine layer with custom visualization parameters. It should be much better than taking a screenshot of the layer. You can specify the scale of the image and the region to export.
In [ ]:
Copied!
# !pip install -U geemap geedim
# !pip install -U geemap geedim
In [ ]:
Copied!
import ee
import geemap
import ee
import geemap
In [ ]:
Copied!
m = geemap.Map(center=(41.0462, -109.7424), zoom=6)
dem = ee.Image('USGS/SRTMGL1_003')
landsat7 = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003').select(
['B1', 'B2', 'B3', 'B4', 'B5', 'B7']
)
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],
}
m.add_layer(
landsat7,
{'bands': ['B4', 'B3', 'B2'], 'min': 20, 'max': 200, 'gamma': 2},
'landsat',
)
m.add_layer(dem, vis_params, 'dem', True, 1)
m
m = geemap.Map(center=(41.0462, -109.7424), zoom=6)
dem = ee.Image('USGS/SRTMGL1_003')
landsat7 = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003').select(
['B1', 'B2', 'B3', 'B4', 'B5', 'B7']
)
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],
}
m.add_layer(
landsat7,
{'bands': ['B4', 'B3', 'B2'], 'min': 20, 'max': 200, 'gamma': 2},
'landsat',
)
m.add_layer(dem, vis_params, 'dem', True, 1)
m
In [ ]:
Copied!
m.layer_to_image('dem', output='dem.tif', crs='EPSG:3857', region=None, scale=None)
m.layer_to_image('dem', output='dem.tif', crs='EPSG:3857', region=None, scale=None)
In [ ]:
Copied!
m.layer_to_image('dem', output='dem.jpg', scale=500)
m.layer_to_image('dem', output='dem.jpg', scale=500)
In [ ]:
Copied!
geemap.show_image('dem.jpg')
geemap.show_image('dem.jpg')
In [ ]:
Copied!
m.layer_to_image('landsat', output='landsat.tif')
m.layer_to_image('landsat', output='landsat.tif')
In [ ]:
Copied!
geemap.geotiff_to_image('landsat.tif', output='landsat.jpg')
geemap.geotiff_to_image('landsat.tif', output='landsat.jpg')
In [ ]:
Copied!
geemap.show_image('landsat.jpg')
geemap.show_image('landsat.jpg')