{
"cells": [
{
"cell_type": "markdown",
"id": "0",
"metadata": {},
"source": [
"\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": [
"To follow this tutorial, you need to [sign up](https://datapane.com/accounts/signup/) for an account with , then install and authenticate the `datapane` Python package. More information can be found [here](https://docs.datapane.com/tutorials/tut-getting-started). \n",
"\n",
"- `pip install datapane`\n",
"- `datapane login`\n",
"- `datapane ping`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"import ee\n",
"import geemap.foliumap as geemap"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {},
"outputs": [],
"source": [
"Map = geemap.Map(center=[40, -100], zoom=4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"# Select the seven NLCD epoches after 2000.\n",
"years = [\"2001\", \"2004\", \"2006\", \"2008\", \"2011\", \"2013\", \"2016\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6",
"metadata": {},
"outputs": [],
"source": [
"# Get an NLCD image by year.\n",
"def getNLCD(year):\n",
" # Import the NLCD collection.\n",
" dataset = ee.ImageCollection(\"USGS/NLCD_RELEASES/2016_REL\")\n",
"\n",
" # Filter the collection by year.\n",
" nlcd = dataset.filter(ee.Filter.eq(\"system:index\", year)).first()\n",
"\n",
" # Select the land cover band.\n",
" landcover = nlcd.select(\"landcover\")\n",
" return landcover"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {},
"outputs": [],
"source": [
"for year in years:\n",
" data = getNLCD(year)\n",
" Map.addLayer(data, {}, \"NLCD \" + year)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8",
"metadata": {},
"outputs": [],
"source": [
"# Add the NLCD legend to the map.\n",
"Map.add_legend(legend_title=\"NLCD Land Cover Classification\", builtin_legend=\"NLCD\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {},
"outputs": [],
"source": [
"Map"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10",
"metadata": {},
"outputs": [],
"source": [
"Map.publish(name=\"National Land Cover Database (NLCD)\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}