63 charts
Chart Overview
Reference: https://developers.google.com/earth-engine/guides/charts_feature#column_chart
In [1]:
Copied!
import ee
import geemap
import geemap.chart as chart
import ee
import geemap
import geemap.chart as chart
In [2]:
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 [3]:
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
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [4]:
Copied!
df = geemap.ee_to_pandas(features)
df
df = geemap.ee_to_pandas(features)
df
Out[4]:
01_tmean | 07_tmean | 08_tmean | 11_tmean | 05_tmean | label | 09_tmean | 10_tmean | 04_tmean | 03_tmean | 12_tmean | 06_tmean | 02_tmean | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 5.791036 | 25.066577 | 23.845259 | 9.849321 | 19.032815 | Desert | 21.454795 | 15.997988 | 14.251640 | 10.454658 | 5.641386 | 23.790506 | 7.645011 |
1 | 2.792467 | 17.850177 | 17.919983 | 4.784706 | 10.395376 | Forest | 15.206573 | 10.081709 | 7.120137 | 5.032932 | 2.317886 | 13.776134 | 3.609074 |
2 | -3.756608 | 22.753059 | 21.848346 | 2.021918 | 13.643875 | Grassland | 16.401770 | 9.263021 | 7.721306 | 2.570146 | -3.426706 | 19.033558 | -1.990220 |
In [5]:
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 [6]:
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 [7]:
Copied!
chart.feature_byFeature(features, xProperty, yProperties, **options)
chart.feature_byFeature(features, xProperty, yProperties, **options)
Creating a chart from ee.FeatureCollection by property¶
Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturebyproperty
In [8]:
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
Out[8]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [9]:
Copied!
df = geemap.ee_to_pandas(features)
df
df = geemap.ee_to_pandas(features)
df
Out[9]:
07_ppt | 02_ppt | 09_ppt | 11_ppt | 04_ppt | label | 01_ppt | 06_ppt | 08_ppt | 05_ppt | 10_ppt | 03_ppt | 12_ppt | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 80.389409 | 21.858469 | 37.412247 | 22.809099 | 8.252543 | Desert | 27.954341 | 14.802123 | 79.326886 | 8.372216 | 32.728694 | 17.579124 | 35.557367 |
1 | 23.409216 | 181.531780 | 54.064534 | 261.008798 | 150.759019 | Forest | 235.373540 | 72.709877 | 25.395566 | 112.392139 | 121.976155 | 181.917962 | 273.243438 |
2 | 76.181755 | 13.915104 | 45.833161 | 20.085923 | 57.736112 | Grassland | 9.636893 | 86.136860 | 60.189630 | 84.276450 | 38.134907 | 29.761295 | 11.198115 |
In [10]:
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 [11]:
Copied!
xProperties = dict(zip(keys, values))
seriesProperty = "label"
xProperties = dict(zip(keys, values))
seriesProperty = "label"
In [12]:
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 [13]:
Copied!
chart.feature_byProperty(features, xProperties, seriesProperty, **options)
chart.feature_byProperty(features, xProperties, seriesProperty, **options)
Last update:
2022-03-14