3

I am interested in using the .sampleRegions function to extract values from the following ImageCollection. In order to do this, I want to select the middle of the three images (index=1) contained within this image collection. Can anyone help me figure out how to select this image from the ImageCollection?

var MFR = ee.ImageCollection("LANDFIRE/Fire/MFRI/v1_2_0")
print(MFR)

output:

type: ImageCollection
id: LANDFIRE/Fire/MFRI/v1_2_0
version: 1633090983238815
bands: []
features: List (3 elements)
properties: Object (14 properties)

If I use .first(), I get the first image which has the desired form, but is the wrong image:

var MFR = ee.ImageCollection("LANDFIRE/Fire/MFRI/v1_2_0").first()
print(MFR)

output:

Image LANDFIRE/Fire/MFRI/v1_2_0/AK (1 band)
type: Image
id: LANDFIRE/Fire/MFRI/v1_2_0/AK
version: 1629985810765077
bands: List (1 element)
properties: Object (6 properties)

Is there an easy way to select the second image?

1 Answer 1

3

Since you know the image id from your script, you can call the image by image id. As in the code below:

var dataset = ee.Image('LANDFIRE/Fire/MFRI/v1_2_0/CONUS');
2
  • Thank you for the response! In this case, the first part of your answer var dataset = ee.Image('LANDFIRE/Fire/MFRI/v1_2_0/CONUS'); is sufficient for what I'm looking to do.
    – Ben
    Nov 30, 2021 at 0:37
  • Yes, you are right. I have added those extra bit to visualize. Nov 30, 2021 at 0:38

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.