Main Page/Stuff/Luc's AML
From phurvitz
< Main Page | Stuff
Revision as of 17:42, 6 November 2007 by Phil Hurvitz (talk | contribs)
/*---------------------------- /* change dir w D:\SAPRP_Working_Files\Raster_Calculations\Sample_Frame\costd /*---------------------------- /* start grid grid /*---------------------------- /* gridpoint if ^[exists frameg -grid] &then framep = gridpoint (..\frame4) /* add an area and count field to the frame points &if ^[iteminfo framep -point needlecount -exists] &then additem framep.pat framep.pat needlecount 5 5 i &if ^[iteminfo framep -point cdarea -exists] &then additem framep.pat framep.pat cdarea 10 10 i /* max distance to costdistance function &sv maxdist 100 /*---------------------------- /* count points &describe framep &sv numpoints = dsc$points /*---------------------------- /* go! &do i = 1 &to %numpoints% &type %i% of %numpoints% /* select the point i reselect framep point framep# = %i% /* save the selection writeselect pts.sel framep point /* reselect from framep to create p1 reselect framep p1 point pts.sel /* delete the selection file &if [exists pts.sel -file] &then &sv d [delete pts.sel -file] &if [exists pts.sex -file] &then &sv d [delete pts.sex -file] /* create a grid from the one selected point pointg = pointgrid(p1) /* run the costdistance outg = con(costdistance(p1, ..\frame4, #, #, %maxdist%) > 0, 1, 0) /* get the cell count (assumes only one value in the grid!) &sv cellcount = [show outg.vat info 1 item count] /* cell count * 9 = area &sv cdarea = 9 * %cellcount% /* create a polygon from the costdistance grid poly1 = gridpoly (outg) /* reselect needle points that overlap clearselect reselect needles point overlap poly1 poly # # /* count of selection &sv numneedles = [extract 1 [show select needles point]] /* write selection and area back onto frameg point calc framep point needlecount = %numneedles% calc framep point cdarea = %cdarea% /* kill intermediate files kill pointg kill outg kill poly1 &end