Hi All, 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! Linda [[alternative HTML version deleted]]
Vladimir Eremeev
2007-Apr-05 09:29 UTC
[R] how to image.plot a XY grid file into a lat-lon map
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: http://www.nabble.com/how-to-image.plot-a-XY-grid-file-into-a-lat-lon-map-tf3528721.html#a9852612 Sent from the R help mailing list archive at Nabble.com.
http://r-spatial.sourceforge.net 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! > > Linda >-- View this message in context: http://www.nabble.com/how-to-image.plot-a-XY-grid-file-into-a-lat-lon-map-tf3528721.html#a9852804 Sent from the R help mailing list archive at Nabble.com.
Roger Bivand
2007-Apr-05 12:31 UTC
[R] how to image.plot a XY grid file into a lat-lon map
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 e-mail: Roger.Bivand at nhh.no
Vladimir Eremeev
2007-Apr-09 10:37 UTC
[R] how to image.plot a XY grid file into a lat-lon map
Hello Linda, Friday, April 6, 2007, 2:47:43 AM, you wrote: LS> On 4/5/07, Vladimir Eremeev <wl2776 at gmail.com> wrote: VE>> If your country or state borders are polygons or polylines, you could convert VE>> them to desired projection using VE>> the function project from the package rgdal. VE>> Latitude-longitude grid also could be added by generating desired polylines VE>> in lat-lon and converting them to the desired projection using project. LS> Linda Smith wrote: LS>>> I have a netcdf gridded file with LCC projection. I can easily use LS>>> image.plot to visualize it. However, as the axises are in X,Y, not Lat and LS>>> Lon, I could not add state or country maps onto it (or lat lon LS>>> information). LS>>> I do have a grid2d file that describes the lat and lon for each (X,Y) LS>>> grid, LS>>> but the lat and lon are not regularly spaced, so I could not use LS>>> image.plot. LS>>> LS>>> Does anyone know how to plot this type of gridded data so that country or LS>>> state borders can be easily added? Thanks a lot! LS>>> VE>> What do you mean by "grid2d file that describes the lat and lon for each VE>> (X,Y) grid"? VE>> If this are two rasters of the same size having corresponding latitude and VE>> longitude values in each raster cell, then you could use contourLines to get VE>> lat-lon grid. However, you, probably, will want to smooth it. LS> Yes, they are. I could add lat and lon info?that way, but LS> still I could not use map() function to overlay state borders onto LS> my image plot because this image is not? in lat and lon LS> coordinates. I presume you are using the function map() from the maps package. ?map says that it returns a list with x, y, range, and names components. You could do something like following, for example (UNTESTED). state.borders.ll<-map("state",plot=FALSE) state.borders<-project(cbind(state.borders.ll$x,state.borders.ll$y),proj="+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100") lines(state.borders) -- Best regards, Vladimir mailto:wl2776 at gmail.com --SevinMail--
Zia Uddin Ahmed
2007-Apr-09 17:31 UTC
[R] Lagrange multiplier for ordinary kriging in gstat in R??
Does anybody know how to write the code for extracting value of LAGRANGE MULTIPLIER after ordinary prediction in "gstat" in R? Thanks! Zia -- Zia Uddin Ahmed 915 Brad Field Hall Department of Crop and Soil Cornell University Ithaca NY 14850 USA
Reasonably Related Threads
- Lat Lon NetCDF subset
- R matching lat/lon pairs from two datasets?
- from points in Lon/Lat to physical distance in dist class
- Extracting subset from netCDF file using lat/lon and converting into .csv in R
- Extracting subset from netCDF file using lat/lon and converting into .csv in R