English

How To: Recover INFO data when the arc.dir file is corrupt

Summary

When the INFO directory file (arc.dir or arcdr9) becomes corrupt, you can no longer access your attribute data. The arc.dir file is accessed more than just about any other file which ARC/INFO uses. This can become corrupt, particularly if two people are working in the same workspace at the same time.

For coverage data, the actual data is stored under the coverage directory, in what INFO calls an external file. So the data is usually OK, it just can't be accessed because the directory file is corrupt. If no backups are readily available, you can still recover the data and make the coverage usable again.

Procedure

  1. Use the operating system to copy the coverage directory to a new location, for example:

    Code:
    % cp cover /disk1/restore/cover


  2. Create a new workspace in the directory in which you've copied the coverage directory.

    A workspace can be created from an existing directory, or as a new system directory using the Arc CREATEWORKSPACE command. The command can be abbreviated as 'cw'.

    Examples:

    Arc: cw \disk1\data

    Arc: cw . (creates a workspace in the current directory)

    The target can be an existing system directory. If the target directory does not exist, Arc will create it.

  3. If you know the item definitions for each coverage feature attribute table, use the INFO DEFINE command to define new tables for each FAT. Remember to include the default Arcinfo items (eg. AREA, PERIMETER, etc.).
  4. If you do not know the item definitions, you can use NIT_TO_INFO.AML

    /*A------------------------------AUTHOR---------------------------------
    /*
    /*Original Coding: ESRI
    /*
    /*N-------------------------------NAME----------------------------------
    /*
    /* NIT_TO_INFO.AML
    /*
    /*Copyright 1997, Environmental Systems Research Institute, Inc.
    /*
    /*P-----------------------------PURPOSE---------------------------------
    /*
    /* Converts an INFO 'nit' file to a new INFO template with
    /* the same item definitions. The new template can than
    /* be renamed and/or externalled to an existing coverage file,
    /* for example pat.adf, in cases where the INFO arc.dir file
    /* has been corrupted and the INFO data can no longer be accessed.
    /*
    /*
    /*U------------------------------USAGE----------------------------------
    /*
    /* nit_to_info
    /*
    /*============================DISCLAIMER================================
    /*You may use, copy, modify, merge, distribute, alter, reproduce and/or
    /*create derivative works of this AML for your own internal use. All
    /*rights not specifically granted herein are reserved to ESRI.
    /*
    /*THIS AML IS PROVIDED "AS-IS" WITHOUT WARRANTY OF ANY KIND, EITHER
    /*EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    /*WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
    /*WITH RESPECT TO THE AML.
    /*
    /*ESRI shall not be liable for any damages under any theory of law
    /*related to your use of this AML, even if ESRI is advised of the
    /*possibilites of such damage. This AML is not supported by ESRI.
    /*======================================================================

    &severity &error &routine bail
    &args nit_file out_file

    &if [exists %out_file% -info] &then
    &return INFO file %out_file% already exists
    &if ^ [exists %nit_file% -file] &then
    &return NIT file %nit_file% not found

    /* make an INFO template to read in the NIT file

    &call make_template

    &s scratch [scratchname -file]

    tables
    sel template
    get %nit_file%
    resel itmplv <> 0
    unload %scratch% itmnam itmwid itmowd itmtyp itmndp init
    nsel

    /* Create a file for the redefined items, if present

    &if [show number select] <> 0 &then
    unload %scratch%.red itmpos itmnam itmwid itmowd itmtyp itmndp init

    /* define the new file

    def %out_file%
    &s file [open %scratch% ostat -read]
    &s definition [read %file% rstat]
    &do &while %rstat% = 0
    &s name [extract 1 %definition%]
    &s width [extract 2 %definition%]
    &s output [extract 3 %definition%]
    &s type [extract 4 %definition%]
    &s decimal [extract 5 %definition%]

    &call set_type

    %name%,%width%,%output%,%item_type%,%decimal%

    &s definition [read %file% rstat]
    &end

    ~

    &s c [close %file%]

    /* redefine items, if necessary

    &if [exists %scratch%.red -file] &then
    &do
    &s file [open %scratch%.red ostat -read]
    &s definition [read %file% rstat]
    &do &while %rstat% = 0
    redefine
    &s start [extract 1 %definition%]
    &s name [extract 2 %definition%]
    &s width [extract 3 %definition%]
    &s output [extract 4 %definition%]
    &s type [extract 5 %definition%]
    &s decimal [extract 6 %definition%]

    &call set_type

    %start%,%name%,%width%,%output%,%item_type%,%decimal%

    &s definition [read %file% rstat]
    &end

    ~

    &end

    /* clean up

    &s c [close %file%]
    &s d [delete %scratch% -file]
    &s d [delete %scratch%.red -file]
    &s d [delete template -info]

    quit

    &return

    &routine make_template
    /*
    /* Creates an INFO template in which the item information
    /* is loaded from the NIT file
    /*
    &s d [delete template -info]
    tables
    def template
    itmnam,16,16,c
    itmwid,2,5,b
    itmkyt,2,5,b
    itmpos,2,5,b
    itmplv,2,5,b
    itmnum,2,5,b
    itmowd,2,5,b
    itmndp,2,5,b
    itmtyp,2,5,b
    itmro,2,5,b
    itmklv,2,5,b
    itmidx,2,5,b
    itmocc,2,5,b
    itmbfs,2,5,b
    itmalt,16,16,c
    itmfmt,16,16,c
    itmclv,2,5,b
    itmnmr,2,5,b
    itmxar,32,32,c
    itmcc,2,5,b
    itmcm,2,5,b
    itmlin,2,5,b
    itmrfu,28,28,c
    ~

    quit
    &return

    &routine set_type
    /*
    /* Sets item type based on the flag in the NIT file.
    /* NOTE: only item types supported by ARC/INFO are
    /* included
    /*
    &select %type%
    &when 1
    &s item_type D
    &when 2
    &s item_type C
    &when 3
    &s item_type I
    &when 4
    &s item_type N
    &when 5
    &s item_type B
    &when 6
    &s item_type F
    &end

    &if %decimal% = -1 &then
    &s decimal

    &return

    &routine bail
    /* out of a define dialogue, if necessary
    ~
    ~
    ~
    ~
    ~

    &if [show program] = TABLES &then
    quit
    &s c [close %file%]
    &s d [delete %out_file% -info]
    &s d [delete template -info]
    &s d [delete %scratch% -file]
    &type An error has occurred in NIT_TO_INFO.AML

    &return Deleting any files created...



    You'll need to look at the corresponding arcxxxx.dat file to find out which 'nit' file belongs to which INFO table. Since coverage attribute tables are stored externally, the 'dat' file contains a pointer to the external file. If you cat the file at the system prompt, you can see which file the INFO file is externalled to, and from that tell what kind of attribute table it is. For example:
    Code:
    [paramount](jriz)<194>:cat arc0000.dat
    ../penn/pat.adf
    [paramount](jriz)<195>:


    The file arc0000.dat points to the pat.adf file under the penn directory, so this is the PAT file for the coverage PENN. In the new workspace, you can create a new item template for PENN.PAT using NIT_TO_INFO.AML. After running the AML, you can then external the new file to the coverage directory:

    Code:
    ENTER COMMAND >SEL PENN.PAT
    0 RECORD(S) SELECTED

    ENTER COMMAND >EXTERNAL
    ENTER COMPLETE FILE NAME OF EXTERNAL FILE
    ../penn/pat.adf

    ENTER COMMAND >SEL PENN.PAT
    68 RECORD(S) SELECTED

    ENTER COMMAND >


    This ties the new INFO template back to the data under the coverage directory.
  5. You should now be able to view your coverage data.