Image metadata
Image information and metadata
To explore image bands and properties in Python, print()
the image with the getInfo()
function. This information can also be accessed programmatically. For example, the following demonstrates how to access information about bands, projections and other metadata:
Import libraries¶
In [1]:
Copied!
import ee
import geemap
import ee
import geemap
Create an interactive map¶
In [2]:
Copied!
Map = geemap.Map()
Map
Map = geemap.Map()
Map
Out[2]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Display data on the map¶
In [3]:
Copied!
# Load an image.
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318')
vis_params = {
'bands': ['B5', 'B4', 'B3'],
'min': 0.0,
'max': 3000,
'opacity': 1.0,
'gamma': 1.2,
}
# Center the map and display the image.
Map.centerObject(image, zoom=8)
Map.addLayer(image, vis_params, 'Landsat')
# Load an image.
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318')
vis_params = {
'bands': ['B5', 'B4', 'B3'],
'min': 0.0,
'max': 3000,
'opacity': 1.0,
'gamma': 1.2,
}
# Center the map and display the image.
Map.centerObject(image, zoom=8)
Map.addLayer(image, vis_params, 'Landsat')
Get image metadata¶
Get information about the bands as a list.
In [4]:
Copied!
bandNames = image.bandNames()
print('Band names: ', bandNames.getInfo())
bandNames = image.bandNames()
print('Band names: ', bandNames.getInfo())
Band names: ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10', 'B11', 'sr_aerosol', 'pixel_qa', 'radsat_qa']
Get projection information from band 1. https://epsg.io/32610
In [5]:
Copied!
b1proj = image.select('B1').projection()
print('Band 1 projection: ', b1proj.getInfo())
b1proj = image.select('B1').projection()
print('Band 1 projection: ', b1proj.getInfo())
Band 1 projection: {'type': 'Projection', 'crs': 'EPSG:32610', 'transform': [30, 0, 460785, 0, -30, 4264215]}
Get scale (in meters) information from band 1.
In [6]:
Copied!
b1scale = image.select('B1').projection().nominalScale()
print('Band 1 scale: ', b1scale.getInfo())
b1scale = image.select('B1').projection().nominalScale()
print('Band 1 scale: ', b1scale.getInfo())
Band 1 scale: 30
Note that different bands can have different projections and scale.
In [7]:
Copied!
b10scale = image.select('B10').projection().nominalScale()
print('Band 10 scale: ', b10scale.getInfo())
b10scale = image.select('B10').projection().nominalScale()
print('Band 10 scale: ', b10scale.getInfo())
Band 10 scale: 30
Get a list of all metadata properties.
In [8]:
Copied!
properties = image.propertyNames()
print('Metadata properties: ', properties.getInfo())
properties = image.propertyNames()
print('Metadata properties: ', properties.getInfo())
Metadata properties: ['IMAGE_QUALITY_TIRS', 'CLOUD_COVER', 'system:id', 'EARTH_SUN_DISTANCE', 'LANDSAT_ID', 'system:footprint', 'system:version', 'CLOUD_COVER_LAND', 'GEOMETRIC_RMSE_MODEL', 'SR_APP_VERSION', 'SATELLITE', 'SOLAR_AZIMUTH_ANGLE', 'IMAGE_QUALITY_OLI', 'WRS_PATH', 'system:time_start', 'SENSING_TIME', 'ESPA_VERSION', 'SOLAR_ZENITH_ANGLE', 'WRS_ROW', 'GEOMETRIC_RMSE_MODEL_Y', 'LEVEL1_PRODUCTION_DATE', 'GEOMETRIC_RMSE_MODEL_X', 'system:asset_size', 'PIXEL_QA_VERSION', 'system:index', 'system:bands', 'system:band_names']
Get a specific metadata property.
In [9]:
Copied!
cloudiness = image.get('CLOUD_COVER')
print('CLOUD_COVER: ', cloudiness.getInfo())
cloudiness = image.get('CLOUD_COVER')
print('CLOUD_COVER: ', cloudiness.getInfo())
CLOUD_COVER: 0.06
Get the timestamp and convert it to a date.
In [10]:
Copied!
date = ee.Date(image.get('system:time_start'))
print('Timestamp: ', date.getInfo())
date = ee.Date(image.get('system:time_start'))
print('Timestamp: ', date.getInfo())
Timestamp: {'type': 'Date', 'value': 1395168392050}
In [11]:
Copied!
date2 = date.format('YYYY-MM-dd')
print('Timestamp: ', date2.getInfo())
date2 = date.format('YYYY-MM-dd')
print('Timestamp: ', date2.getInfo())
Timestamp: 2014-03-18
Use geemap to get image metadata¶
In [12]:
Copied!
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318')
image_props = geemap.image_props(image)
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318')
image_props = geemap.image_props(image)
In [13]:
Copied!
image_props.getInfo()
image_props.getInfo()
Out[13]:
{'CLOUD_COVER': 0.06, 'CLOUD_COVER_LAND': 0.1, 'EARTH_SUN_DISTANCE': 0.995371, 'ESPA_VERSION': '2_23_0_1a', 'GEOMETRIC_RMSE_MODEL': 6.78, 'GEOMETRIC_RMSE_MODEL_X': 4.841, 'GEOMETRIC_RMSE_MODEL_Y': 4.747, 'IMAGE_DATE': '2014-03-18', 'IMAGE_QUALITY_OLI': 9, 'IMAGE_QUALITY_TIRS': 9, 'LANDSAT_ID': 'LC08_L1TP_044034_20140318_20170307_01_T1', 'LEVEL1_PRODUCTION_DATE': 1488849349000, 'NOMINAL_SCALE': 30, 'PIXEL_QA_VERSION': 'generate_pixel_qa_1.6.0', 'SATELLITE': 'LANDSAT_8', 'SENSING_TIME': '2014-03-18T18:46:32.0535800Z', 'SOLAR_AZIMUTH_ANGLE': 146.239578, 'SOLAR_ZENITH_ANGLE': 43.528934, 'SR_APP_VERSION': 'LaSRC_1.3.0', 'WRS_PATH': 44, 'WRS_ROW': 34, 'system:asset_size': '540.072009 MB', 'system:band_names': ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10', 'B11', 'sr_aerosol', 'pixel_qa', 'radsat_qa'], 'system:id': 'LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318', 'system:index': 'LC08_044034_20140318', 'system:time_end': '2014-03-18 18:46:32', 'system:time_start': '2014-03-18 18:46:32', 'system:version': 1522720282729760.0}
Last update:
2022-03-25