2

IMPORTS:

var geometry = /* color: #d63000 */ee.Geometry.Polygon(
    [[[-67.76435852050781, -22.213792811479802],
      [-67.76641845703125, -22.220785143658368],
      [-67.75646209716797, -22.228412744835992],
      [-67.74410247802734, -22.230319580297703],
      [-67.7420425415039, -22.221420792936158],
      [-67.74341583251953, -22.212203596469955],
      [-67.74787902832031, -22.207753698686023],
      [-67.75543212890625, -22.213474969917876]]]);

CODE I have tried :

var fg_points = ee.Feature(geometry);

I thought if we give geometry as a feature it will select all points in that polygon but it isn't.

I have used randomPoints command but it is not evenly selecting all the points what I want is at least a point from each pixel. and the randomPoints command is selecting the same points again and again.

marked as duplicate by user30184, Kadir Şahbaz, aldo_tapia, Kersten, Evil Genius Aug 20 '18 at 11:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Yes, I am only getting vertices from that how to get points inside that polygon...Please help me with this. – Prasad Thota Aug 17 '18 at 10:55
  • what do you mean by points inside that polygon? do you mean like a grid of points? – Rodrigo E. Principe Aug 17 '18 at 10:58
  • Yes like a MultiPoint Geometry that covers each and every pixel of a LANDSAT Image. – Prasad Thota Aug 17 '18 at 10:59
  • You should change the title to Extract coordinates of pixels inside a polygon in GEE – aldo_tapia Aug 17 '18 at 11:27
  • Sorry about that. Now, it's fine. – Prasad Thota Aug 17 '18 at 11:31
2
var bounds = ee.Geometry.Polygon(
    [[[-67.76435852050781, -22.213792811479802],
      [-67.76641845703125, -22.220785143658368],
      [-67.75646209716797, -22.228412744835992],
      [-67.74410247802734, -22.230319580297703],
      [-67.7420425415039, -22.221420792936158],
      [-67.74341583251953, -22.212203596469955],
      [-67.74787902832031, -22.207753698686023],
      [-67.75543212890625, -22.213474969917876]]]);

var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
           .filterBounds(bounds);

// TEST IMAGE
var first = ee.Image(l8.first()).clip(bounds)

// get image projection
var proj = first.select([0]).projection()

// get coordinates image
var latlon = ee.Image.pixelLonLat().reproject(proj)
Map.addLayer(first, {bands:['B1'], min:0, max:500}, 'Image')

// put each lon lat in a list
var coords = latlon.select(['longitude', 'latitude'])
                 .reduceRegion({
  reducer: ee.Reducer.toList(),
  geometry: bounds,
  scale: 30
})

// get lat & lon
var lat = ee.List(coords.get('latitude'))
var lon = ee.List(coords.get('longitude'))

// zip them. Example: zip([1, 3],[2, 4]) --> [[1, 2], [3,4]]
var point_list = lon.zip(lat)

// Create points
var mp = ee.Geometry.MultiPoint(point_list)
Map.addLayer(mp,{}, 'Points')

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