1

I am attempting to gather data for an urban forest, I am more or less trying to run transects through the forest but with Google Earth Engine. I have a few rasters that I am wanting to extract data from and I want to do so at the same point for every raster.

I tried to do this with ee.Image.sample, but it places the sample point at different locations, I imagine due to the resolution of each image. In the following code "fromList" is the forested area featureCollection. "drain" and "elev" are the different rasters, which are both clipped to the featureCollection "fromList"

//SAMPLE
var samples = drain.sample({
  region: fromList,
  geometries: true,
  scale: 90,
});
var samples2 = elev.sample({
  region: fromList,
  geometries: true,
  scale: 90,
});

 print(samples, samples2);
 Map.addLayer(samples);
 Map.addLayer(samples2);

Different sample locations

My next guess was to try and use pins, however, I can't seem to figure out how to get the data from each pixel. The pins are saved into a featureCollection called "pts".

Pin locations

1 Answer 1

1

Combine the two images' bands into one image. Then, you will get only one set of points.

var samples = drain.addBands(elev).sample({
  region: fromList,
  geometries: true,
  scale: 90,
});

(You may wish to, first, rename the images' bands in case any of them have the same name.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.