/* --------------------------------------- /* Program: pipfa.aml /* Author: Andrew Turner /* Date: 13th December 1996 /* Date last modified: 14/01/97 /* --------------------------------------- /* /* ------------------------------- /* 1. Introduction to the program. /* ------------------------------- &type &type Running pipfa.aml &type &type Program to perform point-in-polygon frequency analysis &type &type By Andrew Turner &type &type Hello [username], today's date is [date] &type /* -------------------------------------------------------- /* 2. Selecting the point and polygon coverages to be used. /* -------------------------------------------------------- &type Please wait then select the coverages to be used ... &type &type A menu should appear soon to select a polygon coverage, &type rearrange on screen windows until it is found and select. &type /* Menu to select polygon coverage. &sv cover1 [entryname [getcover * -polygon 'select a polygon coverage']] &type A menu should appear to select a point coverage in time, &type rearrange on-screen windows until it is found and select. &type /* Menu to select point coverage. &sv cover2 [entryname [getcover * -point 'select a point coverage']] &type &pause /* Confirmation of coverage selection. &type &type The following coverages are to be used: &type &type polygon coverage: %cover1% &type point coverage: %cover2% &type /* --------------------------------------------------- /* 3. Dealing with the frequency item in %cover1%.pat. /* --------------------------------------------------- /* Check to see if frequency item exists and give an option to rename. &if [iteminfo %cover1%.pat -info FREQUENCY -exists] &then &do &type Warning frequency item already exists in the polygon attribute table! &type You can either delete this item or rename it to continue. &type &type Warning answer the following by typing 'YES' or 'NO' only. &type Entering anything else may crash the program! &type /* Query whether user wants frequency renamed. &sv rename = [query 'Renname YES/NO' .FALSE.] &if %rename% = .TRUE. &then &do /* Renaming frequency. &label rename_frequency &type /* Asking user for new name. &sv renamefreq = [response 'Enter a new item name for the existing frequency item in upper case letters:'] /* Check to see if no name was entered. &if [null %renamefreq%] &then &do &type &type You did not enter a item name. &type Please try again. &type &goto rename_frequency &end /* Check to see if new name is an existing item name. &if [iteminfo %cover1% -poly %renamefreq% -exists] &then &do &type Warning this is an existing item name! &type Please try again. &type &delvar renamefreq &goto rename_frequency &end &sv cover1b = [upcase %cover1%] /* Calling info to rename frequency. &data arc info ARC SELECT %cover1b%.PAT ALTER FREQUENCY %renamefreq% 5 B 1 %renamefreq%1 1 N N 1 1 Q STOP &end /* Removing frequency. &end &if %rename% = .FALSE. &then &do &type Dropping item frequency from %cover1%.pat &type /* DROPITEM {drop_item} &messages &off dropitem %cover1%.pat %cover1%.pat frequency &messages &on &end &end &pause /* ----------------------------------- /* 4. Creating the intersect coverage. /* ----------------------------------- /* INTERSECT {POLY | LINE | POINT} /* {fuzzy_tolerance} {JOIN | NOJOIN} /* Name and check . &type &type Name the intersect coverage of %cover1% and %cover2%. &type &label name_intersect /* Setting name. &sv cover3 = [response 'Enter a short character string'] /* Check to see if no name was entered. &if [null %cover3%] &then &do &type &type You did not enter a coverage name. &type Please try again. &type &delvar cover3 &goto name_intersect &end /* Check to see whether the name given is an existing coverage name. &if [exists %cover3% -cover] &then &do &type Warning this is an existing coverage name! &type Please try again. &delvar cover3 &goto name_intersect &end &type &type Creating the intersection %cover3% of %cover1% and %cover2%. &type please wait ... &type /* Performing the intersection. &messages &off intersect %cover2% %cover1% %cover3% point &messages &on /* -------------------------------------------------------- /* 5. Calculating the number of points inside the polygons. /* -------------------------------------------------------- /* FREQUENCY {case_item} /* /* Enter Frequency item names (type END oa r blank line when done): /* ================================================================ /* Enter the 1st item: /* /* Enter Summary item names (type END or a blank line when done): /* ============================================================== /* Enter the 1st item: /* /* Check to see if the exists &type Calculating the number of points inside each polygon. &type Be patient this may take some time ... &type /* Setting the name of the . &label name_output &sv o = [response 'Enter a short character string to name the frequency table'] &sv output = [upcase %o%] /* Check to see if no name was entered &if [null %o%] &then &do &type &type You did not enter anything. &type Please try again. &type &delvar o &delvar output &goto name_output &end /* Check to see if the name already exists. &if [exists %output%.TAB -info] &then &do &type Warning this table name already exists! &type Please try again. &delvar output &delvar o &goto name_output &end /* Performing the frequency calculations. &messages &off frequency %cover3%.pat %output%.TAB %cover1%-id end end &messages &on /* -------------------------------------------------- /* 6. Joining the frequency data to the %cover1%.pat. /* -------------------------------------------------- /* JOINITEM /* {LINEAR | ORDERED | LINK} &type Joining the frequency item to %cover1%.pat. &type Please wait ... &type /* Joining frequency. /* &messages &off joinitem %cover1%.pat %output%.tab %cover1%.pat %cover1%-id %cover1%-id /* &messages &on /* ------------------------------------ /* 7. Visualising the frequency values. /* ------------------------------------ &type Press return for a list of frequency for each %cover1%-id. &type &pause &type A list should appear. &type /* Listing the frequency output table. list %output%.TAB &type &type Press return to list the new polygon attribute table %cover1%.pat. &type &pause &type The table should appear. &type /* Listing the new %cover1%.pat. list %cover1%.pat /* ----------------------------------------------- /* 8. Deleting unwanted coverages, files and items /* ----------------------------------------------- &type Warning answer the following by typing 'YES' or 'NO' only. &type Entering anything else may crash the program! &type &pause /* Querying whether user wishes to kill the intersect cover %cover3%. &sv keep1 = [query 'Delete the intersect cover %cover3% yes/no' .true.] &then kill %cover3% &type &pause /* Querying whether user wishes to delete the frequency table. &sv keep2 = [query 'Delete the frequency table yes/no' .true.] &then &do &data arc info ARC SELECT %output%.TAB DELETE %output%.TAB Y Q STOP &end &pause /* --------------------- /* 9. Ending the program. /* --------------------- &type &type ------------------------------- &type This is the end of the program. &type Thankyou! &type Goodbye! &type ------------------------------- &return