89 add labels
Uncomment the following line to install geemap if needed.
In [1]:
Copied!
# !pip install geemap
# !pip install geemap
In [2]:
Copied!
import ee
import geemap
import ee
import geemap
Update the package if needed.
In [3]:
Copied!
# geemap.update_package()
# geemap.update_package()
Create an interactive map.
In [4]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4, add_google_map=False)
Map = geemap.Map(center=[40, -100], zoom=4, add_google_map=False)
In [5]:
Copied!
states = ee.FeatureCollection("TIGER/2018/States")
states = ee.FeatureCollection("TIGER/2018/States")
In [6]:
Copied!
style = {'color': 'black', 'fillColor': "00000000"}
style = {'color': 'black', 'fillColor': "00000000"}
Add an ee.FeatureCollection to the map.
In [7]:
Copied!
Map.addLayer(states.style(**style), {}, "US States")
Map.addLayer(states.style(**style), {}, "US States")
Labeling an ee.FeatureCollection.
In [8]:
Copied!
Map.add_labels(
states,
"STUSPS",
font_size="12pt",
font_color="blue",
font_family="arial",
font_weight="bold",
)
Map
Map.add_labels(
states,
"STUSPS",
font_size="12pt",
font_color="blue",
font_family="arial",
font_weight="bold",
)
Map
Out[8]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Remove labels
In [9]:
Copied!
Map.remove_labels()
Map.remove_labels()
The folium plotting backend does not support removing labels.
Labeling a Pandas DataFrame
In [10]:
Copied!
centroids = geemap.vector_centroids(states)
centroids = geemap.vector_centroids(states)
In [11]:
Copied!
df = geemap.ee_to_df(centroids)
df = geemap.ee_to_df(centroids)
In [12]:
Copied!
Map.add_labels(
df,
"STUSPS",
font_size="12pt",
font_color="blue",
font_family="arial",
font_weight="bold",
)
Map
Map.add_labels(
df,
"STUSPS",
font_size="12pt",
font_color="blue",
font_family="arial",
font_weight="bold",
)
Map
Out[12]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Last update:
2022-03-14