Created
December 17, 2021 16:53
-
-
Save jsta/4021c371febf7dcd0500dedbf7142b91 to your computer and use it in GitHub Desktop.
Plot a featureCollection as a choropleth in Google Earth Engine (GEE)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bottom-left, top-right | |
var aoi = ee.Geometry.Rectangle(43.1, 13, 47, 30); | |
var ecoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017') | |
.filterBounds(aoi); | |
var ecoregions_img = ecoregions | |
.filter(ee.Filter.notNull(['SHAPE_AREA'])) | |
.reduceToImage({ | |
properties: ['SHAPE_AREA'], | |
reducer: ee.Reducer.first() | |
}); | |
var area_values = ecoregions | |
.filter(ee.Filter.greaterThan("SHAPE_AREA", 0)) | |
.aggregate_array("SHAPE_AREA"); | |
print(area_values) // 0 - 72 | |
Map.centerObject(ecoregions, 4) | |
Map.addLayer(ecoregions_img, { | |
min: 0, | |
max: 73, | |
palette: ['FCFDBF', 'FDAE78', 'EE605E', 'B63679', '711F81', '2C105C'] | |
}); | |
Map.addLayer({eeObject: ecoregions.draw({color: 'black', strokeWidth: 1}), visParams: {}, opacity: 0.3}); |
Author
jsta
commented
Dec 17, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment