{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "\"Open\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "markdown", "id": "2", "metadata": {}, "source": [ "# How to get image basic properties and descriptive statistics" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "markdown", "id": "4", "metadata": {}, "source": [ "## Create an interactive map" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "## Add images to the map" ] }, { "cell_type": "code", "execution_count": null, "id": "7", "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, "id": "8", "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", "id": "9", "metadata": {}, "source": [ "## Get image property names" ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "landsat.propertyNames().getInfo()" ] }, { "cell_type": "code", "execution_count": null, "id": "11", "metadata": {}, "outputs": [], "source": [ "landsat.get(\"CLOUD_COVER\").getInfo()" ] }, { "cell_type": "code", "execution_count": null, "id": "12", "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, "id": "13", "metadata": {}, "outputs": [], "source": [ "ee.Date(landsat.get(\"system:time_start\")).format(\"YYYY-MM-dd\").getInfo()" ] }, { "cell_type": "markdown", "id": "14", "metadata": {}, "source": [ "## Get image properties all at once" ] }, { "cell_type": "code", "execution_count": null, "id": "15", "metadata": {}, "outputs": [], "source": [ "landsat_props = geemap.image_props(landsat)\n", "landsat_props.getInfo()" ] }, { "cell_type": "code", "execution_count": null, "id": "16", "metadata": {}, "outputs": [], "source": [ "landsat_props.get(\"IMAGE_DATE\").getInfo()" ] }, { "cell_type": "code", "execution_count": null, "id": "17", "metadata": {}, "outputs": [], "source": [ "naip_props = geemap.image_props(naip)\n", "naip_props.getInfo()" ] }, { "cell_type": "code", "execution_count": null, "id": "18", "metadata": {}, "outputs": [], "source": [ "naip_props.get(\"NOMINAL_SCALE\").getInfo()" ] }, { "cell_type": "markdown", "id": "19", "metadata": {}, "source": [ "## Get image descriptive statistics\n", "\n", "Including minimum, maximum, mean, standard deviation, and sum." ] }, { "cell_type": "code", "execution_count": null, "id": "20", "metadata": {}, "outputs": [], "source": [ "landsat_stats = geemap.image_stats(landsat, scale=90)\n", "landsat_stats.getInfo()" ] }, { "cell_type": "code", "execution_count": null, "id": "21", "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 }