Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a single polyline feature that extends beyond my raster surface. I would like to shrink this line so that the end-points are within the last pixel at the edges of the raster.

I have tried converting the raster to a polygon and clipping but it sometimes puts the endpoint just outside of the raster in no data land.

Is there a simple method that I could use to intersect/shrink the line? ArcObjects is fine.

share|improve this question
    
When you coverted to vector (using I'm guessing Raster to Polygon tool) did you uncheck the Simplify polygons option? –  artwork21 Sep 8 '11 at 16:57
    
@artwork21 - See my reply below. I am worried that the values might not fall within the DEM boundary in all possible cases. Or are the end points always guaranteed to fall within my DEM? –  Nick Ochoski Sep 8 '11 at 17:00
    
I've tested this a few times now and in about 50% of cases my end points actually fall outside of the raster surface - so a simple clip is not a reliable solution. –  Nick Ochoski Sep 8 '11 at 17:41
    
See my reply for a solution to this bounding problem (re: Shrink from Spatial Analyst). –  Nick Ochoski Sep 8 '11 at 18:45

2 Answers 2

up vote 1 down vote accepted

I've just sorted out one method of accomplishing this, but it involves a lot of I/O.

1) CON the DEM at a nominal value (e.g. VALUE > -1)

2) Raster to Polygon conversion (no simplification)

3) Clip the line by the new polygon

When I get the end points of the line using Feature to Vertices (both ends), they visually appear right on the boundary of the DEM, but when I run Extract Values to Points the values represent valid numbers, not no data, so it appears that they do fall within the DEM boundary.

I would still like a method that involved less I/O if anyone can enlighten me. I am worried that the values might not fall within the DEM boundary in all possible cases.

EDIT: In order to ensure that the end points fall within the DEM boundary Shrink (Spatial Analyst) can be applied to the conditional raster to remove a single pixel width from the entire raster before converting it to polygon format.

share|improve this answer

You might try unioning together a bunch of small polygons that represent the cells of the raster, then using that union to intersect your original polyline. To loop through each cell, see code here.

polyline = someLongPolyline
unionpolygon = null
For each cell in raster
    if cell has data
        convert cell to IPolygon
        if !(IRelationalOperator)polygon.Disjoint(polyline)
           if unionPolygon = null
              unionPolygon = polygon
           else
              unionPolygon = (ITopologicalOperator)UnionPolygon).Union
           end if
         end if
    end if
next cell
trimmedPolyline = ((ITopoOp)unionPolygon).Intersect(polyline,esriResult1Dimension
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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