-
Notifications
You must be signed in to change notification settings - Fork 266
/
visualizing_feature_collection.py
57 lines (41 loc) · 1.64 KB
/
visualizing_feature_collection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import ee
from ee_plugin import Map
# Load a FeatureCollection from a table dataset: 'RESOLVE' ecoregions.
ecoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017')
# Display as default and with a custom color.
Map.addLayer(ecoregions, {}, 'default display')
Map.addLayer(ecoregions, {'color': 'FF0000'}, 'colored')
Map.addLayer(ecoregions.draw(**{'color': '006600', 'strokeWidth': 5}), {}, 'drawn')
# Create an empty image into which to paint the features, cast to byte.
empty = ee.Image().byte()
# Paint all the polygon edges with the same number and 'width', display.
outline = empty.paint(**{
'featureCollection': ecoregions,
'color': 1,
'width': 3
})
Map.addLayer(outline, {'palette': 'FF0000'}, 'edges')
# Paint the edges with different colors, display.
outlines = empty.paint(**{
'featureCollection': ecoregions,
'color': 'BIOME_NUM',
'width': 4
})
palette = ['FF0000', '00FF00', '0000FF']
Map.addLayer(outlines, {'palette': palette, 'max': 14}, 'different color edges')
# Paint the edges with different colors and 'width's.
outlines = empty.paint(**{
'featureCollection': ecoregions,
'color': 'BIOME_NUM',
'width': 'NNH'
})
Map.addLayer(outlines, {'palette': palette, 'max': 14}, 'different color, width edges')
# Paint the interior of the polygons with different colors.
fills = empty.paint(**{
'featureCollection': ecoregions,
'color': 'BIOME_NUM',
})
Map.addLayer(fills, {'palette': palette, 'max': 14}, 'colored fills')
# Paint both the fill and the edges.
filledOutlines = empty.paint(ecoregions, 'BIOME_NUM').paint(ecoregions, 0, 2)
Map.addLayer(filledOutlines, {'palette': ['000000'] + palette, 'max': 14}, 'edges and fills')