3

If I have a list of points of interest in Google Earth Engine, e.g.

var pointList = [
  ee.Feature(ee.Geometry.Point(-73.96, 40.781)),
  ee.Feature(ee.Geometry.Point(6.4806, 50.8012))
];

var pointCollection = ee.FeatureCollection(features);

how can I draw a quadratic, planar region of interest around them, e.g. of size 100 x 100 km²? I have used ee.Geometry.buffer() in the past, but this function operates in geodesic geometry and doesn't lead to accurate results.

EDIT: To further specify - I am looking for a quadratic rectangle of 100 × 100 km2 in a local planar coordinate system, i.e. UTM. The problem with the buffer function is also that any rectangles are only quadratic in WGS84, but become rectangular when moving away from the equator.

1 Answer 1

3

I had a similar problem and came up with a work around in 2 steps:

  1. Use the buffer function to draw a circle around your point.
  2. Use the bounds function to fit a bounding box around the circle.

Maybe not that elegant, but it does the job:

var pointList = [
  ee.Feature(ee.Geometry.Point(-73.96, 40.781)),
  ee.Feature(ee.Geometry.Point(6.4806, 50.8012))
];

var pointCollection = ee.FeatureCollection(pointList);

// Define a function of buffering and bounding      
var bounding_box_func = function(feature) {
    var intermediate_buffer = feature.buffer(50000);  // buffer radius, half your box width in m
    var intermediate_box = intermediate_buffer.bounds(); // Draw a bounding box around the circle
       return(intermediate_box); // Return the bounding box
      };

// Apply function
var bounding_boxes = pointCollection.map(bounding_box_func);
    Map.centerObject(pointCollection); // Center map on sample points
    Map.addLayer(bounding_boxes, {color: '#FECA1E', fillColor: '#4c4cff'}, "Bounding boxes");

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.