具有R tkplot的地理坐标的问题

问题描述 投票:0回答:1

我想使用地理坐标对图形的顶点进行空间化(epsg:27572),但是当我使用tkplot函数tkplot.setcoords()时,坐标为“中心”,出现一个0,空间化是真实的镜像对称。职位。一个例子:

library(igraph)
library(tcltk)

relations <- read.table(header=TRUE, check.names= FALSE, textConnection("
  A B      x       y
1 1 2 762920 1872674
2 2 3 778202 1899896
3 3 5 746324 1859111
4 4 5 762920 1872674
5 5 6 762920 1872674
6 6 3 762920 1872674"))

g1 <- graph.data.frame(relations, directed=TRUE)

# fill vertex attributes with coordinates of the table 'relations'
for(i in 1:length(V(g1))){
  for(j in 1:nrow(relations)){
    if(V(g1)[i]$name==as.character(relations$A[j])){
      V(g1)[i]$coordx <- relations$x[j]
      V(g1)[i]$coordy <- relations$y[j]
    }
  }
}
list.vertex.attributes(g1)

# plot the spatialised graph
coords <- cbind(V(g1)$coordx, V(g1)$coordy)
id <- tkplot(g1)
tkplot.setcoords(id, coords)
tkplot.center(id)
tkplot.fit.to.screen(id)

问题是coords与最初的相比已被转换:

> tkplot.getcoords(id)
       [,1]  [,2]
[1,] 762920 27222
[2,] 778202     0
[3,] 746324 40785
[4,] 762920 27222
[5,] 762920 27222
[6,] 762920 27222

很显然,坐标的第二列已“居中”为0。tk窗口的右下角出现一个节点。

r igraph tkplot
1个回答
0
投票
也许尝试原始值:

coords <- cbind(relations$x, relations$y)

© www.soinside.com 2019 - 2024. All rights reserved.