Re: [R] how to image.plot a XY grid file into a lat-lon map

From: Roger Bivand <>
Date: Thu 05 Apr 2007 - 12:31:40 GMT

On Thu, 5 Apr 2007, Vladimir Eremeev wrote:

> If your country or state borders are polygons or polylines, you could
> convert them to desired projection using the function project from the
> package rgdal.
> Latitude-longitude grid also could be added by generating desired
> polylines in lat-lon and converting them to the desired projection using
> project.

Yes, the route would be to plot the image in its native projection, and project the vector data (shorelines, countries) to the same projection. Similar topics have been discussed on the R-sig-geo list, including the reading of netcdf files (which are a bit picky) with functions in the rgdal package which import the coordinate reference system directly.

Please follow this up on R-sig-geo if you need more help.

> Linda Smith wrote:
> >
> > I have a netcdf gridded file with LCC projection. I can easily use
> > image.plot to visualize it. However, as the axises are in X,Y, not Lat and
> > Lon, I could not add state or country maps onto it (or lat lon
> > information).
> > I do have a grid2d file that describes the lat and lon for each (X,Y)
> > grid,
> > but the lat and lon are not regularly spaced, so I could not use
> > image.plot.
> >
> > Does anyone know how to plot this type of gridded data so that country or
> > state borders can be easily added? Thanks a lot!
> >
> What do you mean by "grid2d file that describes the lat and lon for each
> (X,Y) grid"?
> If this are two rasters of the same size having corresponding latitude and
> longitude values in each raster cell, then you could use contourLines to get
> lat-lon grid. However, you, probably, will want to smooth it.

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Apr 05 22:39:41 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 05 Apr 2007 - 13:30:44 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.