[R-sig-Geo] What is the Coordinate Reference System?

Michael Sumner md@umner @ending from gm@il@com
Fri Jun 15 00:42:02 CEST 2018


Try raster::projection(raster::raster(a)) first, then delve if necessary
into the ncdump summary with print(raster::raster(a)))

But, raster(a) may be enough here? To get that stuff more directly from the
NetCDF API you have to use the inq and att functions of ncdf4 or RNetCDF
and that's no fun.

I'd also try raster(rgdal::readGDAL(a)) which is a totally different but
equivalent read path.

Cheers, Mike

On Thu, 14 Jun 2018, 11:03 Sergio Ibarra, <zergioibarra using gmail.com> wrote:

> Greetings,
>
> I'm want to read NetCDF spatial data from a meteorological model (WRF
> model). The NetCDF can have one of these three projections:
>
> Polar stereographic
> Lambert conformal
> Mercator projection
>
> (See figure
>
> https://user-images.githubusercontent.com/27447280/41389756-ed23f91a-6f68-11e8-961e-6ba901913c54.png
> )
>
> What is the  Coordinate Reference System for each case?
>
> Thanks!
>
> Here an example with ncdf4 and raster:
>
> library(ncdf4)
> library(raster)
> a <- tempfile()
> download.file(url = "
> http://www.unidata.ucar.edu/software/netcdf/examples/wrfout_v2_Lambert.nc
> ",
>               destfile = a) #78 Mb
> wrf <- nc_open(a)
> paste("The file has",wrf$nvars,"variables")
> paste("The file has",names(wrf$var))
> lat <- ncvar_get( wrf, "XLAT" )
> lon <- ncvar_get( wrf, "XLONG" )
> t2 <- ncvar_get( wrf, "T2" ) - 273.15
> dim(t2) #73 60 13
> #image
> image(t2[, , 12])
> # raster
> rt2 <- raster(t(t2[1:dim(t2)[1],
>                    dim(t2)[2]:1,
>                    12]),
>               xmn = min(lon),
>               xmx = max(lon),
>               ymn = min(lat),
>               ymx = max(lat),
> *              crs="+init=epsg:4326") # ???*
> spplot(rt2)
>
>
>
> --
> ​Sergio Ibarra Espinosa
> Post Doc
> PhD in Atmospheric Sciences
> Instituto de Astronomia, Geofísica e Ciências Atmosféricas
> Universidade de São Paulo
> Rua do Matão, 1226
> São Paulo-SP - Brasil -
> 05508-090
> +55-11-97425-3791
> Skype: sergio_ibarra1
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list