spatialthoughts / courses

Code and HTML page repository for courses.spatialthoughts.com
56 stars 18 forks source link

Creating Publication Quality Charts with GEE (Full Course Material) #119

Closed utterances-bot closed 9 months ago

utterances-bot commented 9 months ago

Creating Publication Quality Charts with GEE (Full Course Material)

https://courses.spatialthoughts.com/gee-charts.html

abhinav2828 commented 9 months ago

code for 1.3 Time-Series at Multiple Locations is not working. Please check.

spatialthoughts commented 9 months ago

Thank for flagging this. Sometimes there is an ingestion delay and images take more than the 10-hour time specified in the script. Adjust the threshold and it will work. Updated the script with the note https://code.earthengine.google.co.in/0db7034b581b604a29b8359e6d37356b

antsofia commented 2 months ago

Hi, I wonder how to force ui.Chart.image.doySeriesByYear to start with the first year in a collection and continue chronologically? When I plot my data, the first year in the legend is the year with the first available value in the year. Like in your plot that would be the year 2020. But your legend seems to be ok with the chronological order. Thank you!

spatialthoughts commented 2 months ago

@antsofia Hmm. The legend is sorted alphabetically so I expect it to work. Can you share a small reproducible code example (Using Get Link button) that shows this problem? I can take a look and suggest what can be done. If you can't share publicly here, email me at ujaval@spatialthoughts.com

antsofia commented 2 months ago

hi Ujaval, thanks for responding! Here is the code: https://code.earthengine.google.com/9500961b0c96dbcf893627e7eafd5397

as you see, the legend starts with 2020 because in this year the first image was taken on Jan, 3rd (DOY 2), which is the earliest for the collection. Next is the year 2017 with the first image taken on DOY 6. And so on. The problem is not only the legend but also the color assignment - I would like to use a gradient of colors for the series of years. Right now my solution is to add dummy images for the DOY 2 (to match 2020) for each year and then to use limit for x axis to hide this dummy values. But this seems to be kind of an ugly solution to me :)

Thank you! Sofia

spatialthoughts commented 2 months ago

@antsofia You are right, the legend is sorted based on which DOY appears first. A slightly better solution is to extract the values and create a featurecollection and add a dummy feature for the DOY 1 for each year. https://code.earthengine.google.com/1bf108b1241835b2dacbdef629e58342

You can set the colors for each line using series option (series numbering starts from 0). See example at https://courses.spatialthoughts.com/gee-charts.html#simple-time-series