[NARCCAP-discuss] 答复: epsg value for CRCM-cgcm3 model

Jianhua Huang jh.eco.cas at gmail.com
Wed Nov 13 22:54:16 MST 2013


Hi Oleksandr:

If you have the shape file for states or country, I think you can add it to the plot by using geom_polygon() function. 

library(maptools)
shp <- readShapePoly('shape.file.shp')

 ggplot(data = grid, aes(lon.proj, lat.proj, colour = sub_ac_ctr_col), asp = 1) +
geom_point(shape = 15, size = 3) +
scale_colour_manual(name = 'Legend', values = sapply(6:0/18, hsv)) +
theme_set(theme_gray(base_size = 18)) +
 guides(col = guide_legend(reverse=TRUE)) +   
ggtitle('Title') +
geom_polygon(data = shp, aes(x = lat, y= lon))

I don't have a shape file in hand, so I can't test it. But I think it will work.

Jianhua



-----邮件原件-----
发件人: narccap-discuss-bounces at mailman.ucar.edu [mailto:narccap-discuss-bounces at mailman.ucar.edu] 代表 Oleksandr Huziy
发送时间: Wednesday, November 13, 2013 2:59 PM
收件人: Discussion of NARCCAP data - uses and questions
主题: Re: [NARCCAP-discuss] epsg value for CRCM-cgcm3 model

Hi Jianhua:

Thank you for the script. Is there an easy way to make it plot coastlines, state and country borders?
Is csv file obligatory?

Cheers



2013/11/13 Jianhua Huang <jh.eco.cas at gmail.com>

> Hi Oleksandr:
>
> Thanks much for the projection information. That is a perfect projection.
>
> Regarding your question about the R code, if you just want to plot the 
> netcdf directly, you can use the image() function.
> Taking the 3-hourly temperature data from CRCM-cgcm3 model as an example:
>
> nc <- open.ncdf('tas_CRCM_cgcm3_1991010103.nc')  # read the metadata 
> for the netcdf file tas <- get.var.ncdf(nc, 'tas', count = c(140, 115, 
> 1))  # extract the data you want
> image(tas)  #this will show you the figure
>
> For my purpose, I need to extract the data for the United States, and 
> display it with projection. The code looks like this:
>
> library(ggplot2)
> grid <- read.csv('grid.example.csv')
> ggplot(data = grid, aes(lon.proj, lat.proj, colour = sub_ac_ctr_col), 
> asp = 1) +
>   geom_point(shape = 15, size = 3) +
>   scale_colour_manual(name = 'Legend', values = sapply(6:0/18, hsv)) +
>   theme_set(theme_gray(base_size = 18)) +
>   guides(col = guide_legend(reverse=TRUE)) +   ## used to reverse the
> legends
>   ggtitle('Title')
>
> The grid.example.csv file and the output figure are attached.
>
> Jianhua
>
>
>
> -----Original Message-----
> From: narccap-discuss-bounces at mailman.ucar.edu [mailto:
> narccap-discuss-bounces at mailman.ucar.edu] On Behalf Of Oleksandr Huziy
> Sent: Tuesday, November 12, 2013 11:26 AM
> To: Discussion of NARCCAP data - uses and questions
> Subject: Re: [NARCCAP-discuss] epsg value for CRCM-cgcm3 model
>
> Try using this one:
>
> '+lon_0=263.0 +lat_ts=90.0 +R=6370997.0 +proj=stere +x_0=10691802.4659
> +units=m +y_0=10691802.4659 +lat_0=90.0 '
>
> This one was plotted using the above projection.
> [image: Images intégrées 1]
>
>
> 2013/11/12 Oleksandr Huziy <guziy.sasha at gmail.com>
>
> > Ah, no, sorry, I've messed up, the one there is not latlon, it is 
> > rotated north polar stereographic (smth like that)...
> > sorry for the confusion...
> >
> > Cheers
> >
> >
> > 2013/11/12 Oleksandr Huziy <guziy.sasha at gmail.com>
> >
> >> Hi Jianhua:
> >>
> >> It is rotated lat/lon, the proj4string is smth like this:
> >> +o_proj=longlat +lon_0=<your true pole longitude in this crs>-180 
> >> +o_lat_p=<your true pole latitude> +R=6370997.0 +proj=ob_tran
> >> ++units=m o_lon_p=<longitude of the rotated pole in the true 
> >> ++lat/lon>
> >>
> >>
> >> those things in <> could be found in the header of the netcdf file.
> >>
> >> Can you show me your plotting code? I've never done it in R, though 
> >> tried, and abandoned, seems to complicated))
> >>
> >> It would be great to have a working example code with data attached 
> >> to it (just one field for one time step)
> >>
> >> thanks
> >>
> >> Cheers
> >>
> >>
> >>
> >> 2013/11/11 Jianhua Huang <jh.eco.cas at gmail.com>
> >>
> >>> Hi:
> >>>
> >>>
> >>>
> >>> I am trying to plot the netcdf file from CRCM-cgcm3 in R. There 
> >>> are some gaps between the grid cells when I used "+proj=longlat
> >>> +datum=WGS84" as projection. When I transfer the projection with 
> >>> +the
> >>> following function, it improves a little.
> >>>
> >>>
> >>>
> >>> sp.grid.proj <- spTransform(sp.grid, CRS('+init=epsg:3979'))
> >>>
> >>>
> >>>
> >>> Unfortunately, I don't know the exact epsg value I should for the
> >>> CRCM-cgcm3
> >>> model. Thank for any suggestion.
> >>>
> >>>
> >>>
> >>> Jianhua
> >>>
> >>> _______________________________________________
> >>> narccap-discuss mailing list
> >>> narccap-discuss at mailman.ucar.edu
> >>> http://mailman.ucar.edu/mailman/listinfo/narccap-discuss
> >>>
> >>
> >>
> >>
> >> --
> >> Sasha
> >>
> >
> >
> >
> > --
> > Sasha
> >
>
>
>
> --
> Sasha
>
> _______________________________________________
> narccap-discuss mailing list
> narccap-discuss at mailman.ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/narccap-discuss
>
>


--
Sasha
_______________________________________________
narccap-discuss mailing list
narccap-discuss at mailman.ucar.edu
http://mailman.ucar.edu/mailman/listinfo/narccap-discuss



More information about the narccap-discuss mailing list