Re: [R-sig-Geo] Antw: Creating a spatialPolygonsDataFrame from a data frame

2012-10-07 Thread steven mosher
Ok, I'll try that. It looks like some of the G-ring coordinates are specified in such a way that it wraps around the globe the wrong way.. if that makes any sense.. so if the Long straddles the -180/180 I get bogus results. On Sun, Oct 7, 2012 at 12:30 PM, Robert J. Hijmans wrote: > > Steve/Ma

Re: [R-sig-Geo] Antw: Creating a spatialPolygonsDataFrame from a data frame

2012-10-07 Thread Robert J. Hijmans
Steve/Matteo, Or like this using (s)apply: m <- as.matrix(DF) z <- apply(m, 1, function(x) Polygon(matrix(x[c(3:10, 3:4)], ncol=2, byrow=T))) n <- names(z) y <- sapply(1:length(n), function(i) Polygons(z[i], n[i])) sp <- SpatialPolygons(y, proj4string=CRS('+proj=longlat')) spdf <- SpatialPolygons

[R-sig-Geo] Antw: Creating a spatialPolygonsDataFrame from a data frame

2012-10-07 Thread Matteo Mattiuzzi
Hi Steve, what about this? DF <- structure(list(v = c(4L, 4L, 4L, 4L, 4L, 4L, 4L), h = 8:14, ll_lon = c(-131.0149, -117.7464, -104.5202, -91.3388, -78.2083, -65.15, -52.1199), ll_lat = c(39.7081, 39.7342, 39.7557, 39.7728, 39.7858, 39.7937, 39.7994), ul_lon = c(-156.8405, -140.7952, -124.88