Dear all,

I have another question or problem -- this time it is related to the transformation of a Spatial Lines shapefile into a raster.

Let me describe my problem: I want to construct a measure of travel distance from A<->B; I have obtained a shapefile of the highway network of the US; in order to compute the travel distance, I need to transform the shape into a raster -- at least that is what I have done in the past for a similar project, however, there the task was a lot simpler (computing maritime routes).

I use the following code:


#############LOAD USA HIGHWAY NETWORK
USA.highway<-readShapeLines("Shapefiles/Highways/NHPNLine.shp")


###reproject to WGS 84
proj4string(USA.highway)<- CRS("+init=epsg:4269"))
USA.highway<-spTransform(USA.highway,CRS(proj4string(USA)))


USA.highway

##spits out
class       : SpatialLinesDataFrame 
nfeatures   : 176231 
extent      : -176.764, 17.93439, -65.59364, 71.31699  (xmin, xmax, ymin, ymax)
coord. ref. : NA 
nvariables  : 42

###I reconed that -- in order to get crid-cells of roughly .less than ..1, I make the rast

tempr<-raster(nrows=4480, ncols=2080)

###not sure if i need this
setExtent(tempr, extent(USA.highway), keepres=FALSE, snap=FALSE)
###or this?
extent(tempr) <- extent(USA.highway)
###this is the rasterize
USA.highwayraster<- rasterize(USA.highway, tempr, progress='text')


Well, it basically turns out that the raster picture looks nowhere near what the original shapefile looks like; even though I thought it should.
To give you an impression, have a look at 

http://freigeist.devmag.net/wp-content/Screen-Shot-2013-07-19-at-02.19.31.png

(I cropped out Alaska as it would otherwise be not so easily visible).

I definately cant use that to compute routes as the grid basically does not have any connected roads at all!

I appreciate your thoughts, ideas and comments on what I am doing wrong,

thanks a lot
best
----
Thiemo Fetzer
London School of Economics
STICERD
Houghton Street
WC2A 2AE London
United Kingdom

office: 32L, 3.01 D
tel: +44 7411 566845
skype: thiemo.fetzer
email: t.r.fetzer@lse.ac.uk
web: www.trfetzer.com


	[[alternative HTML version deleted]]

