1

I've just started having a play about with the new coveringGrid() geometry function in Earth Engine but it seems to be exhibiting some strange behaviour.

When I run it for a feature, the result shows up correctly in the map, though when I try to use the result for subsequent operations there are features missing from the grid.

I've attached a link to the script highlighting it, where the black feature is the original shapefile input, the blue feature is the result of the coveringGrid() function and what is visualised in in the Map in Earth Engine (i.e. the expected result), and the yellow feature is what is subsequently seen by GEE (cribbed by using getInfo()).

Code sample and link below:

var RGIRegion='03'
var RGIpath='users/Jmleaglacio/RGI7alpha/RGI'+RGIRegion;
var RGIsimplifiedPath='users/Jmleaglacio/RGI7alpha/RGI'+RGIRegion+'_simplified1km';

// The input Feature
var RGIsimplified=ee.Feature(ee.FeatureCollection(RGIsimplifiedPath).first()).aside(print);

Map.addLayer(RGIsimplified)
//There are 22 blue squares, but only 12 are shown by the print statement
var RGIgridInitial=ee.FeatureCollection(ee.FeatureCollection(ee.Feature(RGIsimplified).geometry()
                .coveringGrid('EPSG:3857',1000000))).aside(print)
                
print(RGIgridInitial)
Map.addLayer(RGIgridInitial,{color:'blue'}) //the expected result
Map.addLayer(ee.FeatureCollection(RGIgridInitial.getInfo()),{color:'yellow'}) //the actual result
   

https://code.earthengine.google.com/7ba22d963850a6134e92bcc50b8d5466

1 Answer 1

0

Found the solution: the issue was that the input feature collection was in a different projection to the projection I defined in the coveringGrid() function. If you're using this function, make sure to use ee.Algorithms.projectionTransform() on the input feature collection to make sure that the crs of the input is the same as the one defined in coveringGrid(). Link to code with correct solution here: https://code.earthengine.google.com/05bcb880dc058b653f0ce2483c39d8ec

1
  • 1
    Please share your FeatureCollection users/Jmleaglacio/RGI7alpha/RGI03_simplified1km so others can run your linked code.
    – cengstro
    Commented Aug 4, 2022 at 23:01

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.