diff --git a/notes/lecture12.ipynb b/notes/lecture12.ipynb index eb8946e..37c5d54 100644 --- a/notes/lecture12.ipynb +++ b/notes/lecture12.ipynb @@ -8,9 +8,980 @@ "source": [ "import ee\n", "import geemap\n", + "import geopandas as gpd\n", "ee.Initialize()" ] }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "NLCD\n", + "ESA_WorldCover\n", + "ESRI_LandCover\n", + "ESRI_LandCover_TS\n", + "Dynamic_World\n", + "NWI\n", + "MODIS/051/MCD12Q1\n", + "MODIS/006/MCD12Q1\n", + "GLOBCOVER\n", + "JAXA/PALSAR\n", + "Oxford\n", + "AAFC/ACI\n", + "COPERNICUS/CORINE/V20/100m\n", + "COPERNICUS/Landcover/100m/Proba-V/Global\n", + "USDA/NASS/CDL\n", + "ALOS_landforms\n" + ] + } + ], + "source": [ + "from geemap.legends import builtin_legends\n", + "\n", + "for item in builtin_legends:\n", + " print(item)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "cfa47546c9684d0a8efe8a47b7c38a69", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map(center=[40, -100], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=SearchDataGUI(ch…" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Map=geemap.Map(center=[40,-100], zoom=4)\n", + "Map.add_basemap('HYBRID')\n", + "\n", + "nlcd= ee.Image('USGS/NLCD_RELEASES/2019_REL/NLCD/2019')\n", + "landcover= nlcd.select('landcover')\n", + "\n", + "Map.addLayer(landcover, {}, 'NLCD Land Cover')\n", + "Map.add_legend(title='NLCD Land Cover Classification', builtin_legend='NLCD')\n", + "Map" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "text= 'made by Zhanchao Yang'\n", + "Map.add_text(text, position='bottomright')" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "5322562821364a419afb8b0f3ea3a70d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map(center=[0, 0], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=SearchDataGUI(childr…" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Map = geemap.Map()\n", + "\n", + "dataset = ee.ImageCollection(\"ESA/WorldCover/v100\").first()\n", + "Map.addLayer(dataset, {'bands': ['Map']}, \"Landcover\")\n", + "\n", + "# Add a legend to the map , from google earth engine class table\n", + "\n", + "ee_class_table = \"\"\"\n", + "Value\tColor\tDescription\n", + "10\t006400\tTrees\n", + "20\tffbb22\tShrubland\n", + "30\tffff4c\tGrassland\n", + "40\tf096ff\tCropland\n", + "50\tfa0000\tBuilt-up\n", + "60\tb4b4b4\tBarren / sparse vegetation\n", + "70\tf0f0f0\tSnow and ice\n", + "80\t0064c8\tOpen water\n", + "90\t0096a0\tHerbaceous wetland\n", + "95\t00cf75\tMangroves\n", + "100\tfae6a0\tMoss and lichen\n", + "\"\"\"\n", + "\n", + "legend_dict = geemap.legend_from_ee(ee_class_table)\n", + "Map.add_legend(title=\"ESA Land Cover\", legend_dict=legend_dict)\n", + "Map" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "a2131bb922ee46ad9877613415f2b0f0", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map(center=[40, -100], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=SearchDataGUI(ch…" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\n", + "Map = geemap.Map(center=[40, -100], zoom=4)\n", + "\n", + "legend_dict = {\n", + " '11 Open Water': '466b9f',\n", + " '12 Perennial Ice/Snow': 'd1def8',\n", + " '21 Developed, Open Space': 'dec5c5',\n", + " '22 Developed, Low Intensity': 'd99282',\n", + " '23 Developed, Medium Intensity': 'eb0000',\n", + " '24 Developed High Intensity': 'ab0000',\n", + " '31 Barren Land (Rock/Sand/Clay)': 'b3ac9f',\n", + " '41 Deciduous Forest': '68ab5f',\n", + " '42 Evergreen Forest': '1c5f2c',\n", + " '43 Mixed Forest': 'b5c58f',\n", + " '51 Dwarf Scrub': 'af963c',\n", + " '52 Shrub/Scrub': 'ccb879',\n", + " '71 Grassland/Herbaceous': 'dfdfc2',\n", + " '72 Sedge/Herbaceous': 'd1d182',\n", + " '73 Lichens': 'a3cc51',\n", + " '74 Moss': '82ba9e',\n", + " '81 Pasture/Hay': 'dcd939',\n", + " '82 Cultivated Crops': 'ab6c28',\n", + " '90 Woody Wetlands': 'b8d9eb',\n", + " '95 Emergent Herbaceous Wetlands': '6c9fb8',\n", + "}\n", + "\n", + "nlcd = ee.Image('USGS/NLCD_RELEASES/2019_REL/NLCD/2019')\n", + "landcover = nlcd.select('landcover')\n", + "\n", + "Map.addLayer(landcover, {}, 'NLCD Land Cover 2019')\n", + "Map.add_legend(title=\"NLCD Land Cover Classification\", legend_dict=legend_dict)\n", + "Map" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Displaying labels" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d2ea2d20308a431e8abbca0b6f9f8ae4", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map(center=[40, -100], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=SearchDataGUI(ch…" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "m=geemap.Map(center=[40,-100], zoom=4, add_google_map=False)\n", + "states= ee.FeatureCollection('TIGER/2018/States')\n", + "style= {'color': 'green', 'width': 1, 'lineType': 'solid', 'fillColor': '00000000'}\n", + "m.addLayer(states.style(**style), {}, 'States')\n", + "m" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "m.add_basemap('HYBRID')" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "m.add_labels(\n", + " data=states,\n", + " column='STUSPS',\n", + " font_size= '12pt',\n", + " font_color='blue',\n", + " font_family='arial',\n", + " font_weight='bold',\n", + " draggable=True,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "m.remove_labels()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Spilt-panel maps" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9c8c64e827f94f08ab91bac7e0f88c8e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map(center=[0, 0], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'zoom_out_text'…" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Map= geemap.Map()\n", + "Map.split_map(left_layer='Esri.WorldTopoMap', right_layer='OpenTopoMap')\n", + "Map" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import geemap.foliumap as geemap" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Map= geemap.Map()\n", + "Map.split_map(left_layer='Esri.WorldTopoMap', right_layer='OpenTopoMap')\n", + "Map" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "Map.save('split_map.html')" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/notes/split_map.html b/notes/split_map.html new file mode 100644 index 0000000..feec296 --- /dev/null +++ b/notes/split_map.html @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + \ No newline at end of file