From 998969cc5b5e5806c06fbe628e534043690931f3 Mon Sep 17 00:00:00 2001 From: rizayeva <48497511+rizayeva@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:17:55 -0500 Subject: [PATCH] Delete 3. Pixel-based classificationO --- 3. Pixel-based classificationO | 682 --------------------------------- 1 file changed, 682 deletions(-) delete mode 100644 3. Pixel-based classificationO diff --git a/3. Pixel-based classificationO b/3. Pixel-based classificationO deleted file mode 100644 index a703620..0000000 --- a/3. Pixel-based classificationO +++ /dev/null @@ -1,682 +0,0 @@ -/* Author: Afag Rizayeva - Date: 01-17-2022 - Purpose: Ten fold pixel-based classification of Corona data with incorporation of DEM - Inputs: Corona image geometry (study area polygon); - 2 Corona image layers manually imported in GEE; - 2.5m elevation layer; - training data directory; - testing data directory; - - Adjust the input files' directories and palette variable - Run the code - Export the accuracies as csv files and the final classification map -*/ - -var table = ee.FeatureCollection('users/rizayeva/DS10111041'); - -// Set the palette based on number and names of classes -var palette = ['075b0e'/* forest*/, '075b0e'/* forest*/, '075b0e'/* forest*/, 'ebebeb'/* barren*/, '9de64e'/* grass*/, 'e2d544'/* crop*/, 'ff0000'/* urban*/, '3f553c'/* wetland*/, '0033ff'/* lake*/, 'ffffff'/* snow*/, '88cdf6'/* river*/]; - -// Import two Corona images -// Rename the band names for afterward- ('da') and forward-facing ('df') cameras -var image2 = ee.Image('users/rizayeva/corona_2_5m/DS1011-1040DA_2_5m_JPEG_1band_EPSG32638').rename(['ds10111040da']); -var image3 = ee.Image('users/rizayeva/corona_2_5m/DS1011-1040DF_2_5m_JPEG_1band_EPSG32638').rename(['ds10111040df']); -Map.addLayer(image2, {min: 0, max: 200}, 'DS1011-1040DA', false); -Map.addLayer(image3, {min: 0, max: 200}, 'DS1011-1040DF', false); - -// Define and visualize the elevation layers -var elevation = ee.Image('users/rizayeva/elevation').rename('elevation'); -var slope = ee.Terrain.slope(elevation).clip(table); -var aspect = ee.Terrain.aspect(elevation).clip(table); -var aspect = aspect.subtract(30).multiply(Math.PI/180).cos().subtract(1).multiply(-1/2); - -var imageVisParams = {bands: ['elevation'], min: 1, max: 3445, gamma: [1.85], opacity: 1}; -Map.addLayer(elevation, imageVisParams, 'Elevation', false); -Map.addLayer(slope, {}, 'slope', false); -Map.addLayer(aspect, {}, 'aspect', false); - -var MN_DA = image2.reduceNeighborhood({ - reducer: ee.Reducer.mean(), - kernel: ee.Kernel.square(3.5), -}); -var MN_DF = image3.reduceNeighborhood({ - reducer: ee.Reducer.mean(), - kernel: ee.Kernel.square(3.5), -}); -var stdDevDA = image2.reduceNeighborhood({ - reducer: ee.Reducer.stdDev(), - kernel: ee.Kernel.circle(3.5), -}); -var stdDevDF = image3.reduceNeighborhood({ - reducer: ee.Reducer.stdDev(), - kernel: ee.Kernel.circle(3.5), -}); - -// var texture = image2.glcmTexture({size: 4}); -// print(texture); -var ENT_DA = image2.glcmTexture({size: 3/*4*/}).select('ds10111040da_ent');//.resample('bilinear').reproject({crs: image2.projection().getInfo()['crs'], scale: 16.5}); -var ENT_DF = image3.glcmTexture({size: 3/*4*/}).select('ds10111040df_ent');//.resample('bilinear').reproject({crs: image3.projection().getInfo()['crs'], scale: 16.5}); -var COR_DA = image2.glcmTexture({size: 3/*4*/}).select('ds10111040da_corr');//.resample('bilinear').reproject({crs: image2.projection().getInfo()['crs'], scale: 16.5}); -var COR_DF = image3.glcmTexture({size: 3/*4*/}).select('ds10111040df_corr');//.resample('bilinear').reproject({crs: image3.projection().getInfo()['crs'], scale: 16.5}); -var HOM_DA = image2.glcmTexture({size: 3/*4*/}).select('ds10111040da_idm');//.resample('bilinear').reproject({crs: image2.projection().getInfo()['crs'], scale: 16.5}); -var HOM_DF = image3.glcmTexture({size: 3/*4*/}).select('ds10111040df_idm');//.resample('bilinear').reproject({crs: image3.projection().getInfo()['crs'], scale: 16.5}); -var SM_DA = image2.glcmTexture({size: 3/*5*/}).select('ds10111040da_asm');//.resample('bilinear').reproject({crs: image2.projection().getInfo()['crs'], scale: 20.12}); -var SM_DF = image3.glcmTexture({size: 3/*5*/}).select('ds10111040df_asm');//.resample('bilinear').reproject({crs: image3.projection().getInfo()['crs'], scale: 20.12}); -var VAR_DA = image2.glcmTexture({size: 3/*5*/}).select('ds10111040da_var');//.resample('bilinear').reproject({crs: image2.projection().getInfo()['crs'], scale: 20.12}); -var VAR_DF = image3.glcmTexture({size: 3/*5*/}).select('ds10111040df_var');//.resample('bilinear').reproject({crs: image3.projection().getInfo()['crs'], scale: 20.12}); -var DIS_DA = image2.glcmTexture({size: 3/*5*/}).select('ds10111040da_diss');//.resample('bilinear').reproject({crs: image2.projection().getInfo()['crs'], scale: 20.12}); -var DIS_DF = image3.glcmTexture({size: 3/*5*/}).select('ds10111040df_diss');//.resample('bilinear').reproject({crs: image3.projection().getInfo()['crs'], scale: 20.12}); -Map.addLayer(MN_DA, {}, 'MN_DA', false); -Map.addLayer(MN_DF, {}, 'MN_DF', false); -Map.addLayer(ENT_DA, {}, 'ENT_DA', false); -Map.addLayer(ENT_DF, {}, 'ENT_DF', false); -Map.addLayer(SM_DA, {}, 'SM_DA', false); -Map.addLayer(SM_DF, {}, 'SM_DF', false); -Map.addLayer(COR_DA, {}, 'COR_DA', false); -Map.addLayer(COR_DF, {}, 'COR_DF', false); -Map.addLayer(HOM_DA, {}, 'HOM_DA', false); -Map.addLayer(HOM_DF, {}, 'HOM_DF', false); -Map.addLayer(VAR_DA, {}, 'VAR_DA', false); -Map.addLayer(VAR_DF, {}, 'VAR_DF', false); -Map.addLayer(DIS_DA, {}, 'DIS_DA', false); -Map.addLayer(DIS_DF, {}, 'DIS_DF', false); - -// Map asset directory that contains all Training and Testing data -var assetIdTR='users/rizayeva/Training_Testing/Training10111040'; -var assetIdTE='users/rizayeva/Training_Testing/Testing10111040'; - -// Make a list that contains all the point data in the asset directory -var assetListTR = ee.List(ee.data.getList({'id':assetIdTR})); -var assetListTE = ee.List(ee.data.getList({'id':assetIdTE})); -print('Training data', assetListTR); -print('Testing data', assetListTE); -// Define the number of datasets -var n = assetListTR.size().getInfo(); - -///////////// Classification -///////////// ///////////// ///////////// ///////////// ///////////// 5 TEX no DEM -// Concatenate all layers into one -var pixelPropertiesImage = ee.Image.cat([ - MN_DA, - MN_DF, - stdDevDA, - stdDevDF, - ENT_DA, - ENT_DF, - HOM_DA, - HOM_DF, - SM_DA, - SM_DF - ]).float(); -// print (pixelPropertiesImage); -var bandNames = pixelPropertiesImage.bandNames(); -print('pixelPropertiesImage bandNames with 5 textures no DEM', bandNames); -var bandss = ['ds10111040da_mean', 'ds10111040df_mean', 'ds10111040da_stdDev', 'ds10111040df_stdDev', 'ds10111040da_asm', 'ds10111040df_asm', 'ds10111040da_ent', 'ds10111040df_ent', 'ds10111040da_idm', 'ds10111040df_idm']; - -// Generate an empty Image Collection to later add each of the 10 classification results - var classification = ee.ImageCollection([]); -// Generate an empty list to later add each of the overall accuracies to be averaged - var overallAccuracy = ee.List([]); -// Build a for loop to run a Random Forest classifier using one set of the training and testing data each time - for (var i=0; i