65 vector styling
Uncomment the following line to install geemap if needed.
In [ ]:
Copied!
# !pip install geemap
# !pip install geemap
Styling Earth Engine vector data
In [ ]:
Copied!
import ee
import geemap
import ee
import geemap
In [ ]:
Copied!
# geemap.update_package()
# geemap.update_package()
Use the default style¶
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, "US States")
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, "US States")
Map
Use Image.paint()¶
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
image = ee.Image().paint(states, 0, 3)
Map.addLayer(image, {"palette": "red"}, "US States")
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
image = ee.Image().paint(states, 0, 3)
Map.addLayer(image, {"palette": "red"}, "US States")
Map
Use FeatureCollection.style()¶
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
style = {"color": "0000ffff", "width": 2, "lineType": "solid", "fillColor": "00000080"}
Map.addLayer(states.style(**style), {}, "US States")
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
style = {"color": "0000ffff", "width": 2, "lineType": "solid", "fillColor": "00000080"}
Map.addLayer(states.style(**style), {}, "US States")
Map
Use add_styled_vector()¶
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
vis_params = {
"color": "000000",
"colorOpacity": 1,
"pointSize": 3,
"pointShape": "circle",
"width": 2,
"lineType": "solid",
"fillColorOpacity": 0.66,
}
palette = ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"]
Map.add_styled_vector(
states, column="NAME", palette=palette, layer_name="Styled vector", **vis_params
)
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
vis_params = {
"color": "000000",
"colorOpacity": 1,
"pointSize": 3,
"pointShape": "circle",
"width": 2,
"lineType": "solid",
"fillColorOpacity": 0.66,
}
palette = ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"]
Map.add_styled_vector(
states, column="NAME", palette=palette, layer_name="Styled vector", **vis_params
)
Map
In [ ]:
Copied!
import geemap.colormaps as cm
import geemap.colormaps as cm
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
vis_params = {
"color": "000000",
"colorOpacity": 1,
"pointSize": 3,
"pointShape": "circle",
"width": 2,
"lineType": "solid",
"fillColorOpacity": 0.66,
}
palette = list(cm.palettes.gist_earth.n12)
Map.add_styled_vector(
states, column="NAME", palette=palette, layer_name="Styled vector", **vis_params
)
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
vis_params = {
"color": "000000",
"colorOpacity": 1,
"pointSize": 3,
"pointShape": "circle",
"width": 2,
"lineType": "solid",
"fillColorOpacity": 0.66,
}
palette = list(cm.palettes.gist_earth.n12)
Map.add_styled_vector(
states, column="NAME", palette=palette, layer_name="Styled vector", **vis_params
)
Map
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States").filter(
ee.Filter.inList("NAME", ["California", "Nevada", "Utah", "Arizona"])
)
palette = {
"California": "ff0000",
"Nevada": "00ff00",
"Utah": "0000ff",
"Arizona": "ffff00",
}
vis_params = {
"color": "000000",
"colorOpacity": 1,
"width": 2,
"lineType": "solid",
"fillColorOpacity": 0.66,
}
Map.add_styled_vector(
states, column="NAME", palette=palette, layer_name="Styled vector", **vis_params
)
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States").filter(
ee.Filter.inList("NAME", ["California", "Nevada", "Utah", "Arizona"])
)
palette = {
"California": "ff0000",
"Nevada": "00ff00",
"Utah": "0000ff",
"Arizona": "ffff00",
}
vis_params = {
"color": "000000",
"colorOpacity": 1,
"width": 2,
"lineType": "solid",
"fillColorOpacity": 0.66,
}
Map.add_styled_vector(
states, column="NAME", palette=palette, layer_name="Styled vector", **vis_params
)
Map
Use interactive GUI¶
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, "US States")
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, "US States")
Map