Get attributes of raster that intersect polyline

7661
4
11-03-2013 10:03 AM
KevinHawley
New Contributor
How can I get the attributes associated with raster cells that a polyline intersects? To provide a little background, when a user modifies the geometry of a line in a particular layer, I want to find the raster cells that the line intersects. Then I want to loop through those cells and read a particular attribute associated with the raster (the raster has attributes like state, county, source, metadata_id). The raster is an ArcGIS image service that the user has added to the ArcMap TOC.

Any help would be greatly appreciated. I'm totally stuck on this one.

Thanks,

Kevin
0 Kudos
4 Replies
KeaganAllan
New Contributor III
Hi Kevin,

I may not have the answer for you, but from you have stated I may be able to provide a starting point for you?

If I have understood correctly, you want to extract a number of attributes from a raster and place them in the attribute table of a vector line?

One way to do this would be to:

1) Densify the line, so that you have more vertices (try to the cell size?);
2) Convert the vertices to points;
3) Use the "Extract Multi-Values to points" tool in the toolbox and extract the various raster values to these points;
4) Split the line by these points
5) Spatial Join the Points to the Split Line

Now this is just off the top of my head, one needs to consider how the attributes are transferred to the line form the points. If it does not do this correctly, then perhaps changing the order of things may allow for certain OId's to be similar across the processes and thus could potentially be used as the common attribute for a table join, instead of a spatial join.

All of these tools should be accessible in VB.Net or C#, should you wish to automate this.

I hope this has helped, if not, maybe I can suggest something else.

Cheers,

K
0 Kudos
KevinHawley
New Contributor
Hi Keagan,

Thanks for the response. I'm hoping to avoid creating additional layers to do this since it will occur on demand each time the user modifies a feature. Here's what I would do if the raster layer were a vector polygon file instead: I would create a spatial filter with the polyline geometry as the geometry and intersects and the spatial relation. Then I'd load a feature cursor and then loop through each feature in the cursor and read the metadata_id attribute associated with the intersecting vector polygon feature. Can I do something similar with the raster layer?

I did go through your workflow. The Extract Multi-Values to Points tool added four fields to the point layer. Each field represented the value associated with the raster for each band (b1_current, b2_current, etc.). It did not include fields representing the attributes I'm trying to get at.

Thanks,

Kevin
0 Kudos
HailiangShen
New Contributor
Instead of using GP tool, you may refer to this link http://forums.arcgis.com/threads/95758-Getting-raster-cell-indexes-from-point-coordinates

I believe you can read a pixel value from the underlying DEM cell, but not sure whether you can retrieve your specific fields from the cell.
0 Kudos
KevinHawley
New Contributor
Thanks for your response Hailiang. Based on a suggestion from a colleague, I ended up making a request to the imagery server via the .net WebClient and JavaScriptSerializer rather than using the various raster objects available in arcobjects. The call returns a JSON string which allows me to get at the metadata_id attribute associated with the image.

Ideally, I would have like to get at the attribute table without making a request to the imagery server, but this method solves the problem for now.
0 Kudos