' '---------------------------- '--- Creation information --- '---------------------------- ' 'Name: pointld.ave 'Version: 1.0 'Date: 06/2/97 'Author: Ferdi Hellweger ' Center for Research in Water Resources ' The University of Texas at Austin ' ferdi@crwr.utexas.edu ' ' '--------------------------- '--- Purpose/Description --- '--------------------------- ' 'A point load grid is computed from a point, polyline and/or polygon ftheme based 'on the value in a field in the feature attribute table. ' '-------------------- '--- User's guide --- '-------------------- ' '1. Set the analysis cell size and extent. '2. Highlight the input feature theme(s). Multiple themes can processed. '3. Run the program. '4. Supply the field(s) holding the point load. ' '------------- '--- Notes --- '------------- ' '1. This program supports loads attached to points, polylines and polygons. ' The loads are placed on the grid as follows: ' Points: at the point. ' Polylines: at the first point of the line. ' Polygons: half way between the centroid and the first point of of the boundary. ' '2. When using this with the CONNECT and PICKLOAD methodology the program output ' has to be checked to see that the loads for polygons are not placed in the ' 5x5 rectangle around the centroid of the water quality segments. If that is ' the case the methodology for locating the load for polygons should be altered. ' '3. The program uses a rather crude way to value the point load grid. First a ' point shape file is created, which is then converted to a grid with the ' makefromftab request. It would be much easier if cells could be valued in ' the same as as with the ARC/INFO grid fillcell command. An equivalent has ' not been found in the spatial analyst. ' '4. The output of this program is a point source load grid in the same units as ' the load field in the input feature theme. ' '5. The point source load grid should be added to the nonpoint source load grid ' to create a total load grid before a weighted flow accumulation is done. ' '---------------- '--- Get view --- '---------------- ' theview = av.getactivedoc ' '-------------------- '--- Get theme(s) --- '-------------------- ' thethemes = theview.getactivethemes if (thethemes.count = 0) then msgbox.error("No themes found", "POINT LOAD GRID") exit end thefthemes = list.make for each thetheme in thethemes if (thetheme.getclass.getclassname = "ftheme") then thefthemes.add(thetheme) end end if (thefthemes.count = 0) then msgbox.error("No feature themes found", "POINT LOAD GRID") exit end ' '------------------------------ '--- Set up point load grid --- '------------------------------ ' plgrid = grid.makefromnumb(0.0) ' '------------------------ '--- Set up temp ftab --- '------------------------ ' tempftab = ftab.makenew(("tempname").asfilename, point) tempftab.seteditable(true) tempshapef = tempftab.findfield("shape") tempfields = list.make temploadf = field.make("load", #FIELD_DECIMAL, 16, 4) tempfields = tempfields.add(temploadf) tempftab.addfields(tempfields) temprec = tempftab.addrecord ' '-------------------------- '--- Process each theme --- '-------------------------- ' for each thetheme in thefthemes ' '--- Set up theme --- ' theftab = thetheme.getftab theshapef = theftab.findfield("shape") ' '--- Get field --- ' thefields = theftab.getfields theloadf = msgbox.listasstring(thefields, "Choose point load field for " + thetheme.getname, "POINT LOAD GRID") if (theloadf = nil) then exit end ' '--- Process each feature --- ' for each thefeature in theftab 'check load theload = theftab.returnvalue(theloadf, thefeature) if (theload > 0) then 'get point theshape = theftab.returnvalue(theshapef, thefeature) if (theshape.getclass.getclassname = "point") then thepoint = theshape end if (theshape.getclass.getclassname = "polyline") then thepoint = theshape.asmultipoint.aslist.get(0) end if (theshape.getclass.getclassname = "polygon") then thecentroid = theshape.returncenter cenx = thecentroid.getx ceny = thecentroid.gety theboundarypoint = theshape.aspolyline.asmultipoint.aslist.get(0) boundx = theboundarypoint.getx boundy = theboundarypoint.gety pointx = ((cenx + boundx) / 2) pointy = ((ceny + boundy) / 2) thepoint = point.make(pointx, pointy) if (not (thepoint.iscontainedin(theshape))) then msgbox.info("Point load assigned outside polygon.", "POINT LOAD GRID") end end 'value temp ftab tempftab.seteditable(true) tempftab.setvalue(tempshapef, temprec, thepoint.clone) tempftab.setvalue(temploadf, temprec, theload.clone) tempftab.seteditable(false) 'make temp grid tempgrid = grid.makefromftab(tempftab, prj.makenull, temploadf, nil) 'add temp grid to point load grid plgrid = tempgrid.isnull.con(plgrid, (plgrid + tempgrid)) end end end ' '--------------------------------- '--- Save grid and add to view --- '--------------------------------- ' plgtheme = gtheme.make(plgrid) theview.addtheme(plgtheme) plgtheme.setvisible(true) ' '----------------------------- '--- Final message to user --- '----------------------------- ' message = "Point load grid calculated." msgbox.info(message,"POINT LOAD GRID") ' '----------- '--- End --- '----------- '