[R-sig-Geo] SpatialPoints problem

Johan Van de Wauw johan.vandewauw at gmail.com
Sun Sep 30 20:38:34 CEST 2007


On 9/30/07, Stoitchko Kalenderski <SKalenderski at eos.ubc.ca> wrote:
> Hi All,
> I am trying to create a grid but something getting wrong
> here is the code
>
> rm(list=ls())
> library(maptools)
> library(rgdal)
>
> options("digits"=22)
> lat=seq(from= -123.4, to= -121.4, length=20)
> long=seq(from=48.95, to=49.5, length=10)

latitude cannot be <-90, that's why setting the projection string will
fail. I guess you mixed up latitude and longitude!

> #generates the grid
> grd = expand.grid(lat,long)
> sp_grd <- SpatialPoints(cbind(grd[,2],grd[,1]), proj4string=CRS("+proj=longlat +datum=WGS84"))
> #do projection
>
> spTransform(sp_grd,CRS("+proj=merc +datum=WGS84"))
>
>
>
> any hint is appreciated
>
> thx
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>




More information about the R-sig-Geo mailing list