## // Import boundaries from asset ## var aoi = ee.FeatureCollection('users/juliusadewopo/MzeTargetRegion_alt_dslv2'); ## ## // Set map center to the aoi for making sure we have the correct study area ## Map.centerObject(aoi, 11) ## ## // Define period of analysis ## var start = '2018-07-01'; ## var end = '2018-10-31'; ## ## var season = ee.Filter.date(start,end); ## print(season); ## // Import Sentinel-1 collection ## var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD'); ## ## ## // Filter Sentinel-1 collection for study area, date ranges and polarization components ## var sCollection = sentinel1 ## //filter by aoi and time ## .filterBounds(aoi) ## .filter(season) ## // Filter to get images with VV and VH dual polarization ## .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV')) ## .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH')) ## // Filter to get images collected in interferometric wide swath mode. ## .filter(ee.Filter.eq('instrumentMode', 'IW')); ## ## // Also filter based on the orbit: descending or ascending mode ## var desc = sCollection.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING')); ## var asc = sCollection.filter(ee.Filter.eq('orbitProperties_pass', 'ASCENDING')); ## ## // Inspect number of tiles returned after the search; we will use the one with more tiles ## print("descending tiles ",desc.size()); ## print("ascending tiles ",asc.size()); ## ## // Also Inspect one file ## print(asc.first()); ## // Create a composite from means at different polarizations and look angles. ## var composite = ee.Image.cat([ ## asc.select('VH').mean(), ## asc.select('VV').mean(), ## desc.select('VH').mean() ## ]).focal_median(); ## ## // Display as a composite of polarization and backscattering characteristics. ## Map.addLayer(composite, {min: [-25, -20, -25], max: [0, 10, 0]}, 'composite'); ## ## var collection = ee.ImageCollection(asc.select('VV').merge(desc.select('VV'))) ## ## // Mean ## var mean = collection.reduce(ee.Reducer.mean()); ## ## //alternate: var mean = collection.mean(); ## ## // Median ## var med = collection.reduce(ee.Reducer.median()); ## ## //alternate: var med = collection.median(); ## ## // Standard Deviation ## var sd = collection.reduce(ee.Reducer.stdDev()); ## ## // Percentile ## // Lower values---possibily wet ## var p10 = collection.reduce(ee.Reducer.percentile([10])); ## // Higher values---possibily dry/bright ## var p90 = collection.reduce(ee.Reducer.percentile([90])); ## ## // compute difference of p90 and p10 ## ## var nd_diff = p90.subtract(p10).focal_mean(); ## // Plot the difference layer to use with inspector ## Map.addLayer(nd_diff, {}, 'diff', false); ## ## // Threshold difference value from the inspector from some known location ## var th = 7; // Selecting this value is tricky; ## ## var crop_mask = nd_diff.gt(th); ## var crop = crop_mask.updateMask(crop_mask); ## ## var cropViz = {palette:"yellow"}; ## Map.addLayer(crop, cropViz, 'Potential crop areas'); ## ## //Focus on some speific plot ## var point = ee.Geometry.Point([37.340164603171615, -0.720778037819623]); ## Map.centerObject(point, 13) ## ## ## var CRS = 'EPSG:4326'; // Only if you want export in specific reference system ## ## Export.image.toDrive({ ## image: crop, ## description: 'exporting-crop-to-drive', ## fileNamePrefix: 'rcmrd_crop', ## folder: 'GEE_export', // Name of the Google Drive folder ## scale: 10, ## region: aoi , ## maxPixels: 1e13, ## crs: CRS ## }); ## ## ## // Export the image to an Earth Engine asset. ## ## Export.image.toAsset({ ## image: crop, ## description: 'exporting-crop-to-Assest', ## assetId: 'users/anighosh/rcmrd/crop', ## scale: 10, ## region: aoi, ## pyramidingPolicy: { ## '.default': 'sample', ## }, ## maxPixels: 1e13 ## }); ## ## ## // add slider to interactively select rice area ## ## // try Otsu filter to find the threhold ## ## // Include Sentinel-2 ndvi ## ## // Show time series plots ##