{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"Open\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# How to get image basic properties and descriptive statistics" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Create an interactive map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add images to the map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "centroid = ee.Geometry.Point([-122.4439, 37.7538])\n", "\n", "landsat = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').filterBounds(centroid).first()\n", "\n", "landsat_vis = {'min': 0, 'max': 3000, 'bands': ['B5', 'B4', 'B3']}\n", "\n", "Map.centerObject(centroid, 8)\n", "Map.addLayer(landsat, landsat_vis, \"Landsat-8\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "naip = ee.ImageCollection('USDA/NAIP/DOQQ').filterBounds(centroid).first()\n", "\n", "naip_vis = {'bands': ['N', 'R', 'G']}\n", "\n", "Map.addLayer(naip, naip_vis, 'NAIP')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get image property names" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "landsat.propertyNames().getInfo()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "landsat.get('CLOUD_COVER').getInfo()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# The number of milliseconds since 1970-01-01T00:00:00Z.\n", "landsat.get('system:time_start').getInfo()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ee.Date(landsat.get('system:time_start')).format('YYYY-MM-dd').getInfo()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get image properties all at once" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "landsat_props = geemap.image_props(landsat)\n", "landsat_props.getInfo()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "landsat_props.get('IMAGE_DATE').getInfo()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "naip_props = geemap.image_props(naip)\n", "naip_props.getInfo()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "naip_props.get('NOMINAL_SCALE').getInfo()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get image descriptive statistics\n", "\n", "Including minimum, maximum, mean, standard deviation, and sum." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "landsat_stats = geemap.image_stats(landsat, scale=90)\n", "landsat_stats.getInfo()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "naip_stats = geemap.image_stats(naip, scale=10)\n", "naip_stats.getInfo()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }