121 vector style
Styling Earth Engine vector data based on attributes
Uncomment the following line to install geemap if needed.
In [ ]:
Copied!
# !pip install -U geemap
# !pip install -U geemap
In [ ]:
Copied!
import ee
import geemap
import ee
import geemap
Styling polygons
The US National Wetland Inventory.
In [ ]:
Copied!
Map = geemap.Map(center=[28.00142, -81.7424], zoom=13)
Map.add_basemap("HYBRID")
Map = geemap.Map(center=[28.00142, -81.7424], zoom=13)
Map.add_basemap("HYBRID")
In [ ]:
Copied!
fc = ee.FeatureCollection("projects/sat-io/open-datasets/NWI/wetlands/FL_Wetlands")
fc = ee.FeatureCollection("projects/sat-io/open-datasets/NWI/wetlands/FL_Wetlands")
In [ ]:
Copied!
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]
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]
In [ ]:
Copied!
styled_fc = geemap.ee_vector_style(
fc, column="WETLAND_TY", labels=types, fillColor=fillColor, color="00000000"
)
styled_fc = geemap.ee_vector_style(
fc, column="WETLAND_TY", labels=types, fillColor=fillColor, color="00000000"
)
In [ ]:
Copied!
Map.addLayer(styled_fc, {}, "NWI")
Map.add_legend(title="Wetland Type", labels=types, colors=colors)
Map
Map.addLayer(styled_fc, {}, "NWI")
Map.add_legend(title="Wetland Type", labels=types, colors=colors)
Map
Styling points
In [ ]:
Copied!
fuels = [
"Coal",
"Oil",
"Gas",
"Hydro",
"Nuclear",
"Solar",
"Waste",
"Wind",
"Geothermal",
"Biomass",
]
fuels = [
"Coal",
"Oil",
"Gas",
"Hydro",
"Nuclear",
"Solar",
"Waste",
"Wind",
"Geothermal",
"Biomass",
]
In [ ]:
Copied!
fc = ee.FeatureCollection("WRI/GPPD/power_plants").filter(
ee.Filter.inList("fuel1", fuels)
)
fc = ee.FeatureCollection("WRI/GPPD/power_plants").filter(
ee.Filter.inList("fuel1", fuels)
)
In [ ]:
Copied!
colors = [
"000000",
"593704",
"BC80BD",
"0565A6",
"E31A1C",
"FF7F00",
"6A3D9A",
"5CA2D1",
"FDBF6F",
"229A00",
]
colors = [
"000000",
"593704",
"BC80BD",
"0565A6",
"E31A1C",
"FF7F00",
"6A3D9A",
"5CA2D1",
"FDBF6F",
"229A00",
]
In [ ]:
Copied!
styled_fc = geemap.ee_vector_style(fc, column="fuel1", labels=fuels, color=colors)
styled_fc = geemap.ee_vector_style(fc, column="fuel1", labels=fuels, color=colors)
In [ ]:
Copied!
Map = geemap.Map()
Map.addLayer(styled_fc, {}, "Power Plants")
Map.add_legend(title="Power Plant Fuel Type", labels=fuels, colors=colors)
Map
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.
In [ ]:
Copied!
fc = ee.FeatureCollection("TIGER/2016/Roads")
fc = ee.FeatureCollection("TIGER/2016/Roads")
In [ ]:
Copied!
types = ["I", "U", "S", "M", "C", "O"]
types = ["I", "U", "S", "M", "C", "O"]
In [ ]:
Copied!
labels = ["Interstate", "U.S.", "State recognized", "Common Name", "County", "Other"]
labels = ["Interstate", "U.S.", "State recognized", "Common Name", "County", "Other"]
In [ ]:
Copied!
colors = ["E31A1C", "FF7F00", "6A3D9A", "000000", "FDBF6F", "229A00"]
colors = ["E31A1C", "FF7F00", "6A3D9A", "000000", "FDBF6F", "229A00"]
In [ ]:
Copied!
width = [8, 5, 4, 2, 1, 1]
width = [8, 5, 4, 2, 1, 1]
In [ ]:
Copied!
styled_fc = geemap.ee_vector_style(
fc, column="rttyp", labels=types, color=colors, width=width
)
styled_fc = geemap.ee_vector_style(
fc, column="rttyp", labels=types, color=colors, width=width
)
In [ ]:
Copied!
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
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