Contour lines in GEE

Use this example to create your contour maps

Step 1: import the srtm digital elevation data.

Step 2: Create a geometry on your map

Step 3: use the code below to create contour lines.


var lines = ee.List.sequence(0, 4000, 200)

var contourlines = lines.map(function(line) {
var mycontour = srtm
.convolve(ee.Kernel.gaussian(5, 3))
.subtract(ee.Image.constant(line)).zeroCrossing()
.multiply(ee.Image.constant(line)).toFloat();

return mycontour.mask(mycontour);
})

contourlines = ee.ImageCollection(contourlines).mosaic()

Map.addLayer(contourlines, {min: 0, max: 5000, palette:['00ff00', 'ff0000']}, 'contours')
Map.centerObject(geometry,5)

See an example here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s