# earth_surf: Surface of 1 dg by 1 dg Cells of the Earth In marelac: Tools for Aquatic Sciences

## Description

`earth_surf` computes the surface of 1d by 1dg grid cells as a function of latitude.

Based on data that give the surface distance per 1 dg change in lat/lon from http://en.wikipedia.org/wiki/Latitude

`earth_dist` calculates the distance between two (lat, lon) points

## Usage

 ```1 2``` ```earth_surf(lat = 0, lon = 0) earth_dist(alat, alon, blat, blon, method = 1) ```

## Arguments

 `lat ` latitude (-90 - +90). `lon ` longitude - not used. `alat ` first latitude (-90 - +90). `alon ` first longitude (-180, 180). `blat ` second latitude (-90 - +90). `blon ` second longitude (-180, 180). `method ` an integer indicating the formula to use, either the spherical law of cosines (`1`) or the haversine formula (`2`)

## Value

Surface of the grid cell, in m2.

Distance between the points (alat, alon), (blat, blon), m.

## Author(s)

Karline Soetaert <karline.soetaert@nioz.nl>

`Bathymetry`, `Oceans`
 ``` 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``` ``` earth_surf(seq(0, 90, by = 15)) SURF <- outer(X = Bathymetry\$x, Y = Bathymetry\$y, FUN <- function(X, Y) earth_surf(Y, X)) earth_dist(10, 80, 10, 81) earth_dist(20, 80, 20, 81) SURF <- outer(X = Bathymetry\$x, Y = Bathymetry\$y, FUN <- function(X, Y) earth_surf(Y, X)) sum(SURF) #is: 510,072,000 km2 # the surface of the Oceans, m2 sum(SURF*(Bathymetry\$z < 0)) # is: 3.58e14 # the volume of the Oceans, m3 - sum(SURF*Bathymetry\$z*(Bathymetry\$z < 0)) # is: 1.34e+18 # the surface area at several depths SurfDepth <- vector() dseq <- seq(-7500, -250, by = 250) for (i in 2:length(dseq)) { ii <- which (Bathymetry\$z > dseq[i-1] & Bathymetry\$z <= dseq[i]) SurfDepth[i-1]<-sum(SURF[ii]) } plot(dseq[-1], SurfDepth, xlab = "depth, m", log = "y", ylab = "m2", main = "Surface at ocean depths") ```