89 add labels
Uncomment the following line to install geemap if needed.
In [ ]:
Copied!
# !pip install geemap
# !pip install geemap
In [ ]:
Copied!
import ee
import geemap
import ee
import geemap
Update the package if needed.
In [ ]:
Copied!
# geemap.update_package()
# geemap.update_package()
Create an interactive map.
In [ ]:
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 [ ]:
Copied!
states = ee.FeatureCollection("TIGER/2018/States")
states = ee.FeatureCollection("TIGER/2018/States")
In [ ]:
Copied!
style = {'color': 'black', 'fillColor': "00000000"}
style = {'color': 'black', 'fillColor': "00000000"}
Add an ee.FeatureCollection to the map.
In [ ]:
Copied!
Map.addLayer(states.style(**style), {}, "US States")
Map.addLayer(states.style(**style), {}, "US States")
Labeling an ee.FeatureCollection.
In [ ]:
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
Remove labels
In [ ]:
Copied!
Map.remove_labels()
Map.remove_labels()
Labeling a Pandas DataFrame
In [ ]:
Copied!
centroids = geemap.vector_centroids(states)
centroids = geemap.vector_centroids(states)
In [ ]:
Copied!
df = geemap.ee_to_df(centroids)
df = geemap.ee_to_df(centroids)
In [ ]:
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