// Google Earth Engine code for estimating greenspace exposure // Code link: https://code.earthengine.google.com/11189060e7835ef091d66601c97546e6 // load three-level administrative units // county level var block = ee.FeatureCollection("FAO/GAUL/2015/level2") // country level // var block = ee.FeatureCollection("FAO/GAUL/2015/level0") // state level // var block = ee.FeatureCollection("FAO/GAUL/2015/level1") // load 10-m esa worldCover var esa = ee.Image("ESA/WorldCover/v100/2020") // group all forests, shrubs, grasses to vegetation var green = esa.remap([10,20,30,40,50,60,70,80,90,95,100], [1,1,1,0,0,0,0,0,0,0,0]) //tree, shrubs and grass // load worldpop var pop = ee.ImageCollection("WorldPop/GP/100m/pop").filterDate('2020-01-01','2021-01-01').mosaic() // aggregate 10-m greenspace to 100-m worldpop var pop_prj = ee.ImageCollection("WorldPop/GP/100m/pop").filterDate('2020-01-01','2021-01-01').first().projection() var esa_prj = ee.Image("ESA/WorldCover/v100/2020").projection() var green100 = green.reproject(esa_prj).reduceResolution({ reducer: ee.Reducer.mean(), maxPixels: 1024 }) // reproject to worldpop at 100 m .reproject({ crs: pop_prj }); // estimate population weighted greenspace exposure // (1) perfect match population weighted greenspace exposure // 100 m var popgreen = green100.multiply(pop) // (2) different buffered sizes for estimating greenspace exposure // Define a kernel of circle or square // 500 m var kernelcore = ee.Kernel.circle({ radius: 5, units: 'pixels', normalize: true }); // Smooth the image by convolving with the kernel core. var smooth = green100.convolve(kernelcore); var popgreen500m = smooth.multiply(pop) // Define a kernel of circle or square // 1000 m var kernelcore = ee.Kernel.circle({ radius: 10, units: 'pixels', normalize: true }); // Smooth the image by convolving with the kernel core. var smooth = green100.convolve(kernelcore); var popgreen1000m = smooth.multiply(pop) // Define a kernel of circle or square - 2km // 1500 m var kernelcore = ee.Kernel.circle({ radius: 15, units: 'pixels', normalize: true }); // Smooth the image by convolving with the kernel core. var smooth = green100.convolve(kernelcore); var popgreen1500m = smooth.multiply(pop) // statistics // population var popsum = pop.reduceRegions({ collection: block, reducer:ee.Reducer.sum(), scale: 100 }); // drop .geo column var polyOut = popsum.select(['.*'],null,false); // Export Export.table.toDrive({ collection: polyOut, description: 'Population_sum', folder: 'Global_Greenspace_Expo', fileFormat: 'CSV' }); // perfect pixel match 100 m var countygreen = popgreen.reduceRegions({ collection: block, reducer:ee.Reducer.sum(), scale: 100 }); // drop .geo column var polyOut = countygreen.select(['.*'],null,false); // Export Export.table.toDrive({ collection: polyOut, description: '100m_greenspace_exposure', folder: 'Global_Greenspace_Expo', fileFormat: 'CSV' }); // 500m var countygreen500m = popgreen500m.reduceRegions({ collection: block, reducer:ee.Reducer.sum(), scale: 100 }); // drop .geo column var polyOut = countygreen500m.select(['.*'],null,false); // Export Export.table.toDrive({ collection: polyOut, description: '500m_greenspace_exposure', folder: 'Global_Greenspace_Expo', fileFormat: 'CSV' }); // 1km var countygreen1km = popgreen1000m.reduceRegions({ collection: block, reducer:ee.Reducer.sum(), scale: 100 }); // drop .geo column var polyOut = countygreen1km.select(['.*'],null,false); // Export Export.table.toDrive({ collection: polyOut, description: '1000m_greenspace_exposure', folder: 'Global_Greenspace_Expo', fileFormat: 'CSV' }); // 1500 m var countygreen1500m = popgreen1500m.reduceRegions({ collection: block, reducer:ee.Reducer.sum(), scale: 100 }); // drop .geo column var polyOut = countygreen1500m.select(['.*'],null,false); // Export Export.table.toDrive({ collection: polyOut, description: '1500m_greenspace_exposure', folder: 'Global_Greenspace_Expo', fileFormat: 'CSV' });