shapefile到R中的神经网络 [英] shapefile to neural network in R

查看:60
本文介绍了shapefile到R中的神经网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 R 的神经网络中转换道路类型 SpatialLinesDataFrame 的 shapefile (ESRI).

I need to convert a shapefile (ESRI) of roads type SpatialLinesDataFrame in a neural network in R.

我不知道如何删除形状的节点或顶点.确定节点之间每条边的长度.通过这些参数,我可以使用数据包(网络)创建网络.

I do not know how to remove nodes or vertices of the shape. Determine the length of each edge between nodes. With these parameters I can create the network using the packet (network).

总结:R 中 igraph 网络的输入 shapefile.

Summary: Input shapefile for the igraph network in R.

来自智利南部的感谢.

推荐答案

来试试看 --

library(rgdal)
library(igraph)

dsn <- system.file("vectors", package = "rgdal")[1]
sl <- readOGR(dsn=dsn, layer="kiritimati_primary_roads")
lines2xcoord <- function(lns) sapply(lns@Lines, function(l) l@coords[,1])
lines2ycoord <- function(lns) sapply(lns@Lines, function(l) l@coords[,2])

x <- unlist(sapply(sl@lines, lines2xcoord))
y <- unlist(sapply(sl@lines, lines2ycoord))

g <- graph.empty(n=length(x), directed=FALSE)
V(g)$lat <- x
V(g)$lng <- y
e <- c(t(matrix(c(head(V(g),-1),tail(V(g),-1)), ncol=2)))
add.edges(g,e)

现在 g 是带有线条的 igraph.但是,它错误地假定要连接的 shapefile 中的行.此外,在本例中,它不存储纬度/经度,而是存储投影坐标.

Now g is an igraph with the lines. It assumes incorrectly the lines in the shapefile to be connected, though. Also, it does not store lat/lon in this example, but the projected coordinates.

这篇关于shapefile到R中的神经网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆