Skip to main content
naming
Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

How to calculate area based on a certain value range in google earth engineGoogle Earth Engine?

added 242 characters in body
Source Link
Lana
  • 27
  • 6

So i'mI'm trying to calculate the area with certain color, which those colors are representing certain range of value.

here'sHere's the map

i'mI'm trying to calculate the area of eachthe color black (each range of valuevalue 80.316-97.974), here's the code but itbelow doesn't work how it's supposed to, my guess is because the actual areainstead of polygon for the island itself is about 138.000 km sqgeometry, and the result is way bigger than that. these lines are supposed to calculate the area with the color blackit's a feature collection (value 80.316-97.974which is kinda doubtful because the shapefile itself is basically a collection of polygons).

Yes, the code runs and it got a result, but the actual area of the island itself is about 138.000 km sq, and the result is way bigger than that. So, any idea on solving the problem? (Anyway shout out to Solved Scholar on Youtube for the code)

So i'm trying to calculate the area with certain color, which those colors are representing certain range of value.

here's the map

i'm trying to calculate the area of each color (each range of value), here's the code but it doesn't work, because the actual area of the island itself is about 138.000 km sq, and the result is way bigger than that. these lines are supposed to calculate the area with the color black (value 80.316-97.974)

So I'm trying to calculate the area with certain color, which those colors are representing certain range of value.

Here's the map

I'm trying to calculate the area of the color black (value 80.316-97.974), the code below doesn't work how it's supposed to, my guess is because instead of polygon for the geometry, it's a feature collection (which is kinda doubtful because the shapefile itself is basically a collection of polygons).

Yes, the code runs and it got a result, but the actual area of the island itself is about 138.000 km sq, and the result is way bigger than that. So, any idea on solving the problem? (Anyway shout out to Solved Scholar on Youtube for the code)

Source Link
Lana
  • 27
  • 6

How to calculate area based on a certain value range in google earth engine?

So i'm trying to calculate the area with certain color, which those colors are representing certain range of value.

here's the map

var indon = ee.FeatureCollection('users/sdwijati/IDN_adm2')
var Sesar = ee.FeatureCollection('users/sdwijati/Sesar_Jawa')
var nama_prov = ['Jawa Barat', 'Jakarta Raya', 'Jawa Tengah',
                  'Jawa Timur', 'Yogyakarta', 'Banten']
var prov = indon.filter(ee.Filter.inList('NAME_1', nama_prov));
var s = ee.Image("OpenLandMap/SOL/SOL_SAND-WFRACTION_USDA-3A1A1A_M/v02")
var savg = s.reduce(ee.Reducer.mean());
var gtsavg = savg.updateMask(savg.gte(45))

var n = ee.Image("OpenLandMap/SOL/SOL_WATERCONTENT-33KPA_USDA-4B1C_M/v01")
var navg = n.reduce(ee.Reducer.mean())

var xx = gtsavg.add(navg)

var sesar = Sesar
var bufferBy = function(size) {
  return function(feature) {
    return feature.buffer(size);   
  };
};

var intervals =
  '<RasterSymbolizer>' +
    '<ColorMap type="intervals" extended="false" >' +
      '<ColorMapEntry color="#0CE84A" quantity="45" label="40" />' +
      '<ColorMapEntry color="#FFF300" quantity="62.658" label="62.658" />' +
      '<ColorMapEntry color="#FF1500" quantity="80.316" label="80.316" />' +
      '<ColorMapEntry color="#000000" quantity="97.974" label="97.974" />' +
    '</ColorMap>' +
  '</RasterSymbolizer>';

var sarbuff = sesar.map(bufferBy(25000*4))
Map.addLayer(xx.sldStyle(intervals).clipToCollection(sarbuff).clip(prov));
Map.centerObject(prov, 7)

i'm trying to calculate the area of each color (each range of value), here's the code but it doesn't work, because the actual area of the island itself is about 138.000 km sq, and the result is way bigger than that. these lines are supposed to calculate the area with the color black (value 80.316-97.974)

var sgttinggi = xx.updateMask(xx.lte(97.974))
var sgttinggi2 = sgttinggi.updateMask(sgttinggi.gt(80.316))
var stinggi = sgttinggi.clipToCollection(sarbuff).clip(prov)

var area_pxa = stinggi.multiply(ee.Image.pixelArea()) 
                    .reduceRegion(ee.Reducer.sum(),prov,250,null,null,false,1e13)
                    .get('mean')
                   
 area_pxa = ee.Number(area_pxa).divide(100000)
  print ('Area Dengan Potensi Kerentanan Sangat Tinggi (km²)', area_pxa)