{ "cells": [ { "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') \\\n", " .filterBounds(centroid) \\\n", " .first()\n", "\n", "landsat_vis = {\n", " 'min': 0,\n", " 'max': 3000,\n", " 'bands': ['B5', 'B4', 'B3']\n", "}\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') \\\n", " .filterBounds(centroid) \\\n", " .first()\n", "\n", "naip_vis = {\n", " 'bands': ['N', 'R', 'G']\n", "}\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": { "hide_input": false, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.2" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Table of Contents", "toc_cell": false, "toc_position": { "height": "calc(100% - 180px)", "left": "10px", "top": "150px", "width": "384px" }, "toc_section_display": true, "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }