AnswerBun.com

Make values on some pixels as Null on Google EarthEngine

Geographic Information Systems Asked by Pedro Rincon on December 20, 2020

I have my code as:

function Kelv_Cels(image){
// This function transform Kelvin to Celsius
  var Kelvin = image.select("B6").multiply(0.1).rename('Temp_Celsius');
  var Celsius = Kelvin.subtract(273.15);

  return image.addBands(Celsius);
}

var start = 2007;
var end = 2008;
var landsat7_SR = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR")
                  .filterMetadata('WRS_PATH', 'equals', 29)
                  .filterMetadata('WRS_ROW', 'equals', 47)
                  .filterMetadata('CLOUD_COVER', 'less_than',30)
                  .filterDate(start+'-01-01',end +'-12-31')
                  .map(addNDVI)
                  .map(Kelv_Cels)
                  .map(Clip_state);
print(landsat7_SR);

var chart_max = ui.Chart.image.seriesByRegion(
  landsat7_SR,clinic_shp, ee.Reducer.max() , "Temp_Celsius", 30, 'system:time_start', 'layer')
  .setChartType('ScatterChart')
  .setOptions({
          title: 'Max temperature over time in clinics of State of Colima, Mexico',
          vAxis: {title: 'Temperature (Celsius)'},
          lineWidth: 1,
          pointSize: 4,
          series: {
            0: {color:  '7B241C'}, 
            1: {color:  '76448A'}, 
            2: {color:  '1A5276'},  
            3: {color:  '117864'},
            4: {color:  '239B56'},
            5: {color:  '9A7D0A'},
            6: {color:  '873600'},
            7: {color:  'B3B6B7'},
            8: {color:  '5F6A6A'},
            9: {color:  'EC7063'},
            10: {color: 'A569BD'},
            11: {color: '16A085'}

}});

print(chart_max)

Clip_state is a vector of my state.
And what i want is to extract the stadistics of each region, but as you can see in the attached image.
But some pixels have invalid data, and i use this code to try to fix this data.

function correc_image(image_0){
  var image = image_0.select('Temp_Celsius');
  var percentile = image.reduceRegion(ee.Reducer.percentile([25,75]),Colima_shp );

  var Q3 = percentile.get('Temp_Celsius_p75').getInfo();
  var Q1 = percentile.get('Temp_Celsius_p25').getInfo();
  var IQR = Q3 - Q1;

  var LV = Q1 - 1.5*(IQR);
  var HV = Q3 + 1.5*(IQR);

  var HV_image = image.lt(HV);
  var LV_image = image.gt(LV);

  var image1 = image.multiply(HV_image).multiply(LV_image).rename('Temp_filtrada');

  return image_0.addBands(image1);
}
landsat7_SR = landsat7_SR.map(correc_image);

And i works on a sigle image, but when I use it in a collection it gives me the error.

ImageCollection (Error)
Parameter 'value' is required.

Did you what can I do to solve this problem?
enter image description here]1

One Answer

you cannot use client-side functions in a server-side mapping. Read this. Reworking your function to server-side should work:

function correc_image(image_0){
  var image = image_0.select('Temp_Celsius');
  var percentile = image.reduceRegion(ee.Reducer.percentile([25,75]),geometry );

  var Q3 = percentile.getNumber('Temp_Celsius_p75'); // 
  var Q1 = percentile.getNumber('Temp_Celsius_p25');
  var IQR = Q3.subtract(Q1);

  var LV = Q1.subtract(1.5).multiply(IQR);
  var HV = Q3.add(1.5).multiply(IQR);

  var HV_image = image.lt(ee.Image(HV));
  var LV_image = image.gt(ee.Image(LV));

  var image1 = image.multiply(HV_image).multiply(LV_image).rename('Temp_filtrada');

  return image_0.addBands(image1);
}

Answered by Kuik on December 20, 2020

Add your own answers!

Related Questions

PyQGIS output to specific layer

1  Asked on May 17, 2021

     

Identify U curves in route

0  Asked on May 17, 2021 by pablo-pardo

         

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir