[R-sig-Geo] SpatialLine from Line-object

Rafael Wüest rafael.wueest at gmail.com
Mon Jan 20 17:42:08 CET 2014


Hi Jaqueline

t.lines1 <- SpatialLines(list(Lines(t.linelist, ID=1)))

should do it not that in ?SpatialLines

...
SpatialLines(LinesList, proj4string = CRS(as.character(NA)))
...
LinesList is supposed to be a "list with objects of class Lines-class"

HTH,
Rafael


On 20.01.14 17:00, Jacqueline Schweizer wrote:
>
> Hello everybody,
>
> I am trying to make a commuter-map, where lines going from one region to all the surrounding regions represent the amount of commuters by there thickness.
>
> Let's say I do this for region number 1: I create a dataframe with all the coordinate couples of an inner point of region number 1 to the inner points of 2 surrounding regions. then I make a loop, that creates a list containing all the single lines from this point.
>
> Now for my mapping, I'd like to have a SpatialLineDataFrame -> somehow I cannot create a SpatialLine form my Line-object. Firstly I create the list with all the single Line-objects in it. Then I create a Lines-object by just simply adding an ID. For the SpatialLines I seem to need a proj4string-specification? I tried to use one of a different Shapefile, that uses the same coordinate-system etc. but that doesnt work.
>
> I am sure this is a basic problem, can anyone help me?
> Thanks in advance
>
> Jacqueline
>
>
>
>
>
> t.coord <- data.frame(gemvon=c(1,1), gemnach=c(1,2), XCOORD_1= c(682460.5, 682460.5), YCOORD_1=c(248579.4, 248579.4), XCOORD_2 <- c(685766.5, 674783.5), YCOORD_2 <- c(253025.6, 248746.7))
> head(t.coord)
> #  gemvon gemnach XCOORD_1 YCOORD_1 XCOORD_2 YCOORD_2
> #1      1       1 682460.5 248579.4 685766.5 253025.6
> #2      1       2 682460.5 248579.4 674783.5 248746.7
>
>
> # list of single lines (as an example: only two lines)
>
> t.linelist 	<- list()
>
> for (j in 1:2) {
>
> t.linelist[[j]]			<- Line(rbind(c(t.coord[j, 3], t.coord[j, 4]), c(t.coord[j, 5], t.coord[j, 6])) )
> }
>
> t.linelist
>
> [[1]]
> An object of class "Line"
> Slot "coords":
>           [,1]     [,2]
> [1,] 682460.5 248579.4
> [2,] 685766.5 253025.6
>
>
> [[2]]
> An object of class "Line"
> Slot "coords":
>           [,1]     [,2]
> [1,] 682460.5 248579.4
> [2,] 674783.5 248746.7
>
> t.lines1 <- SpatialLines(Lines(t.linelist, ID=1) )
>
> Fehler in as.list.default(X) :
>    Keine Methode um diese S4 Klasse in einen Vektor zu verwandeln
>
>
>
>
>
>
>
> Disclaimer\ \ Die in dieser E-Mail enthaltenen Informati...{{dropped:27}}
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Rafael Wüest
rafael.wueest at gmail.com
http://www.rowueest.net



More information about the R-sig-Geo mailing list