[R-sig-Geo] input shapefile to build graph-using R

Frede Aakmann Tøgersen frtog at vestas.com
Mon Feb 2 11:13:47 CET 2015


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.

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



More information about the R-sig-Geo mailing list