Changeset 775 in lmdz_wrf for trunk/tools
- Timestamp:
- May 25, 2016, 5:09:32 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r762 r775 17 17 fillValueF64 = 1.e20 18 18 fillValueI32 = -99999 19 20 ####### Content 21 # PolyArea: Function to compute the area of the polygon following 'Shoelace formula' 19 22 20 23 def values_line(line, splitv, chars): … … 6229 6232 6230 6233 return ilatlon, mindiffLl 6234 6235 def PolyArea(x,y): 6236 """ Function to compute the area of the polygon following 'Shoelace formula' 6237 from: http://stackoverflow.com/questions/24467972/calculate-area-of-polygon-given-x-y-coordinates 6238 x: x-values of the vertexs of the polygon 6239 y: y-values of the vertexs of the polygon 6240 >>> x = np.array([-0.5,0.5,0.5,-0.5]) 6241 >>> y = np.array([0.5,0.5,-0.5,-0.5]) 6242 >>> PolyArea(x,y) 6243 1.0 6244 """ 6245 return 0.5*np.abs(np.dot(x,np.roll(y,1))-np.dot(y,np.roll(x,1))) 6246
Note: See TracChangeset
for help on using the changeset viewer.