Skip to content

Commit

Permalink
Merge pull request gee-community#1112 from giswqs/fishnet
Browse files Browse the repository at this point in the history
Added fishnet function gee-community#1111
  • Loading branch information
giswqs authored Jun 18, 2022
2 parents df28b29 + 3eabf79 commit 846f702
Show file tree
Hide file tree
Showing 8 changed files with 432 additions and 28 deletions.
177 changes: 177 additions & 0 deletions docs/notebooks/117_fishnet.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"https://githubtocolab.com/giswqs/geemap/blob/master/examples/notebooks/117_fishnet.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>\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": {
"anaconda-cloud": {},
"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.9.10"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
1 change: 1 addition & 0 deletions docs/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,4 @@ More video tutorials for geemap and Earth Engine are available on my [YouTube ch
114. Creating near real-time global 10-m land cover maps with Dynamic World ([notebook](https://geemap.org/notebooks/114_dynamic_world))
115. Comparing Dynamic World with ESA and ESRI global land cover data ([notebook](https://geemap.org/notebooks/115_land_cover))
116. Creating global land cover timeseries ([notebook](https://geemap.org/notebooks/116_land_cover_timeseries))
117. Creating a fishnet based on an input vector dataset ([notebook](https://geemap.org/notebooks/117_fishnet))
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ More video tutorials for geemap and Earth Engine are available on my [YouTube ch
114. Creating near real-time global 10-m land cover maps with Dynamic World ([notebook](https://geemap.org/notebooks/114_dynamic_world))
115. Comparing Dynamic World with ESA and ESRI global land cover data ([notebook](https://geemap.org/notebooks/115_land_cover))
116. Creating global land cover timeseries ([notebook](https://geemap.org/notebooks/116_land_cover_timeseries))
117. Creating a fishnet based on an input vector dataset ([notebook](https://geemap.org/notebooks/117_fishnet))

### 1. Introducing the geemap Python package for interactive mapping with Google Earth Engine

Expand Down
177 changes: 177 additions & 0 deletions examples/notebooks/117_fishnet.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"https://githubtocolab.com/giswqs/geemap/blob/master/examples/notebooks/117_fishnet.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\"/></a>\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": {
"anaconda-cloud": {},
"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.9.10"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 846f702

Please sign in to comment.