0

I am still a beginner to R and I have the following problem. Any tips will be highly appreciated - it will be a big help to start off. I have a road shapefile for one country in ArcGIS, that I would like to use as a network variable in R to apply network K-function (look for point randomness on the network using spatstat package). I have never worked with this type of problem before in R and I can't figure out how to convert the vector line dataset into network variable in R. I tried to used the shapefile package, but after reading the .shp, .shx and .dbf files, I don't know how it can be used any further.

mihoo
  • 157
  • 3
  • 12
  • 1
    As a starting point, please add to the question the code you have already written, preferably with a link to the shapefile. If you can make the question [fully reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) that would be even better. – SlowLearner Oct 02 '13 at 11:08
  • I have taken a cursory look at the `spatstat` package and it looks like you will need a `ppp` (point pattern) object. Even if you can extract the vector line set from the shapefile, how will you reduce or convert that to a set of points? Will you take a sample every 1km, for example? If you include all the points that make up the line of the roads surely you will have far too many, non-meaningful points? I do not know the answer to this, I am just curious. – SlowLearner Oct 02 '13 at 11:16

1 Answers1

1

The comments above are not correct.

In the spatstat package, first convert your shapefile to an object of class "psp" (planar segment pattern) as explained in the accompanying vignette on shapefiles.

Then use the function as.linnet to convert the "psp" object to a linear network object of class "linnet".

For more explanation, see chapter 17 of the spatstat book.

Adrian Baddeley
  • 1,956
  • 1
  • 8
  • 7