Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
giswqs
GitHub Repository: giswqs/geemap
Path: blob/master/docs/notebooks/121_vector_style.ipynb
2313 views
Kernel: Python 3

Open in Colab

Styling Earth Engine vector data based on attributes

Uncomment the following line to install geemap if needed.

# !pip install -U geemap
import ee import geemap

Styling polygons

The US National Wetland Inventory.

Map = geemap.Map(center=[28.00142, -81.7424], zoom=13) Map.add_basemap("HYBRID")
fc = ee.FeatureCollection("projects/sat-io/open-datasets/NWI/wetlands/FL_Wetlands")
types = [ "Freshwater Forested/Shrub Wetland", "Freshwater Emergent Wetland", "Freshwater Pond", "Estuarine and Marine Wetland", "Riverine", "Lake", "Estuarine and Marine Deepwater", "Other", ] colors = [ "#008837", "#7FC31C", "#688CC0", "#66C2A5", "#0190BF", "#13007C", "#007C88", "#B28653", ] fillColor = [c + "A8" for c in colors]
styled_fc = geemap.ee_vector_style( fc, column="WETLAND_TY", labels=types, fillColor=fillColor, color="00000000" )
Map.addLayer(styled_fc, {}, "NWI") Map.add_legend(title="Wetland Type", labels=types, colors=colors) Map

Styling points

The Global Power Plant Database .

fuels = [ "Coal", "Oil", "Gas", "Hydro", "Nuclear", "Solar", "Waste", "Wind", "Geothermal", "Biomass", ]
fc = ee.FeatureCollection("WRI/GPPD/power_plants").filter( ee.Filter.inList("fuel1", fuels) )
colors = [ "000000", "593704", "BC80BD", "0565A6", "E31A1C", "FF7F00", "6A3D9A", "5CA2D1", "FDBF6F", "229A00", ]
styled_fc = geemap.ee_vector_style(fc, column="fuel1", labels=fuels, color=colors)
Map = geemap.Map() Map.addLayer(styled_fc, {}, "Power Plants") Map.add_legend(title="Power Plant Fuel Type", labels=fuels, colors=colors) Map

Styling polylines

The TIGER: US Census Roads. See the route type codes.

fc = ee.FeatureCollection("TIGER/2016/Roads")
types = ["I", "U", "S", "M", "C", "O"]
labels = ["Interstate", "U.S.", "State recognized", "Common Name", "County", "Other"]
colors = ["E31A1C", "FF7F00", "6A3D9A", "000000", "FDBF6F", "229A00"]
width = [8, 5, 4, 2, 1, 1]
styled_fc = geemap.ee_vector_style( fc, column="rttyp", labels=types, color=colors, width=width )
Map = geemap.Map(center=[40.7792, -73.9613], zoom=12) Map.addLayer(styled_fc, {}, "Census Roads") Map.add_legend(title="Route Type", labels=labels, colors=colors) Map