SoilWatch / soil-erosion-watch

GEE App to explore the state of the world's (degraded) soils
MIT License
56 stars 22 forks source link

Using soil-erosion-watch in GEE code #4

Closed ThomasOnfroy closed 2 years ago

ThomasOnfroy commented 2 years ago

Hello William,

I found your soil-erosion-watch app really interesting. I´m currently working on a project related to flood modeling and risk of soils erosivity after overflowing and runoff events in France. I tested the soil-erosion-watch app and looked at the amazing results for some places in France and in other countries.

I wanted an export of the results (the outputs layers) in raster data, so i tried to launch your app directly in GEE code. I have some errors displayed below, do you knoy why ? GEE_code_tested

Soil Erosion Hazard (A, t.ha-1.year-1): Layer error: Image.load: Image asset 'users/soilwatch/GlobalRainfallErosivity2010' not found. and Line 174: Image.load: Image asset 'users/soilwatch/GlobalRainfallErosivity2010' not found.

Finally, is there a way to extract in GEE code the soil-erosion-watch results in raster data from the code you provided in Github (i.e rasters in .tiff or .ascii )?

Or maybe directly from your app (i didn´t find the fonctionnality yet) ?

Best regards,

Thomas

wouellette commented 2 years ago

Hi Thomas,

Glad you found the app useful!

Regarding the error you observed, it should now be fixed (I had forgotten to make the dataset public).

To export the data to geotiff, if you go to line 500 of the source code app.js, you have the following two code blocks:

Here is a link to the official google documentation to exporting data, if you need further clarifications: https://developers.google.com/earth-engine/guides/exporting

ThomasOnfroy commented 2 years ago

NiHello William,

Thanks a lot for your answers. Works great, I tried the .geotiff export of the "A" layer for a french department (Oise, north of Paris). I assume the "A" layer in . geotiff ouput is the Annual Mean Erosivity from RUSLE approach and computation of the datasets requested in the code. The displayed RGB data in ArcGIS shows data unities from 5 to approximatly 237 for the "Oise" department in france. Do i need to divide the data by 1000 to have the results of soil loss in t.ha per year or i leave it like that? I'm looking forward to export other departments (indeed for my study l'll need all the 96 french departments 😀)

Have a nice day,

Thomas

wouellette commented 2 years ago

Hi Thomas,

I ran the tool to export the soil erosion map with the following parameters: image

And I get data ranging from 0.0001 to 127 t/ha/yr.

image

You do not need to rescale the data, it should be in t/ha/yr already. I highly doubt your bottom bracket value would be as high as 5 t/ha/yr. Which parameters did you use? I recommend to run the analysis on a full 12-month time period so you get all seasonal conditions represented, with the full fraction of green vegetation integral calculated. Of course, 2021 is not over yet, but you could always run it for the full 2020.

Cheers,

William

ThomasOnfroy commented 2 years ago

Hello William,

Yes, my mistake for the unities. I had a quick view in ArcGIS monday, i may had a classification error when i loaded it last time. In the meantime, i ran all the country regions this last days in GEE (at 30 m resolution that is enough good for the study i'm working on). I'll agregate the results of the layer "A" this weekend (currently in holidays with no decent PC to look at the .geotiff's and no GIS arround..;)).

I'll not forget to mention SoilWatch work and yours in the results presentation.

Thanks again for the great dataset!

Best regards,

Thomas

mdtb2302 commented 2 years ago

Hello William!

I found your Soil Erosion Watch app super interesting, nice and useful!!! Thanks for the contribution.

I was wondering to create a GEE script, much simpler than the one you produced in your app where the only output the script produces is the Annual Soil Loss Rate (A).

I have a doubt regarding the _var daterange, used to filterDate the _var maskedcollection. If I define a date_range of one year (e.g. 2021-01-01 / 2021-12-31), does this mean that the value of each pixel of the final output will show the Annual Soil Loss Rate of that specific year? Instead, if I use a longer date_range (e.g. 2019-01-01 / 2021-12-31), will the final output show the Annual Soil Loss Rate for that period? To sum up, is the date_range the variable defining the time frame of the output?

Cheers,

Javi

wouellette commented 2 years ago

date_range determines the time period for which to retrive the Sentinel-2 time series. Within that date_range, temporal aggregation is performed to harmonize the time series to monthly composites. Therefore, if you increase the soil erosion for the period 01-01-2019 - 12-31-2021, it will generate 36 monthly composites (12 per year) and use that as your epoch to compute the Annual Soil Loss Rate. If you want A to be representative of multiple years, you could do it that way.

mdtb2302 commented 2 years ago

Hi William,

I was playing around with the amazing app you developed and I found some "strange artefacts" when plotting data in the map interface (see picture below):

image

Do you know why pixels have this kind of frame?

Thanks!

Javi

wouellette commented 2 years ago

Hi Javi,

You can simply fix that issue by reprojecting the data: var A_layer = ui.Map.Layer(A.reproject({scale:10, crs:'EPSG:4326'}), viz_A, 'Soil Erosion Hazard (A, t.ha-1.year-1)');

Bear in mind that the .reproject() call removes the multi-scale overviews that GEE produces at lower zoom levels,which means the data can only be visualized at higher zoom levels (i.e. up close). It is just a visual artifact, but if you export the data to Geotiff, this artefact goes away as the data gets automatically resampled for storage in geotiff format at the scale you specify in the export function (scale of 10m would be optimal in this case as Sentinel-2 data is used).

An example of how it looks like before and after reprojection: image

image

mdtb2302 commented 2 years ago

That's great!

Many thanks

Javi


De: William Ouellette @.> Enviado: martes, 8 de febrero de 2022 20:04 Para: SoilWatch/soil-erosion-watch @.> Cc: mdtb2302 @.>; Comment @.> Asunto: Re: [SoilWatch/soil-erosion-watch] Using soil-erosion-watch in GEE code (Issue #4)

Hi Javi,

You can simply fix that issue by reprojecting the data: var A_layer = ui.Map.Layer(A.reproject({scale:10, crs:'EPSG:4326'}), viz_A, 'Soil Erosion Hazard (A, t.ha-1.year-1)');

Bear in mind that the .reproject() call removes the multi-scale overviews that GEE produces at lower zoom levels,which means the data can only be visualized at higher zoom levels (i.e. up close). It is just a visual artifact, but if you export the data to Geotiff, this artefact goes away as the data gets automatically resampled for storage in geotiff format at the scale you specify in the export function (scale of 10m would be optimal in this case as Sentinel-2 data is used).

An example of how it looks like before and after reprojection: [image]https://user-images.githubusercontent.com/20474036/153057234-9446c075-eb41-4571-9b19-69d4d5f4232e.png

[image]https://user-images.githubusercontent.com/20474036/153057324-13b00ce3-32cd-44e9-bf16-9d95b2d5eec7.png

— Reply to this email directly, view it on GitHubhttps://github.com/SoilWatch/soil-erosion-watch/issues/4#issuecomment-1032959450, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AXIV37K3O6BRFIIBZH3EVKTU2FSKFANCNFSM5I5F6BVQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***>