Get pixel values from a raster using a multipartpolygonHow to extract all pixel values in a raster filePixel...

How much cash can I safely carry into the USA and avoid civil forfeiture?

How can I get rid of an unhelpful parallel branch when unpivoting a single row?

How can I practically buy stocks?

Restricting the options of a lookup field, based on the value of another lookup field?

Israeli soda type drink

Find a stone which is not the lightest one

std::unique_ptr of base class holding reference of derived class does not show warning in gcc compiler while naked pointer shows it. Why?

Extracting Dirichlet series coefficients

Multiple fireplaces in an apartment building?

Co-worker works way more than he should

Was Dennis Ritchie being too modest in this quote about C and Pascal?

Check if a string is entirely made of the same substring

Is Diceware more secure than a long passphrase?

Magical attacks and overcoming damage resistance

Combinatorics problem, right solution?

Why must Chinese maps be obfuscated?

Multiple options vs single option UI

Is there a better way to say "see someone's dreams"?

Do I need to watch Ant-Man and the Wasp and Captain Marvel before watching Avengers: Endgame?

Unknown code in script

Is there really no use for MD5 anymore?

How to pronounce 'c++' in Spanish

A faster way to compute the largest prime factor

What is the unit of time_lock_delta in LND?



Get pixel values from a raster using a multipartpolygon


How to extract all pixel values in a raster filePixel values change after clipping a raster layerhow to get every images's pixel values of “ImageCollection” in GEEGEE cloud-free Sentinel2 and linear RegressionWrong Min and Max Pixel valuesHow to apply a Cloud Mask in Google Earth Engine? (Landsat 5 TM 8-Day NDVI Composite)How do you return a set of unique pixel values in a raster with pyqgis?PostGIS: Change raster values depending on values from other rasterGetting all pixel values from raster image in ArcGIS Desktop?Clean up pixel noise from raster in ArcGIS






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I'm trying to get the mean value of pixels from an NDVI raster, that intersect the geometry of a FeatureCollection, that is a multipart polygon which represents my sample area, but I can't find the way.



Here's the code:



 // Load geometry
var limites_BSHC = ee.FeatureCollection ('users/charlieswall/tesis/BSHC_LIMITES');
var poligonos = ee.FeatureCollection('users/charlieswall/tesis/POLIGONO_BSCH_DATOS_COMPLETO');
var p_inicio = ee.FeatureCollection('users/charlieswall/tesis/puntos_fecha_BSHC');


// load and filter the collection
var Landsat8_1 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
var Landsat8_1_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
.filterDate('2015-05-4', '2015-08-31')
.filterMetadata('CLOUD_COVER','less_than', 10);


//filter by bounds
var Landsat8_2 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
var Landsat8_2_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
.filterDate('2015-08-20', '2015-10-01')
.filterMetadata('CLOUD_COVER','less_than', 10);

//////getting imagery in to variables
//junio
var imagen1 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150807');
var imagen2 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150807');

//septiembre
var imagen3 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150924');
var imagen4 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150924');

//Create mosaics per period
var mosaic_junio = ee.ImageCollection ([ imagen1, imagen2]).mosaic().clip(limites_BSHC);
var mosaic_septiembre = ee.ImageCollection([imagen3,imagen4]).mosaic().clip(limites_BSHC);

//Compute NDVI per mosaic
// Compute the Normalized Difference Vegetation Index (NDVI).
var nir_junio = mosaic_junio.select('B5');
var red_junio = mosaic_junio.select('B4');
var ndvi_junio = nir_junio.subtract(red_junio).divide(nir_junio.add(red_junio )).rename('NDVI_jun');

var nir_septiembre = mosaic_septiembre.select('B5');
var red_septiembre = mosaic_septiembre.select('B4');
var ndvi_septiembre = nir_septiembre.subtract(red_septiembre).divide(nir_septiembre.add(red_septiembre )).rename('NDVI');

print ( ndvi_septiembre);

//Extracting pixel values from sample poligons
var prueba = ndvi_septiembre.gt(poligonos);
//mask pixels
var septiembre = mosaic_septiembre.updateMask(prueba). addBands(ndvi_septiembre);

var ndvif = function(image){
//add the NDVI band to the image
var ndvi = ndvi_septiembre.rename('NDVI');
//isolate the NDVI band
var quality = ndvi.select('NDVI');
//get pixels above the POLYGON
var ndvi01 = quality.gt(poligonos);
//create a mask from high likelihood pixels
var ndvimask = image.mask().and(ndvi01);
//mask those pixels from the image
return image.updateMask(ndvimask).addBands(ndvi);
};
var collection= ndvi_septiembre.map(ndvif);


It returns an error that says: ndvi_septiembre.map is not a function










share|improve this question
















bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    1















    I'm trying to get the mean value of pixels from an NDVI raster, that intersect the geometry of a FeatureCollection, that is a multipart polygon which represents my sample area, but I can't find the way.



    Here's the code:



     // Load geometry
    var limites_BSHC = ee.FeatureCollection ('users/charlieswall/tesis/BSHC_LIMITES');
    var poligonos = ee.FeatureCollection('users/charlieswall/tesis/POLIGONO_BSCH_DATOS_COMPLETO');
    var p_inicio = ee.FeatureCollection('users/charlieswall/tesis/puntos_fecha_BSHC');


    // load and filter the collection
    var Landsat8_1 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
    var Landsat8_1_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
    .filterDate('2015-05-4', '2015-08-31')
    .filterMetadata('CLOUD_COVER','less_than', 10);


    //filter by bounds
    var Landsat8_2 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
    var Landsat8_2_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
    .filterDate('2015-08-20', '2015-10-01')
    .filterMetadata('CLOUD_COVER','less_than', 10);

    //////getting imagery in to variables
    //junio
    var imagen1 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150807');
    var imagen2 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150807');

    //septiembre
    var imagen3 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150924');
    var imagen4 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150924');

    //Create mosaics per period
    var mosaic_junio = ee.ImageCollection ([ imagen1, imagen2]).mosaic().clip(limites_BSHC);
    var mosaic_septiembre = ee.ImageCollection([imagen3,imagen4]).mosaic().clip(limites_BSHC);

    //Compute NDVI per mosaic
    // Compute the Normalized Difference Vegetation Index (NDVI).
    var nir_junio = mosaic_junio.select('B5');
    var red_junio = mosaic_junio.select('B4');
    var ndvi_junio = nir_junio.subtract(red_junio).divide(nir_junio.add(red_junio )).rename('NDVI_jun');

    var nir_septiembre = mosaic_septiembre.select('B5');
    var red_septiembre = mosaic_septiembre.select('B4');
    var ndvi_septiembre = nir_septiembre.subtract(red_septiembre).divide(nir_septiembre.add(red_septiembre )).rename('NDVI');

    print ( ndvi_septiembre);

    //Extracting pixel values from sample poligons
    var prueba = ndvi_septiembre.gt(poligonos);
    //mask pixels
    var septiembre = mosaic_septiembre.updateMask(prueba). addBands(ndvi_septiembre);

    var ndvif = function(image){
    //add the NDVI band to the image
    var ndvi = ndvi_septiembre.rename('NDVI');
    //isolate the NDVI band
    var quality = ndvi.select('NDVI');
    //get pixels above the POLYGON
    var ndvi01 = quality.gt(poligonos);
    //create a mask from high likelihood pixels
    var ndvimask = image.mask().and(ndvi01);
    //mask those pixels from the image
    return image.updateMask(ndvimask).addBands(ndvi);
    };
    var collection= ndvi_septiembre.map(ndvif);


    It returns an error that says: ndvi_septiembre.map is not a function










    share|improve this question
















    bumped to the homepage by Community 9 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      I'm trying to get the mean value of pixels from an NDVI raster, that intersect the geometry of a FeatureCollection, that is a multipart polygon which represents my sample area, but I can't find the way.



      Here's the code:



       // Load geometry
      var limites_BSHC = ee.FeatureCollection ('users/charlieswall/tesis/BSHC_LIMITES');
      var poligonos = ee.FeatureCollection('users/charlieswall/tesis/POLIGONO_BSCH_DATOS_COMPLETO');
      var p_inicio = ee.FeatureCollection('users/charlieswall/tesis/puntos_fecha_BSHC');


      // load and filter the collection
      var Landsat8_1 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
      var Landsat8_1_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
      .filterDate('2015-05-4', '2015-08-31')
      .filterMetadata('CLOUD_COVER','less_than', 10);


      //filter by bounds
      var Landsat8_2 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
      var Landsat8_2_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
      .filterDate('2015-08-20', '2015-10-01')
      .filterMetadata('CLOUD_COVER','less_than', 10);

      //////getting imagery in to variables
      //junio
      var imagen1 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150807');
      var imagen2 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150807');

      //septiembre
      var imagen3 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150924');
      var imagen4 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150924');

      //Create mosaics per period
      var mosaic_junio = ee.ImageCollection ([ imagen1, imagen2]).mosaic().clip(limites_BSHC);
      var mosaic_septiembre = ee.ImageCollection([imagen3,imagen4]).mosaic().clip(limites_BSHC);

      //Compute NDVI per mosaic
      // Compute the Normalized Difference Vegetation Index (NDVI).
      var nir_junio = mosaic_junio.select('B5');
      var red_junio = mosaic_junio.select('B4');
      var ndvi_junio = nir_junio.subtract(red_junio).divide(nir_junio.add(red_junio )).rename('NDVI_jun');

      var nir_septiembre = mosaic_septiembre.select('B5');
      var red_septiembre = mosaic_septiembre.select('B4');
      var ndvi_septiembre = nir_septiembre.subtract(red_septiembre).divide(nir_septiembre.add(red_septiembre )).rename('NDVI');

      print ( ndvi_septiembre);

      //Extracting pixel values from sample poligons
      var prueba = ndvi_septiembre.gt(poligonos);
      //mask pixels
      var septiembre = mosaic_septiembre.updateMask(prueba). addBands(ndvi_septiembre);

      var ndvif = function(image){
      //add the NDVI band to the image
      var ndvi = ndvi_septiembre.rename('NDVI');
      //isolate the NDVI band
      var quality = ndvi.select('NDVI');
      //get pixels above the POLYGON
      var ndvi01 = quality.gt(poligonos);
      //create a mask from high likelihood pixels
      var ndvimask = image.mask().and(ndvi01);
      //mask those pixels from the image
      return image.updateMask(ndvimask).addBands(ndvi);
      };
      var collection= ndvi_septiembre.map(ndvif);


      It returns an error that says: ndvi_septiembre.map is not a function










      share|improve this question
















      I'm trying to get the mean value of pixels from an NDVI raster, that intersect the geometry of a FeatureCollection, that is a multipart polygon which represents my sample area, but I can't find the way.



      Here's the code:



       // Load geometry
      var limites_BSHC = ee.FeatureCollection ('users/charlieswall/tesis/BSHC_LIMITES');
      var poligonos = ee.FeatureCollection('users/charlieswall/tesis/POLIGONO_BSCH_DATOS_COMPLETO');
      var p_inicio = ee.FeatureCollection('users/charlieswall/tesis/puntos_fecha_BSHC');


      // load and filter the collection
      var Landsat8_1 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
      var Landsat8_1_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
      .filterDate('2015-05-4', '2015-08-31')
      .filterMetadata('CLOUD_COVER','less_than', 10);


      //filter by bounds
      var Landsat8_2 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
      var Landsat8_2_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
      .filterDate('2015-08-20', '2015-10-01')
      .filterMetadata('CLOUD_COVER','less_than', 10);

      //////getting imagery in to variables
      //junio
      var imagen1 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150807');
      var imagen2 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150807');

      //septiembre
      var imagen3 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150924');
      var imagen4 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150924');

      //Create mosaics per period
      var mosaic_junio = ee.ImageCollection ([ imagen1, imagen2]).mosaic().clip(limites_BSHC);
      var mosaic_septiembre = ee.ImageCollection([imagen3,imagen4]).mosaic().clip(limites_BSHC);

      //Compute NDVI per mosaic
      // Compute the Normalized Difference Vegetation Index (NDVI).
      var nir_junio = mosaic_junio.select('B5');
      var red_junio = mosaic_junio.select('B4');
      var ndvi_junio = nir_junio.subtract(red_junio).divide(nir_junio.add(red_junio )).rename('NDVI_jun');

      var nir_septiembre = mosaic_septiembre.select('B5');
      var red_septiembre = mosaic_septiembre.select('B4');
      var ndvi_septiembre = nir_septiembre.subtract(red_septiembre).divide(nir_septiembre.add(red_septiembre )).rename('NDVI');

      print ( ndvi_septiembre);

      //Extracting pixel values from sample poligons
      var prueba = ndvi_septiembre.gt(poligonos);
      //mask pixels
      var septiembre = mosaic_septiembre.updateMask(prueba). addBands(ndvi_septiembre);

      var ndvif = function(image){
      //add the NDVI band to the image
      var ndvi = ndvi_septiembre.rename('NDVI');
      //isolate the NDVI band
      var quality = ndvi.select('NDVI');
      //get pixels above the POLYGON
      var ndvi01 = quality.gt(poligonos);
      //create a mask from high likelihood pixels
      var ndvimask = image.mask().and(ndvi01);
      //mask those pixels from the image
      return image.updateMask(ndvimask).addBands(ndvi);
      };
      var collection= ndvi_septiembre.map(ndvif);


      It returns an error that says: ndvi_septiembre.map is not a function







      polygon masking pixel multipart values






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 15 '18 at 23:13







      Carlos Gimenez Larrosa

















      asked Sep 13 '18 at 20:39









      Carlos Gimenez LarrosaCarlos Gimenez Larrosa

      62




      62





      bumped to the homepage by Community 9 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 9 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I had to try some others ways, and finally got the values by .reduceRegions script, then I wanted to know, how engine computes the pixels by feature so, it's important to have in mind that the scale affects that 'how' depending if the centroid of each pixel is in the area of that feature or not, to be computed. In this way, I used the sampleRegions script in order to get the centroids by feature, to then be able to calculate the mean manually and it works well. Here's the code:



          // Load vector files
          var limites_BSHC = ee.FeatureCollection ('users/charlieswall/tesis/BSHC_LIMITES');
          var poligonos = ee.FeatureCollection('users/charlieswall/tesis/POLIGONO_BSCH_DATOS_COMPLETO');
          var p_inicio = ee.FeatureCollection('users/charlieswall/tesis/puntos_fecha_BSHC');

          //Call and filter imagery first period
          var Landsat8_1 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
          var Landsat8_1_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
          .filterDate('2015-05-4', '2015-08-31')
          .filterMetadata('CLOUD_COVER','less_than', 10);


          //Call and filter imagery, second period
          var Landsat8_2 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
          var Landsat8_2_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
          .filterDate('2015-08-20', '2015-10-01')
          .filterMetadata('CLOUD_COVER','less_than', 10);


          //Print properties
          print (Landsat8_1_Filtrada,'junio', Landsat8_2_Filtrada, 'septiembre');

          //Save imagery into variables
          //June
          var imagen1 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150807');
          var imagen2 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150807');

          //September
          var imagen3 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150924');
          var imagen4 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150924');

          //Create mosaics

          var mosaic_agosto = ee.ImageCollection ([ imagen1, imagen2]).mosaic().clip(limites_BSHC);

          var mosaic_septiembre = ee.ImageCollection([imagen3,imagen4]).mosaic().clip(limites_BSHC);


          //Compute ndvi values per mosaic

          var ndvi_ago = mosaic_agosto.normalizedDifference(['B5','B4']).rename('NDVI_AGO');
          var ndvi_sep = mosaic_septiembre.normalizedDifference(['B5','B4']);

          //Get ndvi values per polygon and centroid points

          var muestreo = ndvi_ago.sampleRegions({
          collection:poligonos,
          properties:['BIOMASA__T','CODIGO_DE:','fecha'],
          scale:30,
          geometries:true
          });

          //Get ndvi mean values
          var reduciendo = ndvi_ago.reduceRegions({
          collection: poligonos,
          reducer: ee.Reducer.mean(),
          scale: 30,
          });


          Map.addLayer (reduciendo);
          Map.addLayer (ndvi_ago);
          Map.centerObject (limites_BSHC);


          print(ndvi_ago);
          print (reduciendo);
          print(muestreo);





          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "79"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f295875%2fget-pixel-values-from-a-raster-using-a-multipartpolygon%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I had to try some others ways, and finally got the values by .reduceRegions script, then I wanted to know, how engine computes the pixels by feature so, it's important to have in mind that the scale affects that 'how' depending if the centroid of each pixel is in the area of that feature or not, to be computed. In this way, I used the sampleRegions script in order to get the centroids by feature, to then be able to calculate the mean manually and it works well. Here's the code:



            // Load vector files
            var limites_BSHC = ee.FeatureCollection ('users/charlieswall/tesis/BSHC_LIMITES');
            var poligonos = ee.FeatureCollection('users/charlieswall/tesis/POLIGONO_BSCH_DATOS_COMPLETO');
            var p_inicio = ee.FeatureCollection('users/charlieswall/tesis/puntos_fecha_BSHC');

            //Call and filter imagery first period
            var Landsat8_1 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
            var Landsat8_1_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
            .filterDate('2015-05-4', '2015-08-31')
            .filterMetadata('CLOUD_COVER','less_than', 10);


            //Call and filter imagery, second period
            var Landsat8_2 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
            var Landsat8_2_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
            .filterDate('2015-08-20', '2015-10-01')
            .filterMetadata('CLOUD_COVER','less_than', 10);


            //Print properties
            print (Landsat8_1_Filtrada,'junio', Landsat8_2_Filtrada, 'septiembre');

            //Save imagery into variables
            //June
            var imagen1 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150807');
            var imagen2 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150807');

            //September
            var imagen3 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150924');
            var imagen4 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150924');

            //Create mosaics

            var mosaic_agosto = ee.ImageCollection ([ imagen1, imagen2]).mosaic().clip(limites_BSHC);

            var mosaic_septiembre = ee.ImageCollection([imagen3,imagen4]).mosaic().clip(limites_BSHC);


            //Compute ndvi values per mosaic

            var ndvi_ago = mosaic_agosto.normalizedDifference(['B5','B4']).rename('NDVI_AGO');
            var ndvi_sep = mosaic_septiembre.normalizedDifference(['B5','B4']);

            //Get ndvi values per polygon and centroid points

            var muestreo = ndvi_ago.sampleRegions({
            collection:poligonos,
            properties:['BIOMASA__T','CODIGO_DE:','fecha'],
            scale:30,
            geometries:true
            });

            //Get ndvi mean values
            var reduciendo = ndvi_ago.reduceRegions({
            collection: poligonos,
            reducer: ee.Reducer.mean(),
            scale: 30,
            });


            Map.addLayer (reduciendo);
            Map.addLayer (ndvi_ago);
            Map.centerObject (limites_BSHC);


            print(ndvi_ago);
            print (reduciendo);
            print(muestreo);





            share|improve this answer




























              0














              I had to try some others ways, and finally got the values by .reduceRegions script, then I wanted to know, how engine computes the pixels by feature so, it's important to have in mind that the scale affects that 'how' depending if the centroid of each pixel is in the area of that feature or not, to be computed. In this way, I used the sampleRegions script in order to get the centroids by feature, to then be able to calculate the mean manually and it works well. Here's the code:



              // Load vector files
              var limites_BSHC = ee.FeatureCollection ('users/charlieswall/tesis/BSHC_LIMITES');
              var poligonos = ee.FeatureCollection('users/charlieswall/tesis/POLIGONO_BSCH_DATOS_COMPLETO');
              var p_inicio = ee.FeatureCollection('users/charlieswall/tesis/puntos_fecha_BSHC');

              //Call and filter imagery first period
              var Landsat8_1 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
              var Landsat8_1_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
              .filterDate('2015-05-4', '2015-08-31')
              .filterMetadata('CLOUD_COVER','less_than', 10);


              //Call and filter imagery, second period
              var Landsat8_2 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
              var Landsat8_2_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
              .filterDate('2015-08-20', '2015-10-01')
              .filterMetadata('CLOUD_COVER','less_than', 10);


              //Print properties
              print (Landsat8_1_Filtrada,'junio', Landsat8_2_Filtrada, 'septiembre');

              //Save imagery into variables
              //June
              var imagen1 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150807');
              var imagen2 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150807');

              //September
              var imagen3 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150924');
              var imagen4 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150924');

              //Create mosaics

              var mosaic_agosto = ee.ImageCollection ([ imagen1, imagen2]).mosaic().clip(limites_BSHC);

              var mosaic_septiembre = ee.ImageCollection([imagen3,imagen4]).mosaic().clip(limites_BSHC);


              //Compute ndvi values per mosaic

              var ndvi_ago = mosaic_agosto.normalizedDifference(['B5','B4']).rename('NDVI_AGO');
              var ndvi_sep = mosaic_septiembre.normalizedDifference(['B5','B4']);

              //Get ndvi values per polygon and centroid points

              var muestreo = ndvi_ago.sampleRegions({
              collection:poligonos,
              properties:['BIOMASA__T','CODIGO_DE:','fecha'],
              scale:30,
              geometries:true
              });

              //Get ndvi mean values
              var reduciendo = ndvi_ago.reduceRegions({
              collection: poligonos,
              reducer: ee.Reducer.mean(),
              scale: 30,
              });


              Map.addLayer (reduciendo);
              Map.addLayer (ndvi_ago);
              Map.centerObject (limites_BSHC);


              print(ndvi_ago);
              print (reduciendo);
              print(muestreo);





              share|improve this answer


























                0












                0








                0







                I had to try some others ways, and finally got the values by .reduceRegions script, then I wanted to know, how engine computes the pixels by feature so, it's important to have in mind that the scale affects that 'how' depending if the centroid of each pixel is in the area of that feature or not, to be computed. In this way, I used the sampleRegions script in order to get the centroids by feature, to then be able to calculate the mean manually and it works well. Here's the code:



                // Load vector files
                var limites_BSHC = ee.FeatureCollection ('users/charlieswall/tesis/BSHC_LIMITES');
                var poligonos = ee.FeatureCollection('users/charlieswall/tesis/POLIGONO_BSCH_DATOS_COMPLETO');
                var p_inicio = ee.FeatureCollection('users/charlieswall/tesis/puntos_fecha_BSHC');

                //Call and filter imagery first period
                var Landsat8_1 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
                var Landsat8_1_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
                .filterDate('2015-05-4', '2015-08-31')
                .filterMetadata('CLOUD_COVER','less_than', 10);


                //Call and filter imagery, second period
                var Landsat8_2 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
                var Landsat8_2_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
                .filterDate('2015-08-20', '2015-10-01')
                .filterMetadata('CLOUD_COVER','less_than', 10);


                //Print properties
                print (Landsat8_1_Filtrada,'junio', Landsat8_2_Filtrada, 'septiembre');

                //Save imagery into variables
                //June
                var imagen1 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150807');
                var imagen2 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150807');

                //September
                var imagen3 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150924');
                var imagen4 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150924');

                //Create mosaics

                var mosaic_agosto = ee.ImageCollection ([ imagen1, imagen2]).mosaic().clip(limites_BSHC);

                var mosaic_septiembre = ee.ImageCollection([imagen3,imagen4]).mosaic().clip(limites_BSHC);


                //Compute ndvi values per mosaic

                var ndvi_ago = mosaic_agosto.normalizedDifference(['B5','B4']).rename('NDVI_AGO');
                var ndvi_sep = mosaic_septiembre.normalizedDifference(['B5','B4']);

                //Get ndvi values per polygon and centroid points

                var muestreo = ndvi_ago.sampleRegions({
                collection:poligonos,
                properties:['BIOMASA__T','CODIGO_DE:','fecha'],
                scale:30,
                geometries:true
                });

                //Get ndvi mean values
                var reduciendo = ndvi_ago.reduceRegions({
                collection: poligonos,
                reducer: ee.Reducer.mean(),
                scale: 30,
                });


                Map.addLayer (reduciendo);
                Map.addLayer (ndvi_ago);
                Map.centerObject (limites_BSHC);


                print(ndvi_ago);
                print (reduciendo);
                print(muestreo);





                share|improve this answer













                I had to try some others ways, and finally got the values by .reduceRegions script, then I wanted to know, how engine computes the pixels by feature so, it's important to have in mind that the scale affects that 'how' depending if the centroid of each pixel is in the area of that feature or not, to be computed. In this way, I used the sampleRegions script in order to get the centroids by feature, to then be able to calculate the mean manually and it works well. Here's the code:



                // Load vector files
                var limites_BSHC = ee.FeatureCollection ('users/charlieswall/tesis/BSHC_LIMITES');
                var poligonos = ee.FeatureCollection('users/charlieswall/tesis/POLIGONO_BSCH_DATOS_COMPLETO');
                var p_inicio = ee.FeatureCollection('users/charlieswall/tesis/puntos_fecha_BSHC');

                //Call and filter imagery first period
                var Landsat8_1 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
                var Landsat8_1_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
                .filterDate('2015-05-4', '2015-08-31')
                .filterMetadata('CLOUD_COVER','less_than', 10);


                //Call and filter imagery, second period
                var Landsat8_2 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
                var Landsat8_2_Filtrada = Landsat8_1.filterBounds(limites_BSHC)
                .filterDate('2015-08-20', '2015-10-01')
                .filterMetadata('CLOUD_COVER','less_than', 10);


                //Print properties
                print (Landsat8_1_Filtrada,'junio', Landsat8_2_Filtrada, 'septiembre');

                //Save imagery into variables
                //June
                var imagen1 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150807');
                var imagen2 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150807');

                //September
                var imagen3 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226075_20150924');
                var imagen4 = ee.Image ('LANDSAT/LC08/C01/T1_TOA/LC08_226076_20150924');

                //Create mosaics

                var mosaic_agosto = ee.ImageCollection ([ imagen1, imagen2]).mosaic().clip(limites_BSHC);

                var mosaic_septiembre = ee.ImageCollection([imagen3,imagen4]).mosaic().clip(limites_BSHC);


                //Compute ndvi values per mosaic

                var ndvi_ago = mosaic_agosto.normalizedDifference(['B5','B4']).rename('NDVI_AGO');
                var ndvi_sep = mosaic_septiembre.normalizedDifference(['B5','B4']);

                //Get ndvi values per polygon and centroid points

                var muestreo = ndvi_ago.sampleRegions({
                collection:poligonos,
                properties:['BIOMASA__T','CODIGO_DE:','fecha'],
                scale:30,
                geometries:true
                });

                //Get ndvi mean values
                var reduciendo = ndvi_ago.reduceRegions({
                collection: poligonos,
                reducer: ee.Reducer.mean(),
                scale: 30,
                });


                Map.addLayer (reduciendo);
                Map.addLayer (ndvi_ago);
                Map.centerObject (limites_BSHC);


                print(ndvi_ago);
                print (reduciendo);
                print(muestreo);






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 17 '18 at 23:19









                Carlos Gimenez LarrosaCarlos Gimenez Larrosa

                62




                62






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f295875%2fget-pixel-values-from-a-raster-using-a-multipartpolygon%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Щит и меч (фильм) Содержание Названия серий | Сюжет |...

                    is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

                    Meter-Bus Содержание Параметры шины | Стандартизация |...