144 chart features
In [ ]:
Copied!
# %pip install -U geemap
# %pip install -U geemap
Import libraries¶
In [ ]:
Copied!
import calendar
import ee
import geemap
from geemap import chart
import calendar
import ee
import geemap
from geemap import chart
In [ ]:
Copied!
geemap.ee_initialize()
geemap.ee_initialize()
feature_by_feature¶
Features are plotted along the x-axis, labeled by values of a selected property. Series are represented by adjacent columns defined by a list of property names whose values are plotted along the y-axis.
In [ ]:
Copied!
ecoregions = ee.FeatureCollection("projects/google/charts_feature_example")
features = ecoregions.select("[0-9][0-9]_tmean|label")
ecoregions = ee.FeatureCollection("projects/google/charts_feature_example")
features = ecoregions.select("[0-9][0-9]_tmean|label")
In [ ]:
Copied!
geemap.ee_to_df(features)
geemap.ee_to_df(features)
In [ ]:
Copied!
x_property = "label"
y_properties = [str(x).zfill(2) + "_tmean" for x in range(1, 13)]
labels = calendar.month_abbr[1:] # a list of month labels, e.g. ['Jan', 'Feb', ...]
colors = [
"#604791",
"#1d6b99",
"#39a8a7",
"#0f8755",
"#76b349",
"#f0af07",
"#e37d05",
"#cf513e",
"#96356f",
"#724173",
"#9c4f97",
"#696969",
]
title = "Average Monthly Temperature by Ecoregion"
x_label = "Ecoregion"
y_label = "Temperature"
x_property = "label"
y_properties = [str(x).zfill(2) + "_tmean" for x in range(1, 13)]
labels = calendar.month_abbr[1:] # a list of month labels, e.g. ['Jan', 'Feb', ...]
colors = [
"#604791",
"#1d6b99",
"#39a8a7",
"#0f8755",
"#76b349",
"#f0af07",
"#e37d05",
"#cf513e",
"#96356f",
"#724173",
"#9c4f97",
"#696969",
]
title = "Average Monthly Temperature by Ecoregion"
x_label = "Ecoregion"
y_label = "Temperature"
In [ ]:
Copied!
fig = chart.feature_by_feature(
features,
x_property,
y_properties,
colors=colors,
labels=labels,
title=title,
x_label=x_label,
y_label=y_label,
)
fig
fig = chart.feature_by_feature(
features,
x_property,
y_properties,
colors=colors,
labels=labels,
title=title,
x_label=x_label,
y_label=y_label,
)
fig
feature.by_property¶
In [ ]:
Copied!
ecoregions = ee.FeatureCollection("projects/google/charts_feature_example")
features = ecoregions.select("[0-9][0-9]_ppt|label")
ecoregions = ee.FeatureCollection("projects/google/charts_feature_example")
features = ecoregions.select("[0-9][0-9]_ppt|label")
In [ ]:
Copied!
geemap.ee_to_df(features)
geemap.ee_to_df(features)
In [ ]:
Copied!
keys = [str(x).zfill(2) + "_ppt" for x in range(1, 13)]
values = calendar.month_abbr[1:] # a list of month labels, e.g. ['Jan', 'Feb', ...]
keys = [str(x).zfill(2) + "_ppt" for x in range(1, 13)]
values = calendar.month_abbr[1:] # a list of month labels, e.g. ['Jan', 'Feb', ...]
In [ ]:
Copied!
x_properties = dict(zip(keys, values))
series_property = "label"
title = "Average Ecoregion Precipitation by Month"
colors = ["#f0af07", "#0f8755", "#76b349"]
x_properties = dict(zip(keys, values))
series_property = "label"
title = "Average Ecoregion Precipitation by Month"
colors = ["#f0af07", "#0f8755", "#76b349"]
In [ ]:
Copied!
fig = chart.feature_by_property(
features,
x_properties,
series_property,
title=title,
colors=colors,
x_label="Month",
y_label="Precipitation (mm)",
legend_location="top-left",
)
fig
fig = chart.feature_by_property(
features,
x_properties,
series_property,
title=title,
colors=colors,
x_label="Month",
y_label="Precipitation (mm)",
legend_location="top-left",
)
fig
feature_groups¶
In [ ]:
Copied!
ecoregions = ee.FeatureCollection("projects/google/charts_feature_example")
features = ecoregions.select("[0-9][0-9]_ppt|label")
ecoregions = ee.FeatureCollection("projects/google/charts_feature_example")
features = ecoregions.select("[0-9][0-9]_ppt|label")
In [ ]:
Copied!
features = ee.FeatureCollection("projects/google/charts_feature_example")
x_property = "label"
y_property = "01_tmean"
series_property = "warm"
title = "Average January Temperature by Ecoregion"
colors = ["#cf513e", "#1d6b99"]
labels = ["Warm", "Cold"]
features = ee.FeatureCollection("projects/google/charts_feature_example")
x_property = "label"
y_property = "01_tmean"
series_property = "warm"
title = "Average January Temperature by Ecoregion"
colors = ["#cf513e", "#1d6b99"]
labels = ["Warm", "Cold"]
In [ ]:
Copied!
chart.feature_groups(
features,
x_property,
y_property,
series_property,
title=title,
colors=colors,
x_label="Ecoregion",
y_label="January Temperature (°C)",
legend_location="top-right",
labels=labels,
)
chart.feature_groups(
features,
x_property,
y_property,
series_property,
title=title,
colors=colors,
x_label="Ecoregion",
y_label="January Temperature (°C)",
legend_location="top-right",
labels=labels,
)
feature_histogram¶
In [ ]:
Copied!
source = ee.ImageCollection("OREGONSTATE/PRISM/Norm91m").toBands()
region = ee.Geometry.Rectangle(-123.41, 40.43, -116.38, 45.14)
features = source.sample(region, 5000)
source = ee.ImageCollection("OREGONSTATE/PRISM/Norm91m").toBands()
region = ee.Geometry.Rectangle(-123.41, 40.43, -116.38, 45.14)
features = source.sample(region, 5000)
In [ ]:
Copied!
geemap.ee_to_df(features.limit(5).select(["07_ppt"]))
geemap.ee_to_df(features.limit(5).select(["07_ppt"]))
In [ ]:
Copied!
property = "07_ppt"
title = "July Precipitation Distribution for NW USA"
property = "07_ppt"
title = "July Precipitation Distribution for NW USA"
In [ ]:
Copied!
fig = chart.feature_histogram(
features,
property,
max_buckets=None,
title=title,
x_label="Precipitation (mm)",
y_label="Pixel Count",
colors=["#1d6b99"],
)
fig
fig = chart.feature_histogram(
features,
property,
max_buckets=None,
title=title,
x_label="Precipitation (mm)",
y_label="Pixel Count",
colors=["#1d6b99"],
)
fig