An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110313/896b0559/attachment.pl>
SpatialLines2PolySet with Albers equal area projection?
2 messages · Sharon Baruch-Mordo, Roger Bivand
On Sun, 13 Mar 2011, Sharon Baruch-Mordo wrote:
Hello list, ?? I???m trying to create a SpatialPolygonsDataFrame from an object of class list (x), which has coordinates for contour lines in Albers equal area (full parameters below). I???m executing the following code: ?? CRSdata <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs +towgs84=0,0,0" sldf <- ContourLines2SLDF(x) proj4string(sldf) <- CRS(CRSdata) ps <- SpatialLines2PolySet(sldf) ?? #so far so good; continue: ?? sp <- PolySet2SpatialPolygons(ps) ?? # I get the following error: ?? Error in PolySet2SpatialPolygons(ps) : unknown coordinate reference system
As was explained in thread starting at: https://stat.ethz.ch/pipermail/r-sig-geo/2011-March/011152.html "PBSmapping "knows" unprojected (geographical coordinates) and UTM (projected coordinates) with a zone number. It does not provide facilities to store any other values." So unless you project to utm or longlat first and back again afterwards, you are stuck. ?PolySet does state the limitation. Roger
?? #what I was hoping to continue executing (which works great with UTM data sets where I defined attr(ps,???projection???) <- ???UTM??? and attr(ps,???zone???) <- ???17N???) ??is: ?? dataframe <- as.data.frame(matrix(as.character(1,nrow=1,ncol=1))) spdf <- SpatialPolygonsDataFrame(sp,dataframe,match.ID=TRUE) ?? Because Albers isn???t ???UTM??? nor ???LL??? I???m not sure what projection to specify for the PolySet object (i.e., attr(ps,???projection???)) in order to properly convert PolySet2SpatialPolygons. Any thoughts or suggestions??? I would also welcome any comments if I???m using an unnecessary long code to convert the list of contour line x/y points into a spatial polygon with the goal of calculating its area in R and exporting it into an ESRI shapefile. ?? Thanks! Sharon ?? Sharon Baruch-Mordo Ph.D. Candidate in Ecology Dept. of Fish, Wildlife, and Conservation??Biology Colorado State University Fort Collins, CO 80523-1474 Phone: 970-491-7020?? Fax: 970-491-5091 E-mail: sharonbm at warnercnr.colostate.edu http://www.warnercnr.colostate.edu/research/bear [[alternative HTML version deleted]]
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