{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"Open\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 geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Update the package if needed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# geemap.update_package()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create an interactive map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map(center=[40, -100], zoom=4, add_google_map=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "states = ee.FeatureCollection(\"TIGER/2018/States\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "style = {'color': 'black', 'fillColor': \"00000000\"}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add an ee.FeatureCollection to the map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.addLayer(states.style(**style), {}, \"US States\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Labeling an ee.FeatureCollection." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.add_labels(\n", " states,\n", " \"STUSPS\",\n", " font_size=\"12pt\",\n", " font_color=\"blue\",\n", " font_family=\"arial\",\n", " font_weight=\"bold\",\n", ")\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Remove labels" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.remove_labels()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Labeling a Pandas DataFrame" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "centroids = geemap.vector_centroids(states)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = geemap.ee_to_df(centroids)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.add_labels(\n", " df,\n", " \"STUSPS\",\n", " font_size=\"12pt\",\n", " font_color=\"blue\",\n", " font_family=\"arial\",\n", " font_weight=\"bold\",\n", ")\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/lELtitr.gif)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }