/* aread8mn.c. Program to compute area contributing to each Pixel in DEM for cell outflow based on d8 directions. David G Tarboton Utah State University SINMAP package version 0.1 9/2/97 */ #include "lsm.h" void main(int argc,char **argv) { char pfile[MAXLN],afile[MAXLN], *ext; int err,nmain; double x=0., y=0.; if(argc < 2) { printf("Usage:\n %s filename [outletx outlety]\n",argv[0]); printf("(The optional outletx and outlety are outlet coordinates\n"); printf("for the area to be computed. If they are not given, or are \n"); printf("0 0 the whole file is computed.)\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("p D8 flow directions(Input)\n"); printf("ad8 D8 area's in pixels\n"); exit(0); } ext=strrchr(argv[1],'.'); if(ext == NULL) { sprintf(pfile,"%s%s",argv[1],"p"); sprintf(afile,"%s%s",argv[1],"ad8"); } else { nmain=strlen(argv[1])-strlen(ext); strncpy(afile,argv[1],nmain); strcat(afile,"ad8"); strcat(afile,ext); strncpy(pfile,argv[1],nmain); strcat(pfile,"p"); strcat(pfile,ext); } if(argc >2) { sscanf(argv[2],"%lf",&x); sscanf(argv[3],"%lf",&y); } if(err=aread8(pfile,afile,x,y) != 0) printf("area error %d\n",err); }