1

I wanted to clip the ALOS elevation model to an ROI. This is the code I wrote.

var dem = ee.Image("JAXA/ALOS/AW3D30_V1_1");
var geometry = 
    /* color: #ffc82d */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[1.3787373046875473, 49.38636777007675],
          [1.3787373046875473, 48.32016208111379],
          [3.5265644531250473, 48.32016208111379],
          [3.5265644531250473, 49.38636777007675]]], null, false);

var clipdem = dem.filterBounds(geometry)

But it gave me this error:

dem.filterBounds is not a function

I tried casting it to an imageCollection before applying the function, but it doesn't clip the image - giving me the image for the entire world. What is causing it and is there a way to work around it?

1 Answer 1

1

Filtering is for imageCollections. To clip an image, try this instead:

var dem = ee.Image("JAXA/ALOS/AW3D30_V1_1");

var geometry =
    ee.Geometry.Polygon(
        [[[1.3787373046875473, 49.38636777007675],
          [1.3787373046875473, 48.32016208111379],
          [3.5265644531250473, 48.32016208111379],
          [3.5265644531250473, 49.38636777007675]]], null, false);

var clipdem = dem.clip(geometry);
Map.addLayer(clipdem, {min:0,max:250}, "DEM");
Map.centerObject(clipdem, 9);
3
  • Thank you! It worked. Commented Oct 30, 2019 at 19:37
  • But is there a way to get the raster that is restricted to the geometry? clipping gives me a raster that has a 0 value outside the geometry. Can I get something that does the same thing that filterBounds does Commented Oct 30, 2019 at 19:46
  • Sounds like a different issue. Maybe something mask-related? Probably worth asking another question for that one. Commented Oct 30, 2019 at 20:26

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.