SmartProject

    Table of contents
    1. 1. The Problem
    2. 2. The Workaround

     

     

    The Problem

    In interactive mode, PROJECT uses the inherent defined projection and only asks for the output projection description:

       Arc: project cover incov outcov
    
       **************************************************
       *      The INPUT projection has been defined.    *
       **************************************************
       Use OUTPUT to define the output projection and END
       to finish.
       Project:
    
    In non-interactive mode you must define the input and output descriptions in an external file like this:

    Arc: project cover incov outcov \path\to\dd2albers.prj

    Where "dd2albers.prj" looks like:

          INPUT
          projection gegraphic
          units dd
          datum nad83
          parameters
          OUTPUT
          projection albers
          units meters
          datum nad83
          paramaters
           61 40  0.000 
           68  0  0.000 
          -132 30  0.000
           59  0  0.000
          500000.00000
          500000.00000
          END
    
    Even though the input projection is defined in the cover, when passing a projection file on the commandline, PROJECT *does not verify the external INPUT description is correct* And, it won't work without the external description.

    This is an error waiting to happen since there is no guarantee the projection as written in the prj text file matches the projection as defined internally in the cover. And then there's the headache of managing N-dozen prj1_to_prj2 projection files.

     

    The Workaround

    As it turns out there is a way to force PROJECT to think it is running interactively, thus using the defined projection, plus using an external projection file for automation:

    &sys arc project cover incov outcov \path\albers.prj

    where "albers.prj" looks like:

       /* the '&if' lines allows this prj file to be used automatically with
       /* with PROJECT and PROJECTDEFINE. The semicolon at the beginning of
       /* the line is important. To use this file from Arc:
       /* "&sys arc project <grid|cov> <cov_in> <cov_out> <%.prj%\albers.prj"
       /* "&sys arc projectdefine <grid|cov> <cov> <%.prj%\albers.prj"
       ;&if [locase[show program]] = project &then; OUTPUT;
          Projection    ALBERS
          Datum         NAD83
          Zunits        NO
          Units         METERS
          Spheroid      GRS1980
          Xshift        0.0000000000
          Yshift        0.0000000000
             Parameters
           61 40  0.000 /* 1st standard parallel
           68  0  0.000 /* 2nd standard parallel
          -132 30  0.000 /* central meridian
           59  0  0.000 /* latitude of projection's origin
          500000.00000 /* false easting (meters)
          500000.00000 /* false northing (meters)
       ;&if [locase[show program]] = project &then; END;
    </cov></cov_out></cov_in>

    You don't really need the &if lines, you can just slap the OUTPUT and END lines in there anyway, but using &if gets you one less error message.

    There is a speed penalty to pay since you are invoking a shell within a shell with a shell, but it's pretty cheap compared to the added security and reliability.

    %.prj% points to a network shared drive which all users can read (x:\arcutils\prj)

     

    PostScript: the same methodology can be used to automate other interactive commands like Append:

    &sys arc append outcov < list_of_covers.txt

    -- MattWilkie - 05 Feb 2001

     


    smart-proj.aml: AML which implements the approach discussed here.

    To use:

    • create a global variable .PRJ which points to where your projection files are stored, e.g. z:\arcutils\prj .Have this var set everytime you start Arc (ESRI:11653).
    • put your smart projection definition files in .PRJ\smart\ (without any extension)

    The command

       Arc: &r smart-proj * albers
    
    will project all of the covers in the current directory to Albers. Output is in a workspace called Albers under the current workspace.

    The script is noisier than I'd like, ouputting so many messages to the screen that it's hard to see what's going on. It works well though and that's what matters to me. smile

     

    -- MattWilkie - 20 Apr 2004

     

     

     

     

    WebForm
    TopicCategory HowTo
    I Attachment Action Size Date Who Comment
    elseaml smart-proj.aml manage 3.3 K 2004-04-20 - 16:34 MattWilkie AML which implements the approach discussed here

     

        Send feedback