Thanks, one clarification:
If I do:
> data(kola.background)
> xy <- kola.background$coast
> names(xy) <- c("x", "y")
> class(xy)
[1] "data.frame"

How is it that I can run successfully:
coast <- map2SpatialLines(xy)

if the help page states that the argument must be of "map" class?:
map2SpatialLines(map, IDs=NULL, proj4string = CRS(as.character(NA)))
Arguments
mapa map object defined in the maps package and returned by the map function
?

Also,
> str(coast,max.level=2)
Formal class 'SpatialLines' [package "sp"] with 3 slots
  ..@ lines      :List of 142
  ..@ bbox       : num [1:2, 1:2] 378389 7388684 865816 7900281
  .. ..- attr(*, "dimnames")=List of 2
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots

which is the criteria by which  map2SpatialLines() starts a new line?

Just in case anybody might be curious, after doing what you suggested, I do
the following to save as shape:
require(rgdal)
str(coast,max.level=2) #from which I know there are 142 Lines
coastdata <- data.frame(ID=1:142,name=rep("",142),stringsAsFactors=F)
row.names(coastdata) <- 1:142
coast <- SpatialLinesDataFrame(sl=coast, data=coastdata, match.ID = TRUE)
writeOGR(coast,dsn="Kolacoast",layer="Kolacoasts",driver="ESRI Shapefile")

Agus

2010/1/26 Roger Bivand <roger.biv...@nhh.no>

> On Tue, 26 Jan 2010, Agustin Lobo wrote:
>
>  Hi!
>> Package StatDA
>> provides background geoinformation as a set of coordinates:
>>
>>> str(kola.background)
>>>
>> List of 4
>> $ boundary:'data.frame':       50 obs. of  2 variables:
>>  ..$ V1: num [1:50] 388650 388160 386587 384035 383029 ...
>>  ..$ V2: num [1:50] 7892400 7881248 7847303 7790797 7769214 ...
>> $ coast   :'data.frame':       6259 obs. of  2 variables:
>>  ..$ V1: num [1:6259] 438431 439102 439102 439643 439643 ...
>>  ..$ V2: num [1:6259] 7895619 7896495 7896495 7895800 7895542 ...
>> $ borders :'data.frame':       504 obs. of  2 variables:
>>  ..$ V1: num [1:504] 417575 417704 418890 420308 422731 ...
>>  ..$ V2: num [1:504] 7612984 7612984 7613293 7614530 7615972 ...
>> $ lakes   :'data.frame':       6003 obs. of  2 variables:
>>  ..$ V1: num [1:6003] 547972 546915 NA 547972 547172 ...
>>  ..$ V2: num [1:6003] 7815109 7815599 NA 7815109 7813873 ...
>>
>> is there any spatial function aready availale to convert these coordinates
>> into Spatial Lines and Spatial Polygons?
>>
>
> This seems to work at least for SpatialLines - for polygons, the rings may
> need to be closed:
>
> library(StatDA)
> data(kola.background)
> xy <- kola.background$boundary
> names(xy) <- c("x", "y")
> library(maptools)
> bdy <- map2SpatialLines(xy)
> plot(bdy)
>
> The data are in the legacy S format (like the maps package).
>
> Roger
>
>
>
>> Thanks
>>
>> Agus
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
> --
> 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.biv...@nhh.no
>
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to