[R-sig-Geo] plot projected map
Dylan Beaudette
dylan.beaudette at gmail.com
Fri Aug 29 17:52:26 CEST 2008
On Friday 29 August 2008, Rosa Trancoso wrote:
> Hello,
>
> I have the same problem as Costas Douvis, reported in
> https://stat.ethz.ch/pipermail/r-sig-geo/2008-June/003713.html
>
> 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:
>
> library(sp)
> df <- data.frame(lat=as.numeric(xlat), lon=as.numeric(xlon),
> z=as.numeric(hgt))
> coordinates(df) <- ~lon+lat # SpatialPointsDataFrame
> proj4string(df) <- CRS("+proj=lcc +a=637000 +lat_1=30 +lat_2=60 +lat_0=40
> +lon_0=-7.5")
> 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.
Cheers,
Dylan
--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341
More information about the R-sig-Geo
mailing list