[R-sig-Geo] plot projected map
dylan.beaudette at gmail.com
Fri Aug 29 17:52:26 CEST 2008
On Friday 29 August 2008, Rosa Trancoso wrote:
> I have the same problem as Costas Douvis, reported in
> I have a matrix of values, a matrix of latitudes and a matrix of
> longitudes. The map is "rectangular" in the Lambert projection. So I did
> the following:
> df <- data.frame(lat=as.numeric(xlat), lon=as.numeric(xlon),
> coordinates(df) <- ~lon+lat # SpatialPointsDataFrame
> proj4string(df) <- CRS("+proj=lcc +a=637000 +lat_1=30 +lat_2=60 +lat_0=40
> spplot(df, scales=list(draw=TRUE))
> But the map is no projected (it should be a rectangle),
> As I want to have lat/lon on the axis of the map, and automatically produce
> lots of maps, converting everything to lcc is not straightforward.
> I am missing something? Any other packages?
I don't often perform spatial transforms in R, but it looks like there is a
fundamental flaw in your code, and it should look something like this:
1. setup SpatialPointsDataFrame
2. assign the CRS as 'proj=lonlat datum=...'
3. invoke the projection method, with the target projection = "+proj=lcc
+a=637000 +lat_1=30 +lat_2=60 +lat_0=40 +lon_0=-7.5"
4. the result should be in the target projection.
Soil Resource Laboratory
University of California at Davis
More information about the R-sig-Geo