int main(int argc, char **argv) { char treefile[MAXLN], coordfile[MAXLN],pfile[MAXLN],wfile[MAXLN],shpfile[MAXLN], shpfilew[MAXLN],temp[MAXLN]; int err, nmain, ordert; if(argc < 3) { printf("\nTo avoid manual file name entry this program may\n"); printf("be used with the following command\n"); printf("subbasinsetup <filename_prefix orderthresh> \n"); printf("Input existing D8 flow directions file name (ends with p suffix)\n"); scanf("%s",pfile); printf("Input existing channel network tree file (ends with tree.dat)\n"); scanf("%s",treefile); printf("Input existing channel network coordinates file (ends with coord.dat)\n"); scanf("%s",coordfile); printf("Input order threshold for subbasin delineation\n"); scanf("%d",&ordert); printf("Input file name for subbasin grid output (ends with w)\n"); scanf("%s",wfile); printf("Input file name for channel network shape output (ends with .shp)\n"); scanf("%s",shpfile); printf("Input file name for watershed shape output (ends with .shp)\n"); scanf("%s",shpfilew); // Now strip it of an extension if it is there nmain=nameadd(temp,shpfilew,""); strcpy(shpfilew,""); strncat(shpfilew,temp,nmain); } else { sscanf(argv[2],"%d",&ordert); nmain=nameadd(pfile,argv[1],"p"); nmain=nameadd(wfile,argv[1],"w"); /* Non grid files */ strcpy(treefile,""); strncat(treefile,argv[1],nmain); strcat(treefile,"tree.dat"); strcpy(coordfile,""); strncat(coordfile,argv[1],nmain); strcat(coordfile,"coord.dat"); strcpy(shpfile,""); strncat(shpfile,argv[1],nmain); strcat(shpfile,".shp"); strcpy(shpfilew,""); strncat(shpfilew,argv[1],nmain); strcat(shpfilew,"w"); } if(err=subbasinsetup(pfile,wfile,treefile,coordfile,shpfile,ordert)!= 0) { printf("Subbasinsetup error %d\n",err); return(err); } RasterToShape ras_to_shape; ras_to_shape.createShape( wfile, pfile, shpfilew); return(0); }
void main(int argc, char **argv) { char wfile[MAXLN],pfile[MAXLN],shapefile[MAXLN]; int nmain; if(argc < 2) { printf("\nTo avoid manual file name entry this program may\n"); printf("be used with the following command\n"); printf("wshedtopoly <filename_prefix> \n"); printf("Input existing watershed file\n"); scanf("%s",wfile); printf("Input existing flow direction file (ends in p)\n"); scanf("%s",pfile); printf("Input name for output shape file (without extension)\n"); scanf("%s",shapefile); } else { nmain=nameadd(wfile,argv[1],"w"); nmain=nameadd(pfile,argv[1],"p"); strcpy(shapefile,""); strncat(shapefile,argv[1],nmain); strcat(shapefile,"w"); } RasterToShape ras_to_shape; ras_to_shape.createShape( wfile, pfile, shapefile); }
void main(int argc,char **argv) { char demfile[MAXLN], pointfile[MAXLN], slopefile[MAXLN], flowfile[MAXLN]; int err,nmain; short useflowfile=0; if(argc < 2) { printf("Usage:\n %s filename [fdrfile]\n",argv[0]); printf("The following are appended BEFORE\n"); printf("the files are opened:\n"); printf("fel Flooded Elevation data\n"); printf("p D8 flow directions\n"); printf("sd8 D8 slope data\n"); printf("optional fdr file of existing stream directions\n"); exit(0); } nmain=nameadd(pointfile,argv[1],"p"); nmain=nameadd(slopefile,argv[1],"sd8"); nmain=nameadd(demfile,argv[1],"fel"); if(argc > 2) { useflowfile=1; nmain=nameadd(flowfile,argv[2],"n"); } if(err=setdird8(demfile, pointfile, slopefile,flowfile,useflowfile) != 0) printf("setdird8 error %d\n",err); }
void main(int argc,char **argv) { char demfile[MAXLN], newfile[MAXLN],flowfile[MAXLN],newflowfile[MAXLN]; int err,nmain; short useflowfile=0; if(argc < 2) { printf("Usage:\n %s filename [fdrfile]\n",argv[0]); printf("The following are appended BEFORE\n"); printf("the files are opened:\n"); printf("(no suffix) Elevation data\n"); printf("fel Flooded elevation data\n"); printf("optional fdr file of existing stream directions\n"); printf("n appended to existing stream directions during fix\n"); exit(0); } nmain=nameadd(newfile,argv[1],"fel"); if(argc > 2) { useflowfile=1; sprintf(flowfile,"%s",argv[2]); nmain=nameadd(newflowfile,argv[2],"n"); } sprintf(demfile,"%s",argv[1]); if(err=flood(demfile, newfile,flowfile,useflowfile,newflowfile) != 0) printf("Flood error %d\n",err); }
// Function to read outlets from a shapefile - overloaded to return an array of integer ID's int readoutlets(char *outletsfile, int *noutlets, double*& x, double*& y, int*& id) { SHPHandle shp = SHPOpen(outletsfile, "rb"); char dbffile[MAXLN]; nameadd(dbffile, outletsfile, ".dbf"); DBFHandle dbf = DBFOpen(dbffile, "rb"); if ((shp != NULL) && (dbf != NULL)) { int nEntities = 0; int nShapeType = 0; SHPGetInfo(shp, &nEntities, &nShapeType, NULL, NULL ); if (nShapeType != SHPT_POINT) { fprintf(stderr, "Outlets shapefile %s is not a point shapefile\n", outletsfile); fflush(stderr); return 1; } long p_size; long countPts = 0; int nfld = DBFGetFieldCount(dbf); //int idfld = DBFGetFieldIndex(dbf, "id"); int idfld = DBFGetFieldIndex(dbf, "OBJECTID"); // ZhuLJ, 2015/6/16 for( int i=0; i<nEntities; i++) { SHPObject * shape = SHPReadObject(shp, i); countPts += shape->nVertices; SHPDestroyObject(shape); } x = new double[countPts]; y = new double[countPts]; if (idfld >= 0) id = new int[countPts]; int nxy=0; for( int i=0; i<nEntities; i++) { SHPObject * shape = SHPReadObject(shp, i); p_size = shape->nVertices; for( int j=0; j<p_size; j++) { x[nxy] = shape->padfX[j]; y[nxy] = shape->padfY[j]; if (idfld >= 0) { id[nxy] = DBFReadIntegerAttribute(dbf, i, idfld); } nxy++; } SHPDestroyObject(shape); } *noutlets=nxy; SHPClose(shp); return 0; } else { fprintf(stderr, "Error opening outlets shapefile: %s\n", outletsfile); fflush(stderr); return 1; } }
static attr_t *setup_access(attrlist_t al, const char *name) { attr_t *at; int type; type=attrtype(name); if(type==-1) { /* type not found add it to the global list */ type=nameadd(name); } at=attrlookup(al, type); if(!at) { /* create a new attribute if it doesn't exist */ at=attradd(al, type); } return at; }
int main(int argc,char **argv) { char pfile[MAXLN],srcfile[MAXLN],distfile[MAXLN]; int err,nmain, thresh=1,i; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-p")==0) { i++; if(argc > i) { strcpy(pfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-src")==0) { i++; if(argc > i) { strcpy(srcfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-dist")==0) { i++; if(argc > i) { strcpy(distfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-ddm")==0) { i++; if(argc > i) { if(strcmp(argv[i],"row")==0) { tdpartition::decompType = DECOMP_ROW; } else if (strcmp(argv[i],"column")==0) { tdpartition::decompType = DECOMP_COLUMN; } else if (strcmp(argv[i],"block")==0) { tdpartition::decompType = DECOMP_BLOCK; } else { goto errexit; } i++; } else goto errexit; } else if(strcmp(argv[i],"-thresh")==0) { i++; if(argc > i) { sscanf(argv[i],"%d",&thresh); i++; } else goto errexit; } else { goto errexit; } } if(argc == 2) { nameadd(pfile,argv[1],"p"); nameadd(srcfile,argv[1],"src"); nameadd(distfile,argv[1],"dist"); } if(err=distgrid(pfile,srcfile,distfile,thresh) != 0) printf("D8 distance error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -p <pfile>\n",argv[0]); printf("-src <srcfile> -dist <distfile> [-thresh <thresh>] [-ddm <ddm>]\n"); printf("<basefilename> is the name of the base digital elevation model\n"); printf("<pfile> is the d8 flow direction input file.\n"); printf("<srcfile> is the stream raster input file.\n"); printf("<distfile> is the distance to stream output file.\n"); printf("<ddm> is the data decomposition method. Either \"row\", \"column\" or \"block\".\n"); printf("The optional <thresh> is the user input threshold number.\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("src stream raster file (Input)\n"); printf("dist distance to stream file(output)\n"); exit(0); }
int main(int argc,char **argv) { char felfile[MAXLN],ssfile[MAXLN]; int err; float p[3]; if(argc < 2) goto errexit; // Specify default weights p[0]=0.4; p[1]=0.1; p[2]=0.05; if(argc == 2) { // printf("You are running %s with the simple use option.\n", argv[0]); nameadd(felfile,argv[1],"fel"); nameadd(ssfile,argv[1],"ss"); } if(argc > 2) { // printf("You are running %s with the specific file names option.\n", argv[0]); int i=1; while(argc > i) { if(strcmp(argv[i],"-fel")==0) { i++; if(argc > i) { strcpy(felfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-ss")==0) { i++; if(argc > i) { strcpy(ssfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-par")==0) { i++; if(argc > i+2) { sscanf(argv[i],"%f",&p[0]); i++; sscanf(argv[i],"%f",&p[1]); i++; sscanf(argv[i],"%f",&p[2]); i++; } else goto errexit; } else goto errexit; } } if( (err=peukerdouglas(felfile,ssfile,p)) != 0) printf("Peuker Douglas Error %d\n",err); return 0; errexit: printf("Simple Use:\n %s <basefilename>\n",argv[0]); printf("Use with specific file names:\n %s -fel <elevationfile>\n",argv[0]); printf("-ss <streamsource> [-par <weightMiddle> <weightSide> <weightDiagonal>]\n"); printf("<basefilename> is the name of the base digital elevation model without suffixes for simple input. 'fel' will be appended. \n"); printf("<elevationfile> is the name of the elevation input file.\n"); printf("<streamsource> is the name of the stream source file output.\n"); printf("The elevation input is smoothed by averaging using the center and eight surrounding grid cells.\n"); printf("<weightMiddle> is the weight given to the center cell in the smoothing of the input elevations.\n"); printf("<weightSide> is the weight given to the 4 side cells in the smoothing of the input elevations.\n"); printf("<weightDiagonal> is the weight given to the 4 diagonal cells in the smoothing of the input elevations.\n"); printf("Default weights are 0.4 0.1 0.05 if -par is not specified.\n"); return 0; }
int main(int argc,char **argv) { char slopefile[MAXLN],areafile[MAXLN],twifile[MAXLN]; int err,i,prow=0, pcol=0; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-sca")==0) { i++; if(argc > i) { strcpy(areafile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-mf")==0) { i++; if(argc > i) { prow = atoi(argv[i]); i++; if(argc > i) { pcol = atoi(argv[i]); i++; } else goto errexit; } else goto errexit; if(prow <=0 || pcol <=0) goto errexit; } else if(strcmp(argv[i],"-slp")==0) { i++; if(argc > i) { strcpy(slopefile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-twi")==0) { i++; if(argc > i) { strcpy(twifile,argv[i]); i++; } else goto errexit; } else { goto errexit; } } if( argc == 2) { nameadd(areafile,argv[1],"sca"); nameadd(slopefile,argv[1],"slp"); nameadd(twifile,argv[1],"twi"); } if((err=twigrid(slopefile,areafile,twifile,prow,pcol)) != 0) printf("TWI error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -sca <areafile>\n",argv[0]); printf("-slp <slopefile> -twi <twifile>\n"); printf("<basefilename> is the name of the raw digital elevation model\n"); printf("<areafile> is the D-infinity specific catchment area input file.\n"); printf("<slopefile> is the D-infinity slope input file.\n"); printf("<twifile> is the topographic wetness index (ln(a/S) output file.\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("sca D-infinity specific catchment area grid (input)\n"); printf("slp D-infinity slope grid (input)\n"); printf("twi output topographic wetness index grid grid\n"); exit(0); }
int main(int argc,char **argv) { char pfile[MAXLN],srcfile[MAXLN],ordfile[MAXLN],ad8file[MAXLN],elevfile[MAXLN],wfile[MAXLN],streamnetshp[MAXLN]; char treefile[MAXLN],coordfile[MAXLN],outletshapefile[MAXLN]; long ordert=1, useoutlets=0; int err,i; bool verbose=false; // Initialize verbose flag if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } // Some debug testing of arguments //int j; //for(j=0; j<argc; j++) // printf("%d %d Arg: %s:end\n",j,strlen(argv[j]),argv[j]); while(argc > i) { if(strcmp(argv[i],"-fel")==0) { i++; if(argc > i) { strcpy(elevfile,argv[i]); // sscanf(argv[i],"%s",elevfile); // DGT 5/14/10 Discovered that this did not copy file names with spaces - so switched to strcpy //printf("filename: %s:end\n",elevfile); i++; } else goto errexit; } else if(strcmp(argv[i],"-p")==0) { i++; if(argc > i) { strcpy(pfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-ad8")==0) { i++; if(argc > i) { strcpy(ad8file,argv[i]); i++; } } else if(strcmp(argv[i],"-src")==0) { i++; if(argc > i) { strcpy(srcfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-ord")==0) { i++; if(argc > i) { strcpy(ordfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-tree")==0) { i++; if(argc > i) { strcpy(treefile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-coord")==0) { i++; if(argc > i) { strcpy(coordfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-o")==0) { i++; if(argc > i) { strcpy(outletshapefile,argv[i]); i++; useoutlets = 1; } else goto errexit; } else if(strcmp(argv[i],"-w")==0) { i++; if(argc > i) { strcpy(wfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-net")==0) { i++; if(argc > i) { strcpy(streamnetshp,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-sw")==0) { i++; ordert=0; } else if(strcmp(argv[i],"-v")==0) { i++; verbose=true; } else { goto errexit; } } if( argc == 2) { nameadd(elevfile,argv[1],"fel"); nameadd(pfile,argv[1],"p"); nameadd(ad8file,argv[1],"ad8"); nameadd(srcfile,argv[1],"src"); nameadd(ordfile,argv[1],"ord"); nameadd(treefile,argv[1],"tree.txt"); nameadd(coordfile,argv[1],"coord.txt"); nameadd(wfile,argv[1],"w"); nameadd(streamnetshp,argv[1],"net.shp"); } if(err=netsetup(pfile,srcfile,ordfile,ad8file,elevfile,treefile,coordfile,outletshapefile,wfile,streamnetshp, useoutlets, ordert,verbose) != 0) printf("StreamNet error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -p <pfile>\n",argv[0]); printf("-fel <elevfile> -ad8 <ad8file> -src <srcfile>\n"); printf("-ord <ordfile> -tree <treefile> -coord <coordfile>\n"); printf("-fel <elevfile> -ad8 <ad8file> -dn <dn>\n"); printf("<basefilename> is the name of the base digital elevation model\n"); printf("<pfile> is the D8 flow direction input file.\n"); printf("<felfile> is the pit filled or carved elevation input file.\n"); printf("<slpdfile> is the output D8 slope distance averaged grid file.\n"); printf("<dn is the optional user selected downslope distance.\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("fel pit filled or carved elevation grid (input)\n"); printf("p D-infinity flow direction grid (Input)\n"); printf("slpd avalanche source site grod (input)\n"); exit(0); }
int main(int argc,char **argv) { char angfile[MAXLN],dgfile[MAXLN],depfile[MAXLN]; int err,useOutlets=0,usew=0,contcheck=1,i; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-ang")==0) { i++; if(argc > i) { strcpy(angfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-dg")==0) { i++; if(argc > i) { strcpy(dgfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-dep")==0) { i++; if(argc > i) { strcpy(depfile,argv[i]); i++; } else goto errexit; } else { goto errexit; } } if( argc == 2) { nameadd(angfile,argv[1],"ang"); nameadd(dgfile,argv[1],"dg"); nameadd(depfile,argv[1],"dep"); } if((err=depgrd(angfile,dgfile,depfile)) != 0) printf("depgrd error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -ang <angfile>\n",argv[0]); printf("-dg <dgfile> -dp <depfile>\n"); printf("<basefilename> is the name of the raw digital elevation model\n"); printf("<angfile> is the D-infinity flow direction input file.\n"); printf("<dgfile> is the disturbance input grid file.\n"); printf("<depfile> is the flow dependence grid file.\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("ang D-infinity flow direction input file\n"); printf("dg disturbance grid (input)\n"); printf("dep dependence grid (input)\n"); exit(0); }
int main(int argc,char **argv) { char slopefile[MAXLN],areafile[MAXLN],atanbfile[MAXLN]; int err,i; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-sca")==0) { i++; if(argc > i) { strcpy(areafile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-slp")==0) { i++; if(argc > i) { strcpy(slopefile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-sar")==0) { i++; if(argc > i) { strcpy(atanbfile,argv[i]); i++; } else goto errexit; } else { goto errexit; } } if( argc == 2) { nameadd(areafile,argv[1],"sca"); nameadd(slopefile,argv[1],"slp"); nameadd(atanbfile,argv[1],"sar"); } if((err=atanbgrid(slopefile,areafile,atanbfile)) != 0) printf("Slope area ratio error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -sca <areafile>\n",argv[0]); printf("-slp <slopefile> -sar <atanbfile>\n"); printf("<basefilename> is the name of the raw digital elevation model\n"); printf("<areafile> is the D-infinity specific catchment area input file.\n"); printf("<slopefile> is the D-infinity slope input file.\n"); printf("<atanbfile> is the slope area ratio output file.\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("sca D-infinity specific catchment area grid (input)\n"); printf("slp D-infinity slope grid (input)\n"); printf("sar output slope area ratio grid\n"); exit(0); }
int main(int argc,char **argv) { char demfile[MAXLN],newfile[MAXLN],flowfile[MAXLN]; int err,order,subbno,i; short useflowfile=0; bool verbose=false; // Initialize verbose flag if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-z")==0) { i++; if(argc > i) { strcpy(demfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-fel")==0) { i++; if(argc > i) { strcpy(newfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-sfdr")==0) { i++; if(argc > i) { strcpy(flowfile,argv[i]); useflowfile=1; i++; } else goto errexit; } else if(strcmp(argv[i],"-v")==0) { i++; verbose=true; } else { goto errexit; } } if( argc == 2) { strcpy(demfile,argv[1]); //printf("File %s\n",demfile); nameadd(newfile,argv[1],"fel"); } // Debugging prints if(verbose) { printf("On input demfile: %s\n",demfile); printf("On input newfile: %s\n",newfile); fflush(stdout); } useflowfile=0; // useflowfile not implemented if((err=flood(demfile,newfile,flowfile,useflowfile,verbose)) != 0) printf("PitRemove error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -z <demfile>\n",argv[0]); printf("-fel <newfile> [-sfdr <flowfile>]\n"); printf("<basefilename> is the name of the raw digital elevation model.\n"); printf("<demfile> is the name of the input elevation grid file.\n"); printf("<newfile> is the output elevation grid with pits filled.\n"); printf("<flowfile> is the input grid of flow directions to be imposed.\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("fel output elevation grid with pits filled.\n\n"); // printf("argc: %d\n",argc); // for(int i=0; i<argc; i++)printf("%s\n",argv[i]); exit(0); }
int main(int argc,char **argv) { char pfile[MAXLN],felfile[MAXLN],slpdfile[MAXLN]; int err,i; double dn=50.0; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-fel")==0) { i++; if(argc > i) { strcpy(felfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-p")==0) { i++; if(argc > i) { strcpy(pfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-slpd")==0) { i++; if(argc > i) { strcpy(slpdfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-ddm")==0) { i++; if(argc > i) { if(strcmp(argv[i],"row")==0) { tdpartition::decompType = DECOMP_ROW; } else if (strcmp(argv[i],"column")==0) { tdpartition::decompType = DECOMP_COLUMN; } else if (strcmp(argv[i],"block")==0) { tdpartition::decompType = DECOMP_BLOCK; } else { goto errexit; } i++; } else goto errexit; } else if(strcmp(argv[i],"-dn")==0) { i++; if(argc > i) { sscanf(argv[i],"%lf",&dn); i++; } else goto errexit; } else { goto errexit; } } if( argc == 2) { nameadd(felfile,argv[1],"fel"); nameadd(pfile,argv[1],"p"); nameadd(slpdfile,argv[1],"slpd"); } if((err=sloped(pfile,felfile,slpdfile,dn)) != 0) printf("sloped error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -p <pfile>\n",argv[0]); printf("-fel <felfile> -slpd <slpdfile> -dn <dn> [-ddm <ddm>]\n"); printf("<basefilename> is the name of the base digital elevation model\n"); printf("<pfile> is the D8 flow direction input file.\n"); printf("<felfile> is the pit filled or carved elevation input file.\n"); printf("<slpdfile> is the output D8 slope distance averaged grid file.\n"); printf("<dn is the optional user selected downslope distance.\n"); printf("<ddm> is the data decomposition method. Either \"row\", \"column\" or \"block\".\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("fel pit filled or carved elevation grid (input)\n"); printf("p D-infinity flow direction grid (Input)\n"); printf("slpd avalanche source site grod (input)\n"); exit(0); }
int main(int argc,char **argv) { char pfile[MAXLN],safile[MAXLN], ssafile[MAXLN], outletfile[MAXLN]; int err, useoutlets,contcheck,usemax; if(argc < 2) goto errexit; usemax=1; // Set defaults useoutlets=0; contcheck=1; if(argc == 2) { // printf("You are running %s with the simple use option.\n", argv[0]); nameadd(pfile,argv[1],"p"); nameadd(safile,argv[1],"sa"); nameadd(ssafile,argv[1],"ssa"); } if(argc > 2) { // printf("You are running %s with the specific file names option.\n", argv[0]); int i=1; while(argc > i) { if(strcmp(argv[i],"-p")==0) { i++; if(argc > i) { strcpy(pfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-sa")==0) { i++; if(argc > i) { strcpy(safile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-ssa")==0) { i++; if(argc > i) { strcpy(ssafile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-o")==0) { i++; if(argc > i) { strcpy(outletfile,argv[i]); i++; useoutlets=1; } else goto errexit; } else if(strcmp(argv[i],"-min")==0) { i++; usemax=0; } else if(strcmp(argv[i],"-nc")==0) { i++; contcheck=0; } else goto errexit; } } if((err=d8flowpathextremeup(pfile, safile, ssafile, usemax, outletfile, useoutlets, contcheck)) != 0) printf("Flow Path Extreme Up Error %d\n",err); return 0; errexit: printf("Simple Use:\n %s <basefilename>\n",argv[0]); printf("Use with specific file names:\n %s -p <pfile>\n",argv[0]); printf("-sa <safile> -ssa <ssafile> [-min] [-nc] [-o <outletsfile>]\n"); printf("<basefilename> is the name of the base digital elevation model without suffixes for simple input. Suffixes 'p', 'sa' and 'ssa' will be appended. \n"); printf("<pfile> is the name of D8 flow directions file.\n"); printf("<safile> is the name of input file with values from which extreme upslope is to be found.\n"); printf("<ssa> is the name of the output file with extreme upslope values.\n"); printf("-min indicates to search for a minimum (default is max)\n"); printf("-nc indicates to override edge contamination checking (checking is on by default)\n"); return 0; }
void main(int argc,char **argv) { char pfile[MAXLN],afile[MAXLN],wfile[MAXLN]; int err,nmain, doall=1,usew=0,contcheck=1,i; long x=0, y=0; if(argc < 2) { printf("Usage:\n %s <filename_prefix> [-xy outlet_x outlet_y] [-wg <weightfile>] [-nc]\n",argv[0]); printf("(The optional outlet_x and outlet_y are outlet coordinates\n"); printf("for the area to be computed. If they are not given \n"); printf("the whole file is computed.\n"); printf("The optional <weightfile> is the file name for a grid of weights for\n"); printf("weighted contributing area evaluation\n"); printf("The flag -nc overrides edge contamination checking\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"); printf("wad8 Weighted D8 areas\n"); exit(0); } i=2; while(argc > i) { if(strcmp(argv[i],"-wg")==0) { i++; if(argc > i) { sscanf(argv[i],"%s",wfile); usew=1; i=i+1; } } else if(strcmp(argv[i],"-xy")==0) { i++; if(argc > i+1) { sscanf(argv[i],"%ld",&x); sscanf(argv[i+1],"%ld",&y); doall = 0; i=i+2; } } else if(strcmp(argv[i],"-nc")==0) { i++; contcheck=0; } else i++; } nmain=nameadd(pfile,argv[1],"p"); if(usew == 1) { nmain=nameadd(afile,argv[1],"wad8"); } else { nmain=nameadd(afile,argv[1],"ad8"); } if(err=aread8(pfile,afile,x,y,doall,wfile,usew,contcheck) != 0) printf("area error %d\n",err); }
int main(int argc,char **argv) { char pfile[MAXLN],safile[MAXLN], ssafile[MAXLN],datasrc[MAXLN],lyrname[MAXLN]; int err, useoutlets,contcheck,usemax,lyrno=0,uselyrname=0; if(argc < 2) goto errexit; usemax=1; // Set defaults useoutlets=0; contcheck=1; if(argc == 2) { // printf("You are running %s with the simple use option.\n", argv[0]); nameadd(pfile,argv[1],"p"); nameadd(safile,argv[1],"sa"); nameadd(ssafile,argv[1],"ssa"); } if(argc > 2) { // printf("You are running %s with the specific file names option.\n", argv[0]); int i=1; while(argc > i) { if(strcmp(argv[i],"-p")==0) { i++; if(argc > i) { strcpy(pfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-sa")==0) { i++; if(argc > i) { strcpy(safile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-ssa")==0) { i++; if(argc > i) { strcpy(ssafile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-o")==0) { i++; if(argc > i) { strcpy(datasrc,argv[i]); i++; useoutlets=1; } else goto errexit; } else if(strcmp(argv[i],"-ddm")==0) { i++; if(argc > i) { if(strcmp(argv[i],"row")==0) { tdpartition::decompType = DECOMP_ROW; } else if (strcmp(argv[i],"column")==0) { tdpartition::decompType = DECOMP_COLUMN; } else if (strcmp(argv[i],"block")==0) { tdpartition::decompType = DECOMP_BLOCK; } else { goto errexit; } i++; } else goto errexit; } else if(strcmp(argv[i],"-lyrno")==0) { i++; if(argc > i) { sscanf(argv[i],"%d",&lyrno); i++; } else goto errexit; } else if(strcmp(argv[i],"-lyrname")==0) { i++; if(argc > i) { strcpy(lyrname,argv[i]); uselyrname = 1; i++; } else goto errexit; } else if(strcmp(argv[i],"-min")==0) { i++; usemax=0; } else if(strcmp(argv[i],"-nc")==0) { i++; contcheck=0; } else goto errexit; } } if((err=d8flowpathextremeup(pfile, safile, ssafile, usemax, datasrc,lyrname,uselyrname,lyrno, useoutlets, contcheck)) != 0) printf("Flow Path Extreme Up Error %d\n",err); return 0; errexit: printf("Simple Use:\n %s <basefilename>\n",argv[0]); printf("Use with specific file names:\n %s -p <pfile>\n",argv[0]); printf("-sa <safile> -ssa <ssafile> [-min] [-nc] [-o <outletsfile>] [-ddm <ddm>]\n"); printf("<basefilename> is the name of the base digital elevation model without suffixes for simple input. Suffixes 'p', 'sa' and 'ssa' will be appended. \n"); printf("<pfile> is the name of D8 flow directions file.\n"); printf("<safile> is the name of input file with values from which extreme upslope is to be found.\n"); printf("<ssa> is the name of the output file with extreme upslope values.\n"); printf("<ddm> is the data decomposition method. Either \"row\", \"column\" or \"block\".\n"); printf("-min indicates to search for a minimum (default is max)\n"); printf("-nc indicates to override edge contamination checking (checking is on by default)\n"); return 0; }
int main(int argc,char **argv) { char angfile[MAXLN],ctptfile[MAXLN],dmfile[MAXLN],qfile[MAXLN],shfile[MAXLN],dgfile[MAXLN]; int err,useOutlets=0,contcheck=1,i; float cSol=1.; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-ang")==0) { i++; if(argc > i) { strcpy(angfile,argv[i]);//input Dinf flow direction grid i++; } else goto errexit; } else if(strcmp(argv[i],"-dg")==0) { i++; if(argc > i) { strcpy(dgfile,argv[i]);//input indicator grid i++; } else goto errexit; } else if(strcmp(argv[i],"-dm")==0) { i++; if(argc > i) { strcpy(dmfile,argv[i]);//Input decay multiplier grid i++; } else goto errexit; } else if(strcmp(argv[i],"-ctpt")==0) { i++; if(argc > i) { strcpy(ctptfile,argv[i]);//Output concentration grid i++; } else goto errexit; } else if(strcmp(argv[i],"-q")==0) { i++; if(argc > i) { strcpy(qfile,argv[i]); //input specific discharge grid i++; } else goto errexit; } else if(strcmp(argv[i],"-csol")==0) { i++; if(argc > i) { sscanf(argv[i],"%f",&cSol);//concentration threshold grid i++; } else goto errexit; } else if(strcmp(argv[i],"-o")==0) { i++; if(argc > i) { strcpy(shfile,argv[i]); i++; useOutlets = 1; } else goto errexit; } else if(strcmp(argv[i],"-nc")==0) { i++; contcheck=0; } else { goto errexit; } } if( argc == 2) { nameadd(angfile,argv[1],"ang"); nameadd(dgfile,argv[1],"dg"); nameadd(dmfile,argv[1],"dm"); nameadd(qfile,argv[1],"q"); nameadd(ctptfile,argv[1],"ctpt"); } if((err=dsllArea(angfile,ctptfile,dmfile,shfile,qfile,dgfile,useOutlets,contcheck,cSol)) != 0) printf("area error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -ang <angfile>\n",argv[0]); printf("-dg <indicatorFile> -dm <dmfile> -ctpt <afile>\n"); printf("-q <qfile> [-o <outletshapefile>] [-csol <cSol>] [<-nc>]\n"); printf("<basefilename> is the name of the raw digital elevation model\n"); printf("<angfile> is the D-infinity flow direction input file.\n"); printf("<indicatorFile> is the disturbance indicator input grid file.\n"); printf("<dmfile> is the decay multiplier input grid file.\n"); printf("<ctptfile> is the concentration output grid file.\n"); printf("<qfile> is the specific discharge input grid file.\n"); printf("<outletshapefile> is the optional outlet shape input file.\n"); printf("<cSol> is the optional concentration threshold.\n"); printf("The flag -nc overrides edge contamination checking\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("ang D-infinity flow direction input file\n"); printf("dg Disturbance indicator input file\n"); printf("dm Decay multiplier grid (input)\n"); printf("q Specific discharge grid (input)\n"); printf("ctpt Concentration grid (output)\n"); exit(0); }
int main(int argc,char **argv) { char demfile[MAXLN], pointfile[MAXLN], slopefile[MAXLN], flowfile[MAXLN]; int err, i, prow = 0, pcol = 0; short useflowfile=0; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-fel")==0) { i++; if(argc > i) { strcpy(demfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-mf")==0) { i++; if(argc > i) { prow = atoi(argv[i]); i++; if(argc > i) { pcol = atoi(argv[i]); i++; } else goto errexit; } else goto errexit; if(prow <=0 || pcol <=0) goto errexit; } else if(strcmp(argv[i],"-sd8")==0) { i++; if(argc > i) { strcpy(slopefile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-p")==0) { i++; if(argc > i) { strcpy(pointfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-sfdr")==0) { i++; if(argc > i) { strcpy(flowfile,argv[i]); i++; useflowfile=1; } else goto errexit; } else { goto errexit; } } if( argc == 2) { nameadd(demfile,argv[1],"fel"); nameadd(pointfile,argv[1],"p"); nameadd(slopefile,argv[1],"sd8"); } if((err=setdird8(demfile, pointfile, slopefile,flowfile,useflowfile, prow, pcol)) != 0) printf("setdird8 error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -fel <demfile>\n",argv[0]); printf("-sd8 <slopefile> -p <angfile> [-sfdr <flowfile>]\n"); printf("<basefilename> is the name of the raw digital elevation model\n"); printf("<demfile> is the pit filled or carved DEM input file.\n"); printf("<slopefile> is the slope output file.\n"); printf("<pointfile> is the output d8 flow direction file.\n"); printf("[-sfdr <flowfile>] is the optional user imposed stream flow direction file.\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("fel carved or pit filled input elevation file\n"); printf("sd8 D8 slope file (output)\n"); printf("p D8 flow direction output file\n"); exit(0); }
int main(int argc, char **argv) { //printf("%d",argc); char demfile[MAXLN],profcfile[MAXLN],plancfile[MAXLN],horizcfile[MAXLN]; char unspherfile[MAXLN],meancfile[MAXLN],maxcfile[MAXLN],mincfile[MAXLN]; int err,i; bool calprof = false,calplan = false, calhoriz = false, calunspher = false; bool calmeanc = false, calmaxc = false, calminc = false; if (argc < 2) { printf("Error: To run the program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if (argc > 2) i = 1; else i = 2; while(argc > i) { if (strcmp(argv[i],"-fel") == 0) { i++; if (argc > i) { strcpy(demfile,argv[i]); //printf("dem:%s\n",demfile); i++; } else goto errexit; } if (strcmp(argv[i],"-out")==0) { i++; while (argc > i) { if (strcmp(argv[i],"-prof")==0) { i++; if (argc > i) { //printf("%s\n",argv[i]); strcpy(profcfile,argv[i]); calprof = true; //printf("prof:%s\n",profcfile); i++; } } else if (strcmp(argv[i],"-plan")==0) { i++; if (argc > i) { strcpy(plancfile,argv[i]); calplan = true; //printf("plan:%s\n",plancfile); i++; } } else if (strcmp(argv[i],"-horiz")==0) { i++; if (argc > i) { strcpy(horizcfile,argv[i]); calhoriz = true; //printf("horiz:%s\n",horizcfile); i++; } } else if (strcmp(argv[i],"-unspher")==0) { i++; if (argc > i) { strcpy(unspherfile,argv[i]); calunspher = true; //printf("unspher:%s\n",unspherfile); i++; } } else if (strcmp(argv[i],"-ave")==0) { i++; if (argc > i) { strcpy(meancfile,argv[i]); calmeanc = true; //printf("ave:%s\n",meancfile); i++; } } else if (strcmp(argv[i],"-max")==0) { i++; if (argc > i) { strcpy(maxcfile,argv[i]); calmaxc = true; //printf("max:%s\n",maxcfile); i++; } } else if (strcmp(argv[i],"-min")==0) { i++; if (argc > i) { strcpy(mincfile,argv[i]); calminc = true; //printf("min:%s\n",mincfile); i++; } } } }else goto errexit; } if( argc == 2) { strcpy(demfile,argv[1]); nameadd(profcfile,argv[1],"profc"); nameadd(plancfile,argv[1],"planc"); nameadd(horizcfile,argv[1],"horizc"); nameadd(unspherfile,argv[1],"unspher"); nameadd(meancfile,argv[1],"avec"); nameadd(maxcfile,argv[1],"maxc"); nameadd(mincfile,argv[1],"minc"); calprof = true; calplan = true; calhoriz = true; calunspher = true; calmeanc = true; calmaxc = true; calminc = true; } if((err=Curvature(demfile,profcfile,plancfile,horizcfile,unspherfile,meancfile,maxcfile,mincfile,calprof ,calplan,calhoriz,calunspher,calmeanc,calmaxc, calminc)) != 0) printf("area error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -fel <felfile>\n",argv[0]); printf("[-out -prof <profcfile> -plan <plancfile> -horiz <horizcfile> -unspher <unspherfile> -ave <meancfile> -max <maxcfile> -min <mincfile>]\n"); printf("<felfile> is the name of the filled digital elevation model\n"); printf("<profcfile> is the profile curvature output file.\n"); printf("<plancfile> is the plan curvature output file.\n"); printf("<horizcfile> is the horizontal curvature output file.\n"); printf("<unspherfile> is the unsphericity output file.\n"); printf("<meancfile> is the mean curvature output file.\n"); printf("<maxcfile> is the maximum curvature output file.\n"); printf("<mincfile> is the minimum curvature output file.\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf(" profc profile curvature output file\n"); printf(" planc plan curvature output file\n"); printf(" horizc horizontal curvature output file\n"); printf(" unspher unsphericity output file\n"); printf(" avec mean curvature output file\n"); printf(" maxc maximum curvature output file\n"); printf(" minc minimum curvature output file\n"); exit(0); }
int main(int argc,char **argv) { char angfile[MAXLN],felfile[MAXLN],slpfile[MAXLN],wfile[MAXLN],rtrfile[MAXLN]; int err,i,statmethod=0,typemethod=0,usew=0, concheck=1; float thresh=0.0; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-ang")==0) { i++; if(argc > i) { strcpy(angfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-fel")==0) { i++; if(argc > i) { strcpy(felfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-slp")==0) { i++; if(argc > i) { strcpy( slpfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-wg")==0) { i++; if(argc > i) { strcpy(wfile,argv[i]); usew=1; i++; } else goto errexit; } else if(strcmp(argv[i],"-du")==0) { i++; if(argc > i) { strcpy(rtrfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-m")==0) { i++; if(argc > i) { if(strcmp(argv[i],"h")==0) { typemethod=0; } else if(strcmp(argv[i],"v")==0) { typemethod=1; } else if(strcmp(argv[i],"p")==0) { typemethod=2; } else if(strcmp(argv[i],"s")==0) { typemethod=3; } else if(strcmp(argv[i],"ave")==0) { statmethod=0; } else if(strcmp(argv[i],"max")==0) { statmethod=1; } else if(strcmp(argv[i],"min")==0) { statmethod=2; } i++; if(strcmp(argv[i],"h")==0) { typemethod=0; } else if(strcmp(argv[i],"v")==0) { typemethod=1; } else if(strcmp(argv[i],"p")==0) { typemethod=2; } else if(strcmp(argv[i],"s")==0) { typemethod=3; } else if(strcmp(argv[i],"ave")==0) { statmethod=0; } else if(strcmp(argv[i],"max")==0) { statmethod=1; } else if(strcmp(argv[i],"min")==0) { statmethod=2; } i++; } else goto errexit; } else if(strcmp(argv[i],"-nc")==0) { i++; concheck=0; } else if(strcmp(argv[i],"-thresh")==0) { i++; if(argc > i) { sscanf(argv[i],"%f",&thresh); i++; } else goto errexit; } else { goto errexit; } } if( argc == 2) { nameadd(angfile,argv[1],"ang"); nameadd(felfile,argv[1],"fel"); nameadd(slpfile,argv[1],"slp"); nameadd(wfile,argv[1],"wg"); nameadd(rtrfile,argv[1],"du"); } if((err=dinfdistup(angfile,felfile,slpfile,wfile,rtrfile,statmethod, typemethod,usew, concheck,thresh)) != 0) printf("area error %d\n",err); //////Calling function ////int dinfdistup(char *angfile,char *felfile,char *slpfile,char *wfile, char *rtrfile, //// int statmethod,int typemethod,int useweight, int concheck, float thresh) // int er; //switch (typemethod) //{ //case 0://horizontal distance to ridge // er=hdisttoridgegrd(angfile,wfile,rtrfile,statmethod, // concheck,thresh,usew); //break; //case 1://vertical rize to ridge // er=vrisetoridgegrd(angfile,felfile,rtrfile, // statmethod,concheck,thresh); //break; //case 2:// Pythagoras distance to ridge // er=pdisttoridgegrd(angfile,felfile,wfile,rtrfile, // statmethod,usew,concheck,thresh); //break; //case 3://surface distance to ridge // er=sdisttoridgegrd(angfile,slpfile,wfile,rtrfile, // statmethod,usew,concheck,thresh); //break; //} ////return (er); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -ang <angfile>\n",argv[0]); printf("-fel <felfile> -slp <slpfile> [-wg <wfile>] -du <rtrfile>\n"); printf("[-m ave h] [-nc]\n"); printf("<basefilename> is the name of the raw digital elevation model\n"); printf("<angfile> is the D-infinity flow direction input file.\n"); printf("<felfile> is the pit filled or carved elevation input file.\n"); printf("<slpfile> is the D-infinity slope input file.\n"); printf("<wgfile> is the D-infinity flow direction input file.\n"); printf("<rtrfile> is the D-infinity distance output file.\n"); printf("[-m ave h] is the optional method flag.\n"); printf("The flag -nc overrides edge contamination checking\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("ang D-infinity contributing area file (output)\n"); printf("fel pit filled or carved elevation file\n"); printf("slp D-infinity slope input file file\n"); printf("wg weight input file\n"); printf("du distance to stream output file\n"); exit(0); }
int main(int argc,char **argv) { char angfile[MAXLN],adecfile[MAXLN],dmfile[MAXLN],wfile[MAXLN],datasrc[MAXLN],lyrname[MAXLN]; int err,useOutlets=0,usew=0,uselyrname=0,lyrno=0,contcheck=1,i; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-ang")==0) { i++; if(argc > i) { strcpy(angfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-dm")==0) { i++; if(argc > i) { strcpy(dmfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-dsca")==0) { i++; if(argc > i) { strcpy(adecfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-wg")==0) { i++; if(argc > i) { strcpy(wfile,argv[i]); i++; usew=1; } else goto errexit; } else if(strcmp(argv[i],"-o")==0) { i++; if(argc > i) { strcpy(datasrc,argv[i]); useOutlets = 1; i++; } else goto errexit; } else if(strcmp(argv[i],"-lyrno")==0) { i++; if(argc > i) { sscanf(argv[i],"%d",&lyrno); i++; } else goto errexit; } else if(strcmp(argv[i],"-lyrname")==0) { i++; if(argc > i) { strcpy(lyrname,argv[i]); uselyrname = 1; i++; } else goto errexit; } else if(strcmp(argv[i],"-nc")==0) { i++; contcheck=0; } else { goto errexit; } } if( argc == 2) { nameadd(angfile,argv[1],"ang"); nameadd(dmfile,argv[1],"dm"); nameadd(adecfile,argv[1],"dsca"); } if(err=dmarea(angfile,adecfile,dmfile,datasrc,lyrname,uselyrname,lyrno,wfile,useOutlets,usew, contcheck) != 0) printf("area error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -ang <angfile>\n",argv[0]); printf("-dm <dmfile> -dsca <adecfile> [-o <outletshapefile>] [-wg <wfile>] [-nc]\n"); printf("<basefilename> is the name of the raw digital elevation model\n"); printf("<angfile> is the D-infinity flow direction input file.\n"); printf("<dmfile> is the decay multiplier input grid file.\n"); printf("<adecfile> is the decayed specific catchment area output grid file.\n"); printf("<wfile> is the weight input grid file.\n"); printf("<outletshapefile> is the optional outlet shape input file.\n"); printf("The flag -nc overrides edge contamination checking\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("ang D-infinity flow direction input file\n"); printf("dm Decay multiplier grid (input)\n"); printf("wg weight grid (input)\n"); printf("dsca decayed specific catchment area grid (output)\n"); exit(0); }
int main(int argc,char **argv) { char pfile[MAXLN],afile[MAXLN],wfile[MAXLN],shfile[MAXLN]; int err,useOutlets=0,usew=0,contcheck=1,i; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-ang")==0) { i++; if(argc > i) { strcpy(pfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-sca")==0) { i++; if(argc > i) { strcpy(afile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-o")==0) { i++; if(argc > i) { strcpy(shfile, argv[i]); useOutlets=1; i++; } else goto errexit; } else if(strcmp(argv[i],"-wg")==0) { i++; if(argc > i) { strcpy(wfile,argv[i]); usew=1; i++; } else goto errexit; } else if(strcmp(argv[i],"-nc")==0) { i++; contcheck=0; } else { goto errexit; } } if( argc == 2) { nameadd(afile,argv[1],"sca"); nameadd(pfile,argv[1],"ang"); } if((err=area(pfile,afile,shfile,wfile,useOutlets,usew,contcheck)) != 0) printf("area error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -ang <angfile>\n",argv[0]); printf("-sca <afile> [-o <shfile>] [-wg <wfile>]\n"); printf("<basefilename> is the name of the raw digital elevation model\n"); printf("<angfile> is the D-infinity flow direction input file.\n"); printf("<afile> is the D-infinity area output file.\n"); printf("[-o <shfile>] is the optional outlet shape input file.\n"); printf("[-wg <wfile>] is the optional weight grid input file.\n"); printf("The flag -nc overrides edge contamination checking\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("sca D-infinity contributing area file (output)\n"); printf("ang D-infinity flow direction output file\n"); exit(0); }
int main(int argc,char **argv) { char demfile[MAXLN],newfile[MAXLN],flowfile[MAXLN]; int err,order,subbno,i; short useflowfile=0; bool verbose=false; // Initialize verbose flag bool is_4p = false; // four-point flow method versus eight-point, arb 5/31/11 char maskfile[MAXLN]; // mask out actual depressions, arb 5/31/11 bool use_mask = false; // flag to specify the optional mask file, arb 5/31/11 if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-z")==0) { i++; if(argc > i) { strcpy(demfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-fel")==0) { i++; if(argc > i) { strcpy(newfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-ddm")==0) { i++; if(argc > i) { if(strcmp(argv[i],"row")==0) { tdpartition::decompType = DECOMP_ROW; } else if (strcmp(argv[i],"column")==0) { tdpartition::decompType = DECOMP_COLUMN; } else if (strcmp(argv[i],"block")==0) { tdpartition::decompType = DECOMP_BLOCK; } else { goto errexit; } i++; } else goto errexit; } else if(strcmp(argv[i],"-sfdr")==0) { i++; if(argc > i) { strcpy(flowfile,argv[i]); useflowfile=1; i++; } else goto errexit; } else if(strcmp(argv[i],"-v")==0) { i++; verbose=true; } else if(strcmp(argv[i],"-4way")==0) // arb added, 5/31/11. This is the flag for 4-point pour method { i++; is_4p=true; } else if(strcmp(argv[i],"-depmask")==0) // arb added, 5/31/11. This is to input the optional depression mask file { i++; if(argc > i) { strcpy(maskfile,argv[i]); use_mask=true; i++; } else goto errexit; } else { goto errexit; } } if( argc == 2) { strcpy(demfile,argv[1]); //printf("File %s\n",demfile); nameadd(newfile,argv[1],"fel"); } // Debugging prints if(verbose) { printf("On input demfile: %s\n",demfile); printf("On input newfile: %s\n",newfile); printf("%ssing mask file: %s\n",use_mask?"U":"Not U", use_mask?maskfile:"N/A"); fflush(stdout); } useflowfile=0; // useflowfile not implemented if((err=flood(demfile,newfile,flowfile,useflowfile,verbose,is_4p,use_mask,maskfile)) != 0) printf("PitRemove error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -z <demfile>\n",argv[0]); printf("-fel <newfile> [-sfdr <flowfile>] [-ddm <ddm>]\n"); printf("<basefilename> is the name of the raw digital elevation model.\n"); printf("<demfile> is the name of the input elevation grid file.\n"); printf("<newfile> is the output elevation grid with pits filled.\n"); printf("<flowfile> is the input grid of flow directions to be imposed.\n"); printf("<ddm> is the data decomposition method. Either \"row\", \"column\" or \"block\".\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("fel output elevation grid with pits filled.\n\n"); exit(0); }
int main(int argc,char **argv) { char angfile[MAXLN],wgfile[MAXLN],raccfile[MAXLN],dmaxfile[MAXLN]; int err,i; if(argc < 2) { printf("Error: To run this program, use either the Simple Usage option or\n"); printf("the Usage with Specific file names option\n"); goto errexit; } else if(argc > 2) { i = 1; // printf("You are running %s with the Specific File Names Usage option.\n", argv[0]); } else { i = 2; // printf("You are running %s with the Simple Usage option.\n", argv[0]); } while(argc > i) { if(strcmp(argv[i],"-ang")==0) { i++; if(argc > i) { strcpy(angfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-wg")==0) { i++; if(argc > i) { strcpy(wgfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-racc")==0) { i++; if(argc > i) { strcpy(raccfile,argv[i]); i++; } else goto errexit; } else if(strcmp(argv[i],"-dmax")==0) { i++; if(argc > i) { strcpy(dmaxfile,argv[i]); i++; } else goto errexit; } else { goto errexit; } } if( argc == 2) { nameadd(angfile,argv[1],"ang"); nameadd(wgfile,argv[1],"wg"); nameadd(raccfile,argv[1],"racc"); nameadd(dmaxfile,argv[1],"dmax"); } if((err=dsaccum(angfile,wgfile,raccfile,dmaxfile)) != 0) printf("dsaccum error %d\n",err); return 0; errexit: printf("Simple Usage:\n %s <basefilename>\n",argv[0]); printf("Usage with specific file names:\n %s -ang <angfile>\n",argv[0]); printf("-wg <wgfile> -racc <depfile> -dmax <maxfile>\n"); printf("<basefilename> is the name of the raw digital elevation model\n"); printf("<angfile> is the D-infinity flow direction input file.\n"); printf("<wgfile> is the input weight grid file.\n"); printf("<depfile> is the output reverse accumulation grid file.\n"); printf("<maxfile> is the output maximum downslope grid file.\n"); printf("The following are appended to the file names\n"); printf("before the files are opened:\n"); printf("ang D-infinity flow direction input file\n"); printf("wg Input weight grid\n"); printf("racc output reverse accumulation grid\n"); printf("dmax Output transport limitted accumulation grid\n"); printf("tdep output maximum downslope grid\n"); exit(0); }