{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"Open\n", "\n", "**Creating a fishnet based on an input vector dataset**\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 -U geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Simply draw a rectangle or polyon on the map use to used as an ROI." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = Map.user_roi\n", "\n", "if data is None:\n", " data = ee.Geometry.BBox(-112.8089, 33.7306, -88.5951, 46.6244)\n", " Map.addLayer(data, {}, 'ROI')\n", " Map.user_roi = None\n", "\n", "Map.centerObject(data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The input data can also be a file path or HTTP URL to a vector dataset. There are two ways to create a fishnet: specifying horizontal and vertical intervals or the number of rows and columns.\n", "\n", "Let's create a fishnet by specifying horizontal and vertical intervals in degrees." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fishnet = geemap.fishnet(data, h_interval=2.0, v_interval=2.0, delta=1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.addLayer(fishnet, {}, 'Fishnet 1')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Draw another polygon on the map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = Map.user_roi\n", "\n", "if data is None:\n", " data = ee.Geometry.Polygon(\n", " [\n", " [\n", " [-64.602356, -1.127399],\n", " [-68.821106, -12.625598],\n", " [-60.647278, -22.498601],\n", " [-47.815247, -21.111406],\n", " [-43.860168, -8.913564],\n", " [-54.582825, -0.775886],\n", " [-60.823059, 0.454555],\n", " [-64.602356, -1.127399],\n", " ]\n", " ]\n", " )\n", " Map.addLayer(data, {}, 'ROI2')\n", "\n", "Map.centerObject(data)\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's create another fishnet by specifying the number of rows and columns." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fishnet = geemap.fishnet(data, rows=6, cols=8, delta=1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.addLayer(fishnet, {}, 'Fishnet 2')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }