www.abzwater.com TM

GEO PORTAL>>FEATURE


Feature
In Google Earth Engine, a feature is an object that is associated with a geometry property and other properties that are known as the attributes of the feature. Features can be constructed from one of the following arguments and an optional dictionary of properties:
- An ee.Geometry.
- A GeoJSON Geometry.
- A GeoJSON Feature.
- A computed object.
The below code snippet demonstrates the construction of a feature using ee.Geometry (). In the code snippet, at first, a geometry of rectangle (i.e., pRectangle1) in shape is created. Subsequently, a feature of rectangle in shape is created by setting the constructor of the feature to this geometry.
              
1.	var COLOR = {  
2.	  RED: 'ff0000',  
3.	  BLACK:'000000',  
4.	  GREEN:'00ff00'  
5.	};  
6.	  
7.	var pRectangle1 = ee.Geometry.Rectangle(-84.46, 39.71, -82.18, 41.12);  
8.	  
9.	var pFeaturefromGeometry=ee.Feature(pRectangle1);  
10.	  
11.	Map.addLayer(pFeaturefromGeometry, {'color': COLOR.RED});  
12.	Map.setCenter(-84.46, 39.71, 8);  

        
The below code snippet shows the construction of a feature using a computed object. As shown, initially, a feature collection which is a collection of features is constructed. This feature collection is filtered using one of the attributes (i.e., high_record) to extract all the features that have the value of high_record greater than 44.4. Subsequently, in this filtered feature collection, the first record is extracted to construct the feature using a computed object.
        
1.	var COLOR = {  
2.	  RED: 'ff0000',  
3.	  BLACK:'000000',  
4.	  GREEN:'00ff00'  
5.	};  
6.	  
7.	var statesData = ee.FeatureCollection('ft:1dZ78QI6P_HrZ6oabSKitytOhWM__fI9O1ayP4AoI');  
8.	var filteredRecord=statesData.filter(ee.Filter.gt("high_record", 44.4));  
9.	var firstRecord=filteredRecord.first();  
10.	var pFeaturefromComputedObject=ee.Feature(firstRecord);  
11.	  
12.	Map.addLayer(pFeaturefromComputedObject, {'color': COLOR.GREEN});  
13.	  
14.	Map.setCenter(-84.46, 39.71, 8);  
        
The JavaScript API of GEE also comes with few relational operations such as intersection, distance, intersects, contains, containedIn, and union. For example, the following code snippet is used to intersect two features to return a feature containing the intersection of the geometries of two features, with the properties of the left feature.
           
1.	var COLOR = {  
2.	  RED: 'ff0000',  
3.	  BLACK:'000000',  
4.	  GREEN:'00ff00'  
5.	};  
6.	  
7.	var pRectangle1 = ee.Geometry.Rectangle(-107.49, 36.04, -106.49, 36.84);  
8.	var pRectangle2 = ee.Geometry.Rectangle(-106.99, 36.04, -105.49, 36.84);  
9.	  
10.	var pFeaturefromGeometry1=ee.Feature(pRectangle1);  
11.	var pFeaturefromGeometry2=ee.Feature(pRectangle2);  
12.	  
13.	var pIntersectedRegion=pFeaturefromGeometry1.intersection(pFeaturefromGeometry2);  
14.	print(pIntersectedRegion);  
15.	  
16.	Map.addLayer(pFeaturefromGeometry1, {'color': COLOR.RED});  
17.	Map.addLayer(pFeaturefromGeometry2, {'color': COLOR.BLACK});  
18.	Map.addLayer(pIntersectedRegion, {'color': COLOR.GREEN});  
19.	  
20.	Map.setCenter(-107.49, 36.04, 8);  
        
As shown in the above code snippet, initially, two features namely feature1 and feature2 are created. Subsequently, these features are specified as the inputs for the method of intersection. The resultant output from the operation is the intersected feature that is highlighted in the adjacent figure.
Continue Reading
Copyright 2016 - 2020 abzWater Operating Company, LLC. All Rights Reserved.