Close Spatial Lines into a Polygon
On Wed, 30 Dec 2009, Rodrigo Aluizio wrote:
Hi Sig list, I?m really new representing spatial data, but I?m already able to create excellent maps using sp, maptools and mapdata packages. Anyway, I have a SpatialLines object (attached) which I would like to ?close? and turn it into a SpatialPolygon, so I can fill it with a color. The object already posses some closed lines (islands) but the entire area is wide open. To make things easier it could be closed at the ocean side (right side, if plotted), so there will be no need to deal with the open and closed areas. This ?closure? may be done as the coast line was and hypotenuse of a rectangular triangle. Is there a way to do so? I was looking for something similar to that in the R site search, but I didn?t found a total match with my issue, or maybe I?m too new to that, so I wasn?t even able to recognize a solution J.
The general answer is in chunks 66 and 71 in the code from our book, see: http://www.asdar-book.org/book/cm_mod.R That leaves one small unclosed island in the NE, plus the coastline. If you want to colour the land, you need to close these two manually to the E, N, and S bounding box values, and something extra to the west, probably by extracting and re-inserting the coords slots of the two "Line" objects. Hope this helps, Roger
Thank you for your attention and sorry if the question was already answered. ------------------------------------------------------------- MSc. <mailto:r.aluizio at gmail.com> Rodrigo Aluizio Centro de Estudos do Mar/UFPR Laborat?rio de Micropaleontologia
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