public static List<ProfilePoint> doProfile( GridCoverage2D coverage, Coordinate... coordinates ) throws Exception {
        GridGeometry2D gridGeometry = coverage.getGridGeometry();
        RenderedImage renderedImage = coverage.getRenderedImage();
        RandomIter iter = RandomIterFactory.create(renderedImage, null);

        List<ProfilePoint> profilePointsList = doProfile(iter, gridGeometry, coordinates);

        iter.done();
        return profilePointsList;
    }
public static List < ProfilePoint > doProfile ( GridCoverage2D coverage , Coordinate ... coordinates ) throws Exception { GridGeometry2D gridGeometry = coverage . getGridGeometry ( ) ; RenderedImage renderedImage = coverage . getRenderedImage ( ) ; RandomIter iter = RandomIterFactory . create ( renderedImage , null ) ; List < ProfilePoint > profilePointsList = doProfile ( iter , gridGeometry , coordinates ) ; iter . done ( ) ; return profilePointsList ; }
Calculates the profile of a raster map between given {@link Coordinate coordinates}.

@param coverage the coverage from which to extract the profile.
@param coordinates the coordinates to use to trace the profile.
@return the list of {@link ProfilePoint}s.
@throws Exception