/* Program: img_plot.aml /* /* Purpose: Creates a plotfile in the specified output format from the /* input image or grid. Allows sub-image (inset) plotting. /* /* Usage: &r img_plot /* /* Supported image formats: TIFF, BIL, BIP, BSQ, RLC, Arc GRID, /* SUNRASTER, ERDAS, IMAGINE, GRASS /* If running Arc 7.1 or higher, also supports JPEG, BMP input images /* Supported plotfile formats: Arc 1040 (GRA), EPS, CGM /* /* Calls: img_plot.menu /* /* Notes: Uses ArcPlot to zoom and create plotfile of zoomed extent. /* /* If a known image is not listed on the menu for selection, then /* it may be missing a corresponding header file (.hdr for BIL, BIP, /* BSQ; or .tfw for TIFF). Use the DOQHEAD toolkit to create a /* ".hdr" file for BIL/BIP DOQ images. Manually create a ".tfw" /* file for TIFF images. The following are useable dummy .hdr and /* .tfw files which will fool ARC into recognizing non-referenced /* images (these will not correctly geo-reference an image, just /* pseudo-reference for plotting's sake). These dummy header files /* are useful when plotting non-registered scanned 9 in x 9 in /* aerial photos with no georeferencing or orthographic correction: /* whatever.tfw whatever.hdr /* ------------ ------------ /* 1.00 nrows 10240 /* 0.00 ncols 10240 /* 0.00 ulxmap 0.0 (dummy x) /* -1.00 ulymap 10250.0 (dummy y) /* 0.0 (dummy x) xdim 1.00 /* 10250.0 (dummy y) ydim 1.00 /* layout bil /* nbands 1 /* /* /* History: JKosovich 09/10/97 Original coding /* JKosovich 03/31/98 Modified to display, zoom, and plot via menu /* /*------------------------------------------------------------------------------ /* &args routine &severity &error &routine bailout &s prog = [ENTRYNAME %aml$file% -NOEXT -FILE] /* current AML being run &if [NULL [SHOW &watch]] &then &watch %prog%.watch /* /***** Set amlpath if not set, or if AML called by full pathname ***** /* &s path = [DIR %aml$fullfile%] &if [NULL [SHOW &amlpath]] &then &amlpath %path% &else &amlpath %path% [SHOW &amlpath] /* no problem if duplicated &menupath [SHOW &amlpath] /* /***** If arg passed in, must be routine from menu ***** /* &if ^ [NULL %routine%] &then &do &call %routine% &return &end &if [NULL [EXTRACT 1 [SHOW &terminal]]] &then &terminal 9999 /* /***** Determine ARC/INFO version for supported image formats, then ***** /***** echo these formats to screen before calling menu. ***** /* &call echo_formats /* /***** Call menu ***** /* &type *** Please wait for menu... &call menu &if %.i_cancel% &then &do &call exit &return &end /* /***** Set DISPLAY option # from chosen output format (used in plot routn) ***** /* &select [UPCASE %.i_format%] &when GRA &s disopt = ' ' &when EPS &s disopt = 2 &when CGM &s disopt = 6 &otherwise &s disopt = ' ' /* just in case &end /* select /* /***** If plotting subset of image, call routine ***** /* &if [UPCASE %.i_extent%] = INSET &then &call inset /* /***** Plot image ***** /* &type &type *** Creating output plotfile %.i_plotfile%. Please wait... &call plot /* /***** All done, exit successfully ***** /* &type &type &type ******************************************************** &type Plotfile %.i_plotfile% successfully created. &type Thanks for using %prog%.aml, [UPCASE [USERNAME]]! &type ******************************************************** &type &type &call exit &return /******************************************************************************* /******************** ROUTINE LIST ************************* /******************************************************************************* /* /*------------------- &routine ECHO_FORMATS /*------------------- /* Echo supported image and plotfile formats to user &s arcver = [EXTRACT 1 [SHOW VERSION]] /* eg. 7.0.4, 7.1, 7.1.1 &s arcver1 = [BEFORE %arcver% .] /* eg. 7 &if %arcver1% < 7 &then &return &error \*** NOTE: Must use Arc version 7.0 or newer (%arcver%)\\ &s arcver2 = [SUBSTR [AFTER %arcver% .] 1 1] /* digit after the 7, eg. 0, 1 &if %arcver2% = 0 & %arcver1% = 7 &then /* if 7.0.3, 7.0.4, etc. &do &s inlist1 = TIFF, BIL, BIP, BSQ, RLC, Arc GRID, &s inlist2 = SUNRASTER, ERDAS, IMAGINE, GRASS &s outlist1 = GRA, EPS, CGM &s ex = bil &end &else &if %arcver2% > 0 | %arcver1% > 7 &then /* if 7.1, 7.1.1, 8.0, etc. &do &s inlist1 = TIFF, JPEG, BIL, BIP, BMP, BSQ, RLC, &s inlist2 = SUNRASTER, ERDAS, IMAGINE, GRASS, Arc GRID &s outlist1 = GRA, EPS, CGM &s ex = jpeg &end &s outlist = %outlist1% &type &type &type &type *********************************************************************** &type ********************* Program: %prog%.aml ************************* &type *********************************************************************** &type *** Supported image formats: %inlist1% &type *** %inlist2% &type *** Supported plotfile formats: %outlist1% &type *********************************************************************** &type &type &return /*----------- &routine MENU /*----------- /* /* Call menu &s .i_cancel = .FALSE. &thread &create i$imgplot &modal ~ &menu img_plot ~ &stripe 'IMAGE PLOTTING MENU' ~ &position &uc &screen &uc ~ &pinaction '&r img_plot cancel' &return /*------------ &routine INSET /*------------ /* Called if inset plot was chosen &type &type *** Please wait for image to draw on screen... DISPLAY 0 &s quit = .TRUE. &if [UPCASE [SHOW PROGRAM]] = ARCPLOT &then &s quit = .FALSE. &else ARCPLOT DISPLAY 9999 3 MAPEXTENT IMAGE %.i_image% IMAGE %.i_image% /* Zoom in until user indicates correct extent &messages &popup &do &while ^ [QUERY 'Is the image extent correct' .FALSE.] MAPEXTENT * CLEAR IMAGE %.i_image% &end &messages &on /* Capture final mapextent &s .i_mapextent = [SHOW MAPEXTENT] &s .i_xmin = [EXTRACT 1 [SHOW MAPEXTENT]] &s .i_ymin = [EXTRACT 2 [SHOW MAPEXTENT]] &s .i_xmax = [EXTRACT 3 [SHOW MAPEXTENT]] &s .i_ymax = [EXTRACT 4 [SHOW MAPEXTENT]] &s .i_dx = [CALC %.i_xmax% - %.i_xmin%] &s .i_dy = [CALC %.i_ymax% - %.i_ymin%] &if %quit% &then QUIT &return /*----------- &routine PLOT /*----------- /* DISPLAY 0 &s quit = .TRUE. &if [UPCASE [SHOW PROGRAM]] = ARCPLOT &then &s quit = .FALSE. &else ARCPLOT DISPLAY 1040 %disopt% %.i_plotfile% &type \*** Plotting image...\ &if [UPCASE %.i_extent%] = FULL &then MAPEXTENT IMAGE %.i_image% &else MAPEXTENT %.i_mapextent% &s xmax = [EXTRACT 3 [SHOW MAPEXTENT PAGE]] &s ymax = [EXTRACT 4 [SHOW MAPEXTENT PAGE]] /* /***** If longer in x than y, landscape, etc. ***** /* /*&if %xmax% > %ymax% &then /*PAGESIZE %landscape% /*&else &if %xmax% < %ymax% &then /*PAGESIZE %portrait% /*&else /*PAGESIZE %square% PAGESIZE %.i_pgx% %.i_pgy% IMAGE %.i_image% QUIT &type *** Output plotfile %.i_plotfile% created. &return /*------------------- &routine CANCEL /*------------------- /* /* If menu was Cancelled or pin was pulled /* &s .i_cancel = .TRUE. &type &type &type *** Image plotting cancelled. &type &type &if [SHOW &thread &exists i$imgplot] &then &thread &delete i$imgplot &return /*----------- &routine EXIT /*----------- /* &if [SHOW &thread &exists i$imgplot] &then &thread &delete i$imgplot &if [EXISTS xxmsg -FILE] &then &s dok = [DELETE xxmsg -FILE] &dv .i* &return /*-------------- &routine BAILOUT /*-------------- /* &severity &error &ignore &messages &on &if [VARIABLE quit] &then &do &if [UPCASE [SHOW PROGRAM]] = ARCPLOT & %quit% &then QUIT &end /* /***** Close files (no problem if not open) ***** /* /*&s cok = [CLOSE -ALL] /*&if [VARIABLE tmpfile] &then /*&if [EXISTS %tmpfile% -FILE] &then &s dok = [DELETE %tmpfile%] /* &type \***** Error occurred at line %aml$errorline% in %aml$errorfile% *****\ &call exit &return; &return &error