65 vector styling
Uncomment the following line to install geemap if needed.
In [1]:
Copied!
# !pip install geemap
# !pip install geemap
Styling Earth Engine vector data
In [2]:
Copied!
import ee
import geemap
import ee
import geemap
In [3]:
Copied!
# geemap.update_package()
# geemap.update_package()
Use the default style¶
In [4]:
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
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Use Image.paint()¶
In [5]:
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
Out[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Use FeatureCollection.style()¶
In [6]:
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
Out[6]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Use add_styled_vector()¶
In [7]:
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
Out[7]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [8]:
Copied!
import geemap.colormaps as cm
import geemap.colormaps as cm
In [9]:
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
Out[9]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [10]:
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
Out[10]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Use interactive GUI¶
In [11]:
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
Out[11]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Last update:
2022-03-14