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

From: Vladimir Eremeev <>
Date: Thu 05 Apr 2007 - 09:29:52 GMT

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.

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.

View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Apr 05 19:34:10 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.