Geographic Information Systems Asked by Izaeljr on June 13, 2021
I have an image classified with pixel values equals to one and zero. I want to return the lat and long from pixels values equals to one, would be possible, using GEE?
You can use .selfMask()
to remove all zero values, then .sample()
your image after adding .pixelLonLat()
to retrieve the pixel values.
To convert the pixel values to a list, you can use .aggregate_array('longitude')
and .aggregate_array('latitude')
, or use .reduceColumns()
using whichever reducer you need to provide the results you're looking for (e.g. mean()
, minMax()
, toList()
, etc.)
// These weren't shared in the original question so still to define:
// image - your image of interest
// roi - your region of interest
// Mask zero values, add PixelLonLag, clip to roi
var imgWithPixLonLat = image.selfMask().addBands(ee.Image.pixelLonLat()).clip(roi)
// Pixel longitude values as a list
print(imgWithPixLonLat.sample().aggregate_array('longitude'))
// Mean lon/lat values
print(imgWithPixLonLat.sample().reduceColumns({reducer: ee.Reducer.mean().repeat(2),
selectors: ['longitude', 'latitude']
}))
Correct answer by hooge048 on June 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP