Uncomment the following line to install geemap if needed.
In [1]:
Copied!
# !pip install geemap
# !pip install geemap
How to get image basic properties and descriptive statistics¶
In [2]:
Copied!
import ee
import geemap
import ee
import geemap
Create an interactive map¶
In [3]:
Copied!
Map = geemap.Map()
Map
Map = geemap.Map()
Map
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Add images to the map¶
In [4]:
Copied!
centroid = ee.Geometry.Point([-122.4439, 37.7538])
landsat = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').filterBounds(centroid).first()
landsat_vis = {'min': 0, 'max': 3000, 'bands': ['B5', 'B4', 'B3']}
Map.centerObject(centroid, 8)
Map.addLayer(landsat, landsat_vis, "Landsat-8")
centroid = ee.Geometry.Point([-122.4439, 37.7538])
landsat = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').filterBounds(centroid).first()
landsat_vis = {'min': 0, 'max': 3000, 'bands': ['B5', 'B4', 'B3']}
Map.centerObject(centroid, 8)
Map.addLayer(landsat, landsat_vis, "Landsat-8")
In [5]:
Copied!
naip = ee.ImageCollection('USDA/NAIP/DOQQ').filterBounds(centroid).first()
naip_vis = {'bands': ['N', 'R', 'G']}
Map.addLayer(naip, naip_vis, 'NAIP')
naip = ee.ImageCollection('USDA/NAIP/DOQQ').filterBounds(centroid).first()
naip_vis = {'bands': ['N', 'R', 'G']}
Map.addLayer(naip, naip_vis, 'NAIP')
Get image property names¶
In [6]:
Copied!
landsat.propertyNames().getInfo()
landsat.propertyNames().getInfo()
Out[6]:
['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', 'system:time_end', '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']
In [7]:
Copied!
landsat.get('CLOUD_COVER').getInfo()
landsat.get('CLOUD_COVER').getInfo()
Out[7]:
0.05
In [8]:
Copied!
# The number of milliseconds since 1970-01-01T00:00:00Z.
landsat.get('system:time_start').getInfo()
# The number of milliseconds since 1970-01-01T00:00:00Z.
landsat.get('system:time_start').getInfo()
Out[8]:
1365533194757
In [9]:
Copied!
ee.Date(landsat.get('system:time_start')).format('YYYY-MM-dd').getInfo()
ee.Date(landsat.get('system:time_start')).format('YYYY-MM-dd').getInfo()
Out[9]:
'2013-04-09'
Get image properties all at once¶
In [10]:
Copied!
landsat_props = geemap.image_props(landsat)
landsat_props.getInfo()
landsat_props = geemap.image_props(landsat)
landsat_props.getInfo()
Out[10]:
{'CLOUD_COVER': 0.05, 'CLOUD_COVER_LAND': 0.06, 'EARTH_SUN_DISTANCE': 1.001791, 'ESPA_VERSION': '2_23_0_1b', 'GEOMETRIC_RMSE_MODEL': 6.678, 'GEOMETRIC_RMSE_MODEL_X': 4.663, 'GEOMETRIC_RMSE_MODEL_Y': 4.78, 'IMAGE_DATE': '2013-04-09', 'IMAGE_QUALITY_OLI': 9, 'IMAGE_QUALITY_TIRS': 9, 'LANDSAT_ID': 'LC08_L1TP_044034_20130409_20170310_01_T1', 'LEVEL1_PRODUCTION_DATE': 1489126619000, 'NOMINAL_SCALE': 30, 'PIXEL_QA_VERSION': 'generate_pixel_qa_1.6.0', 'SATELLITE': 'LANDSAT_8', 'SENSING_TIME': '2013-04-09T18:46:34.7579070Z', 'SOLAR_AZIMUTH_ANGLE': 142.742508, 'SOLAR_ZENITH_ANGLE': 34.973495, 'SR_APP_VERSION': 'LaSRC_1.3.0', 'WRS_PATH': 44, 'WRS_ROW': 34, 'system:asset_size': '558.682087 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_20130409', 'system:index': 'LC08_044034_20130409', 'system:time_end': '2013-04-09 18:46:34', 'system:time_start': '2013-04-09 18:46:34', 'system:version': 1581684730621653}
In [11]:
Copied!
landsat_props.get('IMAGE_DATE').getInfo()
landsat_props.get('IMAGE_DATE').getInfo()
Out[11]:
'2013-04-09'
In [12]:
Copied!
naip_props = geemap.image_props(naip)
naip_props.getInfo()
naip_props = geemap.image_props(naip)
naip_props.getInfo()
Out[12]:
{'IMAGE_DATE': '2018-08-04', 'NOMINAL_SCALE': 0.6, 'system:asset_size': '507.744814 MB', 'system:band_names': ['R', 'G', 'B', 'N'], 'system:id': 'USDA/NAIP/DOQQ/m_3712213_sw_10_060_20180804_20190209', 'system:index': 'm_3712213_sw_10_060_20180804_20190209', 'system:time_end': '2018-08-04 00:00:00', 'system:time_start': '2018-08-04 00:00:00', 'system:version': 1585606585367435}
In [13]:
Copied!
naip_props.get('NOMINAL_SCALE').getInfo()
naip_props.get('NOMINAL_SCALE').getInfo()
Out[13]:
0.6
Get image descriptive statistics¶
Including minimum, maximum, mean, standard deviation, and sum.
In [14]:
Copied!
landsat_stats = geemap.image_stats(landsat, scale=90)
landsat_stats.getInfo()
landsat_stats = geemap.image_stats(landsat, scale=90)
landsat_stats.getInfo()
Out[14]:
{'max': {'B1': 7624, 'B10': 3155, 'B11': 3127, 'B2': 8471, 'B3': 9778, 'B4': 10679, 'B5': 11606, 'B6': 13054, 'B7': 12327, 'pixel_qa': 480, 'radsat_qa': 254, 'sr_aerosol': 228}, 'mean': {'B1': 373.1098468094287, 'B10': 2933.4637979167583, 'B11': 2916.278387909346, 'B2': 427.40213139234174, 'B3': 614.9744637045823, 'B4': 591.3781773385491, 'B5': 1954.134478186476, 'B6': 1472.071307222312, 'B7': 996.8232780577415, 'pixel_qa': 322.8433703241347, 'radsat_qa': 0.00019878780091270898, 'sr_aerosol': 87.74885862483129}, 'min': {'B1': -1432, 'B10': 2759, 'B11': 2702, 'B2': -1129, 'B3': -345, 'B4': -403, 'B5': 35, 'B6': 10, 'B7': 5, 'pixel_qa': 322, 'radsat_qa': 0, 'sr_aerosol': 8}, 'std': {'B1': 201.9355685609457, 'B10': 67.57460806939051, 'B11': 63.85549758560136, 'B2': 230.81296623126636, 'B3': 296.8097076885089, 'B4': 393.63764571402265, 'B5': 1202.7937141588027, 'B6': 926.420271742664, 'B7': 729.0233711578251, 'pixel_qa': 4.9833065816273345, 'radsat_qa': 0.1664709111036373, 'sr_aerosol': 25.1855827242985}, 'sum': {'B1': 1557981451.9372544, 'B10': 12249159935.513742, 'B11': 12177399433.172562, 'B2': 1784687804.2, 'B3': 2567926888.180393, 'B4': 2469396718.560784, 'B5': 8159809497.49804, 'B6': 6146875544.007842, 'B7': 4162399334.5490217, 'pixel_qa': 1347970027.027451, 'radsat_qa': 830, 'sr_aerosol': 366378380.98823535}}
In [15]:
Copied!
naip_stats = geemap.image_stats(naip, scale=10)
naip_stats.getInfo()
naip_stats = geemap.image_stats(naip, scale=10)
naip_stats.getInfo()
Out[15]:
{'max': {'B': 233, 'G': 233, 'N': 223, 'R': 229}, 'mean': {'B': 114.4638137606029, 'G': 109.69790669773778, 'N': 90.02379690730004, 'R': 98.22685449511252}, 'min': {'B': 49, 'G': 33, 'N': 1, 'R': 20}, 'std': {'B': 36.49168534887196, 'G': 38.489676683171794, 'N': 46.037770089931975, 'R': 45.42471323713558}, 'sum': {'B': 48679172.0627451, 'G': 46652327.05098021, 'N': 38285321.407842256, 'R': 41773917.835293904}}
Last update:
2022-03-14