Skip to content

Instantly share code, notes, and snippets.

@emhart
Created June 4, 2014 23:39
Show Gist options
  • Save emhart/53324b5a6635988754dc to your computer and use it in GitHub Desktop.
Save emhart/53324b5a6635988754dc to your computer and use it in GitHub Desktop.
library(sp)
library(raster)
### Data source: http://nadp.sws.uiuc.edu/ntn/annualmapsByYear.aspx#2012
### Sites provided by sarah
# Load up our data
depF<-'NO3_dep_2012.tif'
concF<-'NO3_conc_2012.tif'
sites <- read.csv("neonsites.csv")
unprojDep <- raster(depF)
projDep <- projectRaster(from = unprojDep,crs=" +init=EPSG:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 ")
unprojConc <- raster(concF)
projConc <- projectRaster(from = unprojConc,crs=" +init=EPSG:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 ")
sites <- SpatialPoints(sites[,7:6],proj4string =CRS("+init=EPSG:4326") )
# extract data
pointDep <- unlist(extract(projDep,ll,buffer = 1000))
pointConc <- unlist(extract(projConc,ll,buffer = 1000))
# Plot our data
myext <- extent(c(-85.5,-65.5,35,50))
par(mfrow=c(1,2))
plot(projDep, ext = myext)
points(ll,pch=19,cex=.8)
plot(projConc,ext=myext)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment