[R-sig-Geo] input shapefile to build graph-using R
Roger Bivand
Roger.Bivand at nhh.no
Mon Feb 2 12:13:59 CET 2015
On Mon, 2 Feb 2015, Frede Aakmann Tøgersen wrote:
> Dear "whoever you are"
>
> You give way to little information in order to make us able help you.
> Just posting a jpg image of the error message already presented doesn't
> help either.
Exactly. In addition, the JPG is only on Nabble (with advertisements), and
not on the actual list.
What puzzles me most is why the OP thinks that the input objects d and
vertices (which should be data.frame objects) are the
SpatialLinesDataFrame and SpatialPointsDataFrame objects read with (very)
outdated functions in maptools. d should be:
"A data frame containing a symbolic edge list in the first two columns.
Additional columns are considered as edge attributes."
Reading the help pages of functions one uses, and checking that the
objects being passed as argument values actually meet the conditions
stipulated, should really come before posting a question. Reading the
posting guide is also warmly reccommended.
Roger
>
> Posting the following will probably enable us to help you better.
>
> 1) Immediately after the error show the output from a call to traceback()
> 2) If not providing the data, then show calls to str() on the imported data, 'lt' and 'pt'
> 3) Provide the output from sessionInfo()
>
>> From the error message:
>
>> Error in graph.data.frame(pl, directed = TRUE, vertices = pt) :
>> Duplicate vertex names
>
> it seems like the vertices in the pt object has not been named in an unique way since that is probably needed.
>
> Also from the warning the error just above seems to be related to the namings of the vertices. More than one vertex was missing an ID:
>
>> In addition: Warning message:
>> In graph.data.frame(pl, directed = TRUE, vertices = pt) :
>> In `d' `NA' elements were replaced with string "NA"
>
> graph.data.frame seems to convert factor vector to a vector of strings which in this case gives identical ids with names NA.
>
> By the way, on many email lists it would be seen courteously of you to provide you affiliation so people can see who they are dealing with.
>
>
> Yours sincerely / Med venlig hilsen
>
>
> Frede Aakmann Tøgersen
> Specialist, M.Sc., Ph.D.
> Plant Performance & Modeling
>
> Technology & Service Solutions
> T +45 9730 5135
> M +45 2547 6050
> frtog at vestas.com
> http://www.vestas.com
>
> Company reg. name: Vestas Wind Systems A/S
> This e-mail is subject to our e-mail disclaimer statement.
> Please refer to www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>
>
>> -----Original Message-----
>> From: R-sig-Geo [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of
>> silverlining
>> Sent: 2. februar 2015 09:32
>> To: r-sig-geo at r-project.org
>> Subject: Re: [R-sig-Geo] input shapefile to build graph-using R
>>
>>> # Load libraries
>>> library(spdep)
>>> library(igraph)
>>> library(maptools)
>>> pl <- readShapeLines("H:/data/Beijing_NatrualRoads.shp",
>> + proj4string=CRS("+proj=Mercator_Auxiliary_Sphere +datum=WGS84"))
>>> pt <-
>> readShapePoints("H:/data/Beijing_NatrualRoads_computejunctions.shp",
>> + proj4string=CRS("+proj=Mercator_Auxiliary_Sphere +datum=WGS84"))
>>> g <- graph.data.frame(pl, directed=TRUE, vertices=pt)
>> Error in graph.data.frame(pl, directed = TRUE, vertices = pt) :
>> Duplicate vertex names
>> In addition: Warning message:
>> In graph.data.frame(pl, directed = TRUE, vertices = pt) :
>> In `d' `NA' elements were replaced with string "NA"
>>> cl<-closeness(g, mode = c("out"),weights = NULL, normalized = TRUE)
>> Error in match(x, table, nomatch = 0L) : object 'g' not found
>>>
>> <http://r-sig-geo.2731867.n2.nabble.com/file/n7587719/R_error.jpg>
>>
>>
>>
>> --
>> View this message in context: http://r-sig-
>> geo.2731867.n2.nabble.com/input-shapefile-to-build-graph-using-R-
>> tp7587718p7587719.html
>> Sent from the R-sig-geo mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list