<jupyter_start><jupyter_text>[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/giswqs/GEE-Courses/blob/master/docs/geemap_intro/11_analysis.ipynb) Descriptive statisticsUncomment and execute the following code block to install geemap if needed.<jupyter_code># !pip install geemap
import ee
import geemap
Map = geemap.Map()

centroid = ee.Geometry.Point([-122.4439, 37.7538])

image = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').filterBounds(centroid).first()

vis = {'min': 0, 'max': 3000, 'bands': ['B5', 'B4', 'B3']}

Map.centerObject(centroid, 8)
Map.addLayer(image, vis, "Landsat-8")
Map<jupyter_output><empty_output><jupyter_text>Using Earth Engine built-in functions to get image properties.<jupyter_code>image.propertyNames().getInfo()
image.get('CLOUD_COVER').getInfo()<jupyter_output><empty_output><jupyter_text>Using `geemap.image_props()` to get image properties.<jupyter_code>props = geemap.image_props(image)
props.getInfo()<jupyter_output><empty_output><jupyter_text>Get image summary statistics, such as max, min, mean, std, sum.<jupyter_code>stats = geemap.image_stats(image, scale=90)
stats.getInfo()<jupyter_output><empty_output><jupyter_text>Zonal statisticsAdd Earth Engine datasets.<jupyter_code>Map = geemap.Map(center=[40, -100], zoom=4)

# Add Earth Engine dataset
dem = ee.Image('USGS/SRTMGL1_003')

# Set visualization parameters.
dem_vis = {
    'min': 0,
    'max': 4000,
    'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],
}

# Add Earth Engine DEM to map
Map.addLayer(dem, dem_vis, 'SRTM DEM')

# Add Landsat data to map
landsat = ee.Image('LE7_TOA_5YEAR/1999_2003')

landsat_vis = {'bands': ['B4', 'B3', 'B2'], 'gamma': 1.4}
Map.addLayer(landsat, landsat_vis, "LE7_TOA_5YEAR/1999_2003")

states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, 'US States')
Map<jupyter_output><empty_output><jupyter_text>Computer zonal statistics. - Allowed output formats: csv, shp, json, kml, kmz- Allowed statistics type: MEAN, MAXIMUM, MINIMUM, MEDIAN, STD, MIN_MAX, VARIANCE, SUM<jupyter_code>out_dem_stats = 'dem_stats.csv'
geemap.zonal_statistics(dem, states, out_dem_stats, statistics_type='MEAN', scale=1000)
out_landsat_stats = 'landsat_stats.csv'
geemap.zonal_statistics(
    landsat, states, out_landsat_stats, statistics_type='SUM', scale=1000
)<jupyter_output><empty_output><jupyter_text>Zonal statistics by groupAdd Earth Engine datasets.<jupyter_code>Map = geemap.Map(center=[40, -100], zoom=4)

dataset = ee.Image('USGS/NLCD_RELEASES/2019_REL/NLCD/2019')
landcover = dataset.select('landcover')
Map.addLayer(landcover, {}, 'NLCD 2019')

states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, 'US States')
Map.add_legend(builtin_legend='NLCD')
Map<jupyter_output><empty_output><jupyter_text>Computer zonal statistics by group.- statistics_type can be either 'SUM' or 'PERCENTAGE'- denominator can be used to convert square meters to other areal units, such as square kilimeters.<jupyter_code>nlcd_stats = 'nlcd_stats.csv'

geemap.zonal_statistics_by_group(
    landcover,
    states,
    nlcd_stats,
    statistics_type='SUM',
    denominator=1000000,
    decimal_places=2,
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14171779141104293, 'fraction_numerical': 0.04049079754601227, 'mean_word_length': 6.992647058823529, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '414463', 'license': 'MIT', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1225, 'n_words': 229, 'path': 'docs/geemap_intro/11_analysis.ipynb', 'repo_name': 'giswqs/GEE-Courses', 'size': '3260'}