Google Earth Engine – Making Painted Point Always Visible Without Exporting in Google Earth Engine

google-earth-engineimage-pyramids

I'm creating an image using the Earth Engine API and then I'm displaying it on a map.
The image is using a "mode" pyramiding policy, and I would like to use "max" but I don't know how to change it without exporting.

I created a minimal example to explain myself : https://code.earthengine.google.com/7a40cc6466e711e301901f62cd489283

// extract the centroid of the geometry
var point = geometry.centroid(.001)

// create a fake image in the geometry 
//with 0 values everywhere but the center
var dummy = ee.Image()
  .byte()
  .paint({featureCollection: geometry,color: 0})
  .paint({featureCollection: point.buffer(20),color: 1})

Map.addLayer(dummy, {palette: ["red","blue"], max:1}, "dummy")

// zoom on the square at the exact level 
// where the blue point disapear on my screen
Map.centerObject(geometry)
Map.setZoom(11)

In this small example I create an rectangle image with 0 value everywhere but the centroid.

If I zoom out too much the point become invisible, I would like to always see it, what shoud I change in the Image or in the addLayer method ?

Best Answer

This is not a pyramiding problem. Pyramiding only applies to stored images — taking a high-resolution base image and making lower-resolution images out of it. Here, the image is being generated from scratch at the resolution you're viewing it at. You need to approach this as asking the image operations to do what you want.

You can change your second .paint() to have a line-width, like this:

  .paint({featureCollection: point.buffer(20), color: 1, width: 1})

This way, even if the feature area is less than 1 pixel, it will still try to draw a 1-pixel-wide line around the perimeter, which will result in there being at least one pixel with value 1 no matter how small it shrinks.

Another possibility would be to paint the point and the buffered point. Painting a point geometry always fills in exactly one pixel, so if you paint both, you're guaranteed there will be at least one pixel. This won't affect the exact boundary whereas the line-width option may (by 1 pixel).

Related Question