igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] input shapefile to build graph-using R


From: Gábor Csárdi
Subject: Re: [igraph] input shapefile to build graph-using R
Date: Wed, 4 Feb 2015 13:29:39 -0500

You have NAs as vertex names I guess. Replace them with something else. 

Gabor

On Mon, Feb 2, 2015 at 12:36 AM, Hao Wang <address@hidden> wrote:
When using igraph to do network analysis- computing closeness for road network, I confront these problems. I am trying to input shapefile data(line and vertex), the R code is as follows:
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_ND_Junctions.shp",proj4string=CRS("+proj=Mercator_Auxiliary_Sphere +datum=WGS84"))

Then errors occurs when trying to build graph using function "graph.data.frame":
> g <- graph.data.frame(pl, directed=FALSE, vertices=pt)
Error in graph.data.frame(pl, directed = FALSE, vertices = pt) : 
  Duplicate vertex names
Warning:
In graph.data.frame(pl, directed = FALSE, vertices = pt) :
  In `d' `NA' elements were replaced with string "NA"

Could anyone help me to solve these problems, thank you very much.
------------------
Hao Wang
Institute of Geomatics,
Department of Civil Engineering, 
Tsinghua University,
Haidian District, Beijing 100084, P.R. China
 

_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help



reply via email to

[Prev in Thread] Current Thread [Next in Thread]