[R-sig-Geo] proj4string error on data.frame generated from NCEP data

Maggie CY Lau maglau at Princeton.EDU
Thu Apr 7 16:24:01 CEST 2016


HI all,

I am an ecologist who would like to use several datasets generated by NCEP reanalysis. I attempted to use the R package "RNCEP" to extract the data and generate .tiff files. These files will be analyzed by a student using ArcMap. I created the data fame with the information I need, but had problem exporting the data into .tiff file that can be projected in polar stereograph in ArcMap. The use of "+proj=longlat + datum=WGS84" gave the following error message:

Error in `proj4string<-`(`*tmp*`, value = <S4 object of class "CRS">) :
  Geographical CRS given to non-conformant data: 91.25

Then I tried using ""+proj=stere +lat_0=90 +lat_ts=60 +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs". proj4string went fine but the export tiff appeared as a box image instead of an angular one.

Please kindly check the following codes from the line "library(sp)" onward.

Thanks,
Maggie Lau

====
install.packages("RNCEP", dependencies=TRUE)
install.packages(c('abind', 'maps', 'fields', 'tgp', 'fossil'), dependencies=TRUE)
install.packages("raster")
install.packages("rgdal")

library(RNCEP)
air.sig995.extent <- NCEP.gather(variable='air.sig995', level='surface', months.minmax=c(7),
years.minmax=c(2011), lat.southnorth=c(60,89.9), lon.westeast=c(-179,180),
reanalysis2=FALSE, return.units=TRUE)
air.sig995.ag <- NCEP.aggregate(wx.data=air.sig995.extent, YEARS=TRUE, MONTHS=TRUE,
DAYS=FALSE, HOURS=FALSE, fxn='mean')
dimnames(air.sig995.ag)[[3]][1]
air.sig995.ag.df <- NCEP.array2df(air.sig995.ag[,,1], var.names = 'Temperature')

library(sp)
coordinates(air.sig995.ag.df) <- ~longitude+latitude
gridded(air.sig995.ag.df) <- TRUE
crs <- "+proj=longlat + datum=WGS84"
proj4string(air.sig995.ag.df) <- CRS(crs)
#stere <- "+proj=stere +lat_0=90 +lat_ts=60 +lon_0=0
# +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
#proj4string(air.sig995.ag.df) <- CRS(stere)

library(raster)
ras <- raster(air.sig995.ag.df)
writeRaster(ras, 'air.sig995.Jul.ag.tif', overwrite=TRUE)




	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list