4

How do I identify certain roads ( of a line shapefile) that intersect with a layer that is produced from the reclassify tool (for raster data)? I am trying to identify which roads specifically are in the same area as the one created by the reclassify.

  • 6
    I would convert the raster to vector and go from there with an overlay tool or select by location. – Chris W Dec 4 '14 at 19:54
  • converting raster data to polygons is rarely a good idea. I would use R/raster package function 'rasterize' to count the number of lines that cross each cell and then 'mask' to only keep the cells that are of interest. – Robert Hijmans Mar 15 '15 at 22:20
1

It's not clear what set of tools you're using. This approach in R might be of value though. Essentially I convert the raster cells that meet some criteria to polygons, then use overlay to subset out those lines that pass through the desired raster cells.

require(sp)
require(raster)
require(rgeos)
require(RColorBrewer) # Just for the plotting
require(latticeExtra) # Just for the plotting

set.seed(1)

# Create some sample lines
l1 <- Lines(Line(cbind(c(0,0.5,1),c(1,0.8,0.3))), ID="a")
l2 <- Lines(Line(cbind(c(0.25,0.8,0),c(0,0.1,0.9))), ID="b")
l3 <- Lines(Line(cbind(c(0,1),c(0,1))), ID="c")
sl <- SpatialLines(list(l1,l2, l3))

# Create a sample raster of values between 0 and 10
r <- raster(extent(sl), res=0.25)
r[] <- matrix(round(runif(16, min=0, max=10)), nrow=4)

# Convert raster cells to polygons
# Only include cells that meet given criteria, e.g. cell value = 5 or 7
rpoly <- rasterToPolygons(r, fun=function(x) {x == 5 | x == 7}, na.rm=T)

# Overlay the lines on the polygons to get subset of lines that pass
# through polygons
slSubset <- sl[rpoly]

# Plot sample data
spplot(r, scales=list(draw=TRUE), xlab="x", ylab="y", 
       col.regions=colorRampPalette(brewer.pal(9, "YlOrRd")), 
       par.settings=list(fontsize=list(text=15))) +
    layer(sp.polygons(rpoly, col='white', lwd=3)) +
    layer(sp.lines(sl)) + 
    layer(sp.lines(slSubset, lwd=4))

Imgur

Heavier lines show the subset of lines chosen and cells highlighted with white borders show the subset of raster cells that meet given criteria.

| improve this answer | |
0

using arcmap 10.1

  1. Open the attribute table of reclassify raster and select the areas whose intersection to be checked with road lines, this is optional and need only when you are checking relation ship with specific area for example river area with road lines.

2.Open the arc toolbox and expand Conversion toolbox. Expand "From raster" tools and select Raster to polygon tool.By this tool your reclassify data converted into polygon areas.

3.In slectection menu choose select by location.In "select feature from" choose road lines and converted polygon in the "source layer"."Apply a search distance" according to your data and click apply.

In this way you are able to identify required intersection of lines with specific areas.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.