Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
Get image statistic table on Google Earth Engine

I would like to have a look at my raster statistics, similar to freq(raster) in R, but in Google Earth Engine. I would like to know which pixel value appears how often (it is a classified raster). I can't seem to find the right ee function for this. Can anyone help?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

These kind of statistics may require or NOT a region over which things are be computed depending on whether you are dealing with a bounded or an unbounded image. So, let's have a region of interest first:

var region = 
    /* color: #98ff00 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[-111.4018515625, 42.568784561631375],
          [-111.4018515625, 35.47803445034791],
          [-91.62646093750003, 35.47803445034791],
          [-91.62646093750003, 42.568784561631375]]], null, false);

Now, we can load a classified image. Let's assume the IGBP classification since you mentioned a classified image and you didn't provide any:

var image = ee.Image('MODIS/051/MCD12Q1/2012_01_01')
  .select('Land_Cover_Type_1');

If you want the frequencies as raw values, you can reduce the classified image as follows:

var freq = image.reduceRegion({
  reducer: ee.Reducer.frequencyHistogram(),
  geometry: region,
  scale: 100
});

print(freq);

If you want a chart, you can use ui.Chart.image.histogram as follows:

var chart  = ui.Chart.image.histogram({
  image: image, 
  region: region, 
  scale: 100
});

print(chart)

Link to code

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!