{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "0", "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map(zoom=8)" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "image = ee.Image(\"LANDSAT/LE7_TOA_5YEAR/1999_2003\").select(\n", " [\"B1\", \"B2\", \"B3\", \"B4\", \"B5\", \"B7\"]\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "Map.addLayer(\n", " image,\n", " {\"bands\": [\"B4\", \"B3\", \"B2\"], \"min\": 20, \"max\": 200, \"gamma\": 2.0},\n", " \"Landsat 7\",\n", ")\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "region = Map.user_roi" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "if region is None:\n", " region = ee.Geometry.Point([-101.5, 40]).buffer(100000)\n", " Map.addLayer(ee.Image().paint(region, 0, 4), {\"palette\": \"yellow\"}, \"ROI-1\")" ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "random_points = geemap.random_sampling(image, region, numPixels=1000)\n", "Map.addLayer(random_points, {}, \"Random Sampling\")" ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": {}, "outputs": [], "source": [ "df = geemap.ee_to_df(random_points)\n", "df" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "region2 = Map.user_roi" ] }, { "cell_type": "code", "execution_count": null, "id": "9", "metadata": {}, "outputs": [], "source": [ "if region2 is None:\n", " region2 = ee.Geometry.Point([-99, 40]).buffer(100000)\n", " Map.addLayer(ee.Image().paint(region2, 0, 4), {\"palette\": \"blue\"}, \"ROI-2\")" ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "sys_points = geemap.random_sampling(image, region2, scale=10000)\n", "Map.addLayer(sys_points, {}, \"Systematic Sampling\")" ] }, { "cell_type": "code", "execution_count": null, "id": "11", "metadata": {}, "outputs": [], "source": [ "df = geemap.ee_to_df(sys_points)\n", "df" ] }, { "cell_type": "markdown", "id": "12", "metadata": {}, "source": [ "![](https://i.imgur.com/14ulR5D.png)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }