PecanProject / bety

Web-interface to the Biofuel Ecophysiological Traits and Yields Database (used by PEcAn and TERRA REF)
https://www.betydb.org
BSD 3-Clause "New" or "Revised" License
16 stars 38 forks source link

Fix elevation #127

Closed dlebauer closed 10 years ago

dlebauer commented 10 years ago

Some sites don't have elevation (RM-2408); these can be queried and fixed, e.g. in R using

(from http://stackoverflow.com/a/8975851/199217)

> require(geonames)
> GNsrtm3(54.481084,-3.220625)
  srtm3       lng      lat
1   797 -3.220625 54.48108
dlebauer commented 10 years ago

This is how I fixed it:

Step 1: query geonames

library(geonames)
options(geonamesUsername="dlebauer")
sites <- read.csv("/Users/David LeBauer/Downloads/sites.csv")

elevation <- vector(mode = "numeric", length = nrow(sites))
for(i in 1:nrow(sites)){
  elevation[i] <- GNsrtm3(sites$lat[i], sites$l
}

Step 2: Google Earth

manual search / replace all unsuccessful geonames that returned NA value

Step 3: write queries

Combine updated info in Excel spreadsheet. See RM-2408 for attached excel spreadsheet

SQL update statements here: https://gist.github.com/dlebauer/e76c6bec32b1d29f1a16

Step 4: Executed queries