63 charts
Chart Overview
Reference: https://developers.google.com/earth-engine/guides/charts_feature#column_chart
In [ ]:
Copied!
import ee
import geemap
import geemap.chart as chart
# from geemap import chart
import ee
import geemap
import geemap.chart as chart
# from geemap import chart
In [ ]:
Copied!
# geemap.update_package()
# geemap.update_package()
Creating a chart from ee.FeatureCollection by feature¶
Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturebyfeature
In [ ]:
Copied!
Map = geemap.Map()
features = ee.FeatureCollection("projects/google/charts_feature_example").select(
"[0-9][0-9]_tmean|label"
)
Map.addLayer(features, {}, "Ecoregions")
Map
Map = geemap.Map()
features = ee.FeatureCollection("projects/google/charts_feature_example").select(
"[0-9][0-9]_tmean|label"
)
Map.addLayer(features, {}, "Ecoregions")
Map
In [ ]:
Copied!
df = geemap.ee_to_df(features)
df
df = geemap.ee_to_df(features)
df
In [ ]:
Copied!
xProperty = "label"
yProperties = [str(x).zfill(2) + "_tmean" for x in range(1, 13)]
labels = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
]
colors = [
"#604791",
"#1d6b99",
"#39a8a7",
"#0f8755",
"#76b349",
"#f0af07",
"#e37d05",
"#cf513e",
"#96356f",
"#724173",
"#9c4f97",
"#696969",
]
title = "Average Monthly Temperature by Ecoregion"
xlabel = "Ecoregion"
ylabel = "Temperature"
xProperty = "label"
yProperties = [str(x).zfill(2) + "_tmean" for x in range(1, 13)]
labels = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
]
colors = [
"#604791",
"#1d6b99",
"#39a8a7",
"#0f8755",
"#76b349",
"#f0af07",
"#e37d05",
"#cf513e",
"#96356f",
"#724173",
"#9c4f97",
"#696969",
]
title = "Average Monthly Temperature by Ecoregion"
xlabel = "Ecoregion"
ylabel = "Temperature"
In [ ]:
Copied!
options = {
"labels": labels,
"colors": colors,
"title": title,
"xlabel": xlabel,
"ylabel": ylabel,
"legend_location": "top-left",
"height": "500px",
}
options = {
"labels": labels,
"colors": colors,
"title": title,
"xlabel": xlabel,
"ylabel": ylabel,
"legend_location": "top-left",
"height": "500px",
}
In [ ]:
Copied!
chart.feature_byFeature(features, xProperty, yProperties, **options)
chart.feature_byFeature(features, xProperty, yProperties, **options)
In [ ]:
Copied!
ecoregions = ee.FeatureCollection("projects/google/charts_feature_example")
normClim = (
ee.ImageCollection("OREGONSTATE/PRISM/Norm81m").toBands().select("[0-9][0-9]_tmean")
)
ecoregions = ee.FeatureCollection("projects/google/charts_feature_example")
normClim = (
ee.ImageCollection("OREGONSTATE/PRISM/Norm81m").toBands().select("[0-9][0-9]_tmean")
)
In [ ]:
Copied!
geemap.ee_to_df(ecoregions)
geemap.ee_to_df(ecoregions)
In [ ]:
Copied!
normClim
normClim
In [ ]:
Copied!
fc = geemap.zonal_stats(
normClim, ecoregions, stat_type="MEAN", scale=500, return_fc=True, verbose=False
)
fc = geemap.zonal_stats(
normClim, ecoregions, stat_type="MEAN", scale=500, return_fc=True, verbose=False
)
In [ ]:
Copied!
geemap.ee_to_df(fc)
geemap.ee_to_df(fc)
Creating a chart from ee.FeatureCollection by property¶
Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturebyproperty
In [ ]:
Copied!
Map = geemap.Map()
features = ee.FeatureCollection("projects/google/charts_feature_example").select(
"[0-9][0-9]_ppt|label"
)
Map.addLayer(features, {}, "Features")
Map
Map = geemap.Map()
features = ee.FeatureCollection("projects/google/charts_feature_example").select(
"[0-9][0-9]_ppt|label"
)
Map.addLayer(features, {}, "Features")
Map
In [ ]:
Copied!
df = geemap.ee_to_df(features)
df
df = geemap.ee_to_df(features)
df
In [ ]:
Copied!
keys = [str(x).zfill(2) + "_ppt" for x in range(1, 13)]
values = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
]
keys = [str(x).zfill(2) + "_ppt" for x in range(1, 13)]
values = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
]
In [ ]:
Copied!
xProperties = dict(zip(keys, values))
seriesProperty = "label"
xProperties = dict(zip(keys, values))
seriesProperty = "label"
In [ ]:
Copied!
options = {
"title": "Average Ecoregion Precipitation by Month",
"colors": ["#f0af07", "#0f8755", "#76b349"],
"xlabel": "Month",
"ylabel": "Precipitation (mm)",
"legend_location": "top-left",
"height": "500px",
}
options = {
"title": "Average Ecoregion Precipitation by Month",
"colors": ["#f0af07", "#0f8755", "#76b349"],
"xlabel": "Month",
"ylabel": "Precipitation (mm)",
"legend_location": "top-left",
"height": "500px",
}
In [ ]:
Copied!
chart.feature_byProperty(features, xProperties, seriesProperty, **options)
chart.feature_byProperty(features, xProperties, seriesProperty, **options)
Creating a chart from ee.FeatureCollection from a group of features¶
Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturegroups
In [ ]:
Copied!
Map = geemap.Map()
features = ee.FeatureCollection("projects/google/charts_feature_example")
xProperty = "label"
yProperty = "01_tmean"
seriesProperty = "warm"
Map = geemap.Map()
features = ee.FeatureCollection("projects/google/charts_feature_example")
xProperty = "label"
yProperty = "01_tmean"
seriesProperty = "warm"
In [ ]:
Copied!
options = {
"title": "Average January Temperature by Ecoregion",
"colors": ["#cf513e", "#1d6b99"],
"xlabel": "Ecoregion",
"ylabel": "Jan temp (C)",
"legend_location": "top-right",
"height": "500px",
"labels": ["Warm", "Cold"],
}
options = {
"title": "Average January Temperature by Ecoregion",
"colors": ["#cf513e", "#1d6b99"],
"xlabel": "Ecoregion",
"ylabel": "Jan temp (C)",
"legend_location": "top-right",
"height": "500px",
"labels": ["Warm", "Cold"],
}
In [ ]:
Copied!
chart.feature_groups(features, xProperty, yProperty, seriesProperty, **options)
chart.feature_groups(features, xProperty, yProperty, seriesProperty, **options)