Assignment 5

Develop code to compute the viewshed of a point on a grid terrain. grid. The user should specify on the command line the (name of the) elevation grid, the viewshed grid and the viewpoint coordinates, like this:
[ltoma@dover:\~] ./viewshed test2.asc test2vis.asc 5 7
This will read elevation grid test2.asc, compute the viewshed of viewpoint at row=5 and col=7 and save it as grid test2vis.asc. A point in the viewshed grid can have one or three values: NODATA (if the input point is NODATA), 0 if the point is not visible and 1 if the point is visible.

To start, implement the straightforward O(n \sqrt n) algorithm discussed in class, with linear interpolation.

Test grids are available here. The location of these files is: /mnt/research/gis/DATA/DEM/. If you are on one of the linux machines on campus, you can access these files directly at the specified path. Do NOT copy them to your directory, some are rather large ---- just work with them from the specified path.

General outline

For this assignment I am providing very little structure. Feel free to design your code as you like.

My only suggestion is that you split the viewshed function into (at least) two functions: one that computes whether a specific point (i,j) is visible from (vprow,vpcol); and one that calls this function in a loop, for every point (i,j):

void compute_viewshed (Grid* eg, Grid * vg, int vprow, int vpcol) {
     for (i=0; i< g->nrows; i++)  {
         for (j=0; j< g-> ncols; j++) {

	 set (vg, i, j) = is_visible(eg, vprow, vpcol, i, j); 
         }//for j  
     }//for i


I am including the output for set1.asc from vp=(100,100) here and from vp=(250,250) here. Feel free to render it and see how it looks like.

Submitting your Work

Place the source files in your class folder on microwave. Make a folder "assignment5" or "a5" for assignment 5. Include a Makefile.
Last modified: Mon Sep 29 14:38:48 EDT 2014