www.abzwater.com TM

GEO PORTAL>>GEOMETRY


Geometry
In Google Earth Engine (GEE), vector data (e.g., points, lines, and polygons) is handled with the geometry type. There are many types of geometries supported by GEE. Point (ee.Geometry.Point ()), Multi Point (ee.Geometry.MultiPoint ()), Line (ee.Geometry.LineString()), Multi Line(ee.Geometry.MultiLineString()), and Polygon(ee.Geometry.Polygon()) are some of the geometries supported in JavaScript API of GEE. To create a Geometry programmatically, the constructor of the geometry is supplied with the proper list(s) of coordinates. For example, the below code snippet constructs a geometry of point type:
         
1.	var COLOR = {  
2.	  RED: 'ff0000',  
3.	  BLACK:'000000',  
4.	  GREEN:'00ff00'  
5.	};  
6.	  
7.	var pPoint = ee.Geometry.Point(-107.49, 36.04);  
8.	  
9.	Map.addLayer(pPoint, {'color': COLOR.RED});  
10.	Map.setCenter(-107.49, 36.04, 8);  
        
Similarly, the below code snippet constructs a geometry of polygon type:
        
1.	var COLOR = {  
2.	  RED: 'ff0000',  
3.	  BLACK:'000000',  
4.	  GREEN:'00ff00'  
5.	};  
6.	  
7.	var pPolygon = ee.Geometry.Polygon(-107.49, 36.04,-106.49, 36.04, -106.49, 36.84);  
8.	  
9.	Map.addLayer(pPolygon, {'color': COLOR.RED});  
10.	Map.setCenter(-107.49, 36.04, 8);  
        
In GEE there are serval methods (e.g., bounds(), area(),type(), length(), and perimeter()) to get the information associated with geometries. For example, in the below code snippet, the area() is used to get the area of a rectangle.
        
1.	var COLOR = {  
2.	  RED: 'ff0000',  
3.	  BLACK:'000000',  
4.	  GREEN:'00ff00'  
5.	};  
6.	  
7.	var pRectangle = ee.Geometry.Rectangle(-107.49, 36.04, -106.49, 36.84);  
8.	  
9.	var pArea=pRectangle.area();  
10.	print(pArea);  
11.	  
12.	Map.addLayer(pRectangle, {'color': COLOR.RED});  
13.	Map.setCenter(-107.49, 36.04, 8);  
        
Earth Engine supports a wide variety of operations on Geometry objects. These include operations on individual geometries such as computing a buffer, and bounding box. 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 find the minimum distance between two geometries.
          
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(-105.49, 36.04, -104.49, 36.84);  
9.	  
10.	var pDistance=pRectangle1.distance(pRectangle2);  
11.	print(pDistance);  
12.	  
13.	Map.addLayer(pRectangle1, {'color': COLOR.RED});  
14.	Map.addLayer(pRectangle2, {'color': COLOR.GREEN});  
15.	  
16.	Map.setCenter(-107.49, 36.04, 8);  
        
As shown in the above code snippet, initially, two geometries namely "pRectangle1" and "pRectangle2" are created. Subsequently, the second geometry (i.e., pRectangle2) is specified as the input for the method of distance. The resultant output is the minimum distance between the given geometries.
Continue Reading
Copyright © 2016 - 2020 abzWater Operating Company, LLC. All Rights Reserved.