-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclassify
58 lines (43 loc) · 1.54 KB
/
classify
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
function get_volcanic_areas() {
var volcanoes = ee.FeatureCollection('ft:1By_TxmjpCjLippFR1REdyA7ULGEAoQPw-EjubYAk')
function volcanoPatch(feature) {
var lat = ee.Number(feature.get('latitude'))
var lon = ee.Number(feature.get('longitude'))
var geom = ee.Geometry.Point(lon,lat).buffer(50000)
return ee.Feature(geom,{}).copyProperties(feature)
}
return volcanoes.map(volcanoPatch)
}
var volcanic_areas = get_volcanic_areas()
//Map.addLayer(volcanic_areas)
// fire features
var fire1 = ee.Geometry.Point(-116.19, 38.75)
var fire2 = ee.Geometry.Point(-105.21, 34.96)
var fire3 = ee.Geometry.Point(-89.82, 43.33)
// volcano (hawaii)
var hawaii = ee.Geometry.Point(-155.2286, 19.4329)
var iceland = ee.Geometry.Point(-20.39, 64.17)
// fire feature collection
var hotThings = ee.FeatureCollection([
ee.Feature(fire1,{}),
ee.Feature(fire2,{}),
ee.Feature(fire3,{}),
ee.Feature(hawaii,{}),
ee.Feature(iceland,{})
])
//Map.addLayer(hotThings,{color:'red'})
function classify(feature) {
var hot = feature.geometry()
var volcanic = hot.containedIn(volcanic_areas)
var hot_type = ee.Algorithms.If(volcanic,'volcanic','fire')
return ee.Feature(hot,{'hot_type':hot_type}).copyProperties(feature)
}
var classified = hotThings.map(classify)
var volcanoes = classified.filter(ee.Filter.eq('hot_type','volcanic'))
var fires = classified.filter(ee.Filter.eq('hot_type','fire'))
//filter then print t map
print(volcanoes)
print(fires)
Map.addLayer(volcanic_areas)
Map.addLayer(volcanoes,{color:'cyan'})
Map.addLayer(fires,{color:'red'})