Chart Overview
Reference: https://developers.google.com/earth-engine/guides/charts_feature#column_chart
import ee
import geemap
import geemap.chart as chart
# from geemap import chart
# geemap.update_package()
Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturebyfeature
Map = geemap.Map()
features = ee.FeatureCollection('projects/google/charts_feature_example').select(
'[0-9][0-9]_tmean|label'
)
Map.addLayer(features, {}, "Ecoregions")
Map
Map(center=[0, 0], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=SearchDataGUI(childr…
df = geemap.ee_to_df(features)
df
01_tmean | 02_tmean | 03_tmean | 04_tmean | 05_tmean | 06_tmean | 07_tmean | 08_tmean | 09_tmean | 10_tmean | 11_tmean | 12_tmean | label | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 5.791036 | 7.645011 | 10.454658 | 14.251640 | 19.032815 | 23.790506 | 25.066577 | 23.845259 | 21.454795 | 15.997988 | 9.849321 | 5.641386 | Desert |
1 | 2.792467 | 3.609074 | 5.032932 | 7.120137 | 10.395376 | 13.776134 | 17.850177 | 17.919983 | 15.206573 | 10.081709 | 4.784706 | 2.317886 | Forest |
2 | -3.756608 | -1.990220 | 2.570146 | 7.721306 | 13.643875 | 19.033558 | 22.753059 | 21.848346 | 16.401770 | 9.263021 | 2.021918 | -3.426706 | Grassland |
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"
options = {
"labels": labels,
"colors": colors,
"title": title,
"xlabel": xlabel,
"ylabel": ylabel,
"legend_location": "top-left",
"height": "500px",
}
chart.feature_byFeature(features, xProperty, yProperties, **options)
VBox(children=(Figure(axes=[Axis(label='Ecoregion', scale=OrdinalScale()), Axis(label='Temperature', orientati…
ecoregions = ee.FeatureCollection('projects/google/charts_feature_example')
normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands().select('[0-9][0-9]_tmean')
geemap.ee_to_df(ecoregions)
01_ppt | 01_tdmean | 01_tmax | 01_tmean | 01_tmin | 01_vpdmax | 01_vpdmin | 02_ppt | 02_tdmean | 02_tmax | ... | 12_ppt | 12_tdmean | 12_tmax | 12_tmean | 12_tmin | 12_vpdmax | 12_vpdmin | label | value | warm | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 27.954341 | -5.938981 | 14.051854 | 5.791036 | -2.469782 | 12.487592 | 1.354838 | 21.858469 | -5.516508 | 16.323491 | ... | 35.557367 | -5.750375 | 13.843468 | 5.641386 | -2.560697 | 12.173214 | 1.272226 | Desert | 0 | 1 |
1 | 235.373540 | -0.696075 | 6.547829 | 2.792467 | -0.962896 | 4.098799 | 0.508449 | 181.531780 | -0.703566 | 8.196231 | ... | 273.243438 | -0.668041 | 5.827072 | 2.317886 | -1.191301 | 3.521696 | 0.480811 | Forest | 1 | 1 |
2 | 9.636893 | -9.243995 | 2.920941 | -3.756608 | -10.434157 | 4.750901 | 0.487785 | 13.915104 | -7.865428 | 4.853363 | ... | 11.198115 | -8.863683 | 3.177410 | -3.426706 | -10.030822 | 5.038356 | 0.488113 | Grassland | 2 | 0 |
3 rows × 87 columns
normClim
fc = geemap.zonal_stats(normClim, ecoregions, stat_type='MEAN', scale=500, return_fc=True, verbose=False)
geemap.ee_to_df(fc)
01_ppt | 01_tdmean | 01_tmax | 01_tmean | 01_tmin | 01_vpdmax | 01_vpdmin | 02_ppt | 02_tdmean | 02_tmax | ... | 12_ppt | 12_tdmean | 12_tmax | 12_tmean | 12_tmin | 12_vpdmax | 12_vpdmin | label | value | warm | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 27.954341 | -5.938981 | 14.051854 | 5.910990 | -2.469782 | 12.487592 | 1.354838 | 21.858469 | -5.516508 | 16.323491 | ... | 35.557367 | -5.750375 | 13.843468 | 5.783772 | -2.560697 | 12.173214 | 1.272226 | Desert | 0 | 1 |
1 | 235.373540 | -0.696075 | 6.547829 | 3.094200 | -0.962896 | 4.098799 | 0.508449 | 181.531780 | -0.703566 | 8.196231 | ... | 273.243438 | -0.668041 | 5.827072 | 2.610459 | -1.191301 | 3.521696 | 0.480811 | Forest | 1 | 1 |
2 | 9.636893 | -9.243995 | 2.920941 | -3.734058 | -10.434157 | 4.750901 | 0.487785 | 13.915104 | -7.865428 | 4.853363 | ... | 11.198115 | -8.863683 | 3.177410 | -3.396242 | -10.030822 | 5.038356 | 0.488113 | Grassland | 2 | 0 |
3 rows × 87 columns
Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturebyproperty
Map = geemap.Map()
features = ee.FeatureCollection('projects/google/charts_feature_example').select(
'[0-9][0-9]_ppt|label'
)
Map.addLayer(features, {}, 'Features')
Map
Map(center=[0, 0], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=SearchDataGUI(childr…
df = geemap.ee_to_df(features)
df
01_ppt | 02_ppt | 03_ppt | 04_ppt | 05_ppt | 06_ppt | 07_ppt | 08_ppt | 09_ppt | 10_ppt | 11_ppt | 12_ppt | label | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 27.954341 | 21.858469 | 17.579124 | 8.252543 | 8.372216 | 14.802123 | 80.389409 | 79.326886 | 37.412247 | 32.728694 | 22.809099 | 35.557367 | Desert |
1 | 235.373540 | 181.531780 | 181.917962 | 150.759019 | 112.392139 | 72.709877 | 23.409216 | 25.395566 | 54.064534 | 121.976155 | 261.008798 | 273.243438 | Forest |
2 | 9.636893 | 13.915104 | 29.761295 | 57.736112 | 84.276450 | 86.136860 | 76.181755 | 60.189630 | 45.833161 | 38.134907 | 20.085923 | 11.198115 | Grassland |
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',
]
xProperties = dict(zip(keys, values))
seriesProperty = "label"
options = {
'title': "Average Ecoregion Precipitation by Month",
'colors': ['#f0af07', '#0f8755', '#76b349'],
'xlabel': "Month",
'ylabel': "Precipitation (mm)",
'legend_location': "top-left",
"height": "500px",
}
chart.feature_byProperty(features, xProperties, seriesProperty, **options)
VBox(children=(Figure(axes=[Axis(label='Month', scale=OrdinalScale()), Axis(label='Precipitation (mm)', orient…
Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturegroups
Map = geemap.Map()
features = ee.FeatureCollection('projects/google/charts_feature_example')
xProperty = 'label'
yProperty = '01_tmean'
seriesProperty = 'warm'
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"],
}
chart.feature_groups(features, xProperty, yProperty, seriesProperty, **options)
VBox(children=(Figure(axes=[Axis(label='Ecoregion', scale=OrdinalScale()), Axis(label='Jan temp (C)', orientat…