Adv_GIS - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Adv_GIS

Description:

the table document you use in ArcView is a user interface for a VTab (a virtual table) ... ChineseZodiac = MsgBox.Input('What is your Chinese Zodiac symbol?,'Symbol' ... – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 17
Provided by: Pete8
Category:
Tags: advgis | chinese | zodiac

less

Transcript and Presenter's Notes

Title: Adv_GIS


1
Tables and Attributes
  • Week3, Fall 2003

2
Object model for tables
  • the table document you use in ArcView is a user
    interface for a VTab (a virtual table). You can
    only do a few things with the table document
    itself (sort and promote), the majority of your
    work will be with VTab
  • The VTab is built from one or more physical
    tabular sources on disk (INFO,dBASE or txt). The
    sources are presented to you as a single virtual
    table. You can edit,query and extend your
    tables.
  • Each VTab has two Bitmaps, a selection Bitmap and
    a definition Bitmap

3
Add theme from xy coords
  • Create a text file (xy_table.txt) with No. X, Y
    as headings and (1,-85.71,36.17),(2,-85.39,36.21)
    , (3, -85.29, 36.02), (4, -85.63,36.04). Use
    Notepad and save the file with txt extension
    (xy_table.txt) to your folder.
  • Create a New Project and Add New View (you may
    use the script from your previous homework) and
    name the View as Putnam
  • Add putshape.shp from the folder
    U\4850_5850\Data_Center\week4 using script (from
    your previous homework) See demo.
  • theFileName "c\4850\data_center\week3\xy_table.
    txt".AsFileName
  • theVTab VTab.Make(theFilename, false, false)
  • myTable Table.Make(theVTab)
  • myTable.SetName(XY_Table)
  • myTable.GetWin.Open 'Open the new table document

skipFirst line
forWrite
4
VTab.Make(aFileName,ForWrite,SkipFirst)
  • Makes the VTab from aFileName. aFileName may be
    either an INFO file, a dBASE file, or a text
    file.
  • If forWrite is TRUE, the VTab will start out
    editable. If aFileName is a text file, forWrite
    must be FALSE.
  • If skipFirst is TRUE, the VTab will not include
    the first record of the disk file this feature
    is useful for polygon attribute tables because it
    drops the universe polygon.
  • Use VTab.MakeNew if you want to create a new file.

5
Create Point theme
  • theViewav.FindDoc(Putnam County") finding
    Putnam County for theView, you can use
    GetActiveDoc
  • theVTabav.GetProject.FindDoc(XY_Table").GetVTab
  • xFieldtheVTab.FindField(X")
  • yFieldtheVTab.FindField(Y")
  • xySourceXYName.Make(theVTab,xField,yField)
  • theThemeTheme.Make(xySource)
  • ptTheme theView.AddTheme(theTheme)
  • theTheme.SetVisible(true)

6
Creating, Opening and Closing a File
  • The Make request to the TextFile or LineFile
    classes creates new files or opens existing
    files. Lets create a text file
  • Create a text file to write to and read from
  • if the file exists, overwrite it.
  • myTextFile TextFile.Make(myTextFilename,,
    FILE_PERM_WRITE)
  • Open a line file for reading.
  • myLineFile LineFile.make(myLineFilename,
    FILE_PERM_READ)

7
Create a new Table file
  • If you need a completely new table to store data
    you dont already have on disk, youll need to
    create a file on disk, a new VTab object, and
    then the Table object.
  • Create a new Table file
  • myFile FileDialog.Put(xyz.dbf.AsFilename,.,
    File)
  • theVTab VTab.MakeNew(myFile,dbase)
  • myTable Table.Make(theVTab)
  • myTable.SetName(xyz)
  • VTab.MakeNew (aFileName, aClass) - Make a new
    table and give a filename and file type dbase,
    info, or dtext

8
FileDialog.Put(defaultFileName,aPattern,
FileWinTitle)
  • Creates a file window for making new files. The
    FileName defaultFileName serves as the default
    value. The path of the defaultFileName is the
    beginning directory for the Put. aPattern defines
    the pattern for similar files. Use an asterisk as
    a wild card character (".ave"). FileWinTitle is
    the file window title. If no title is specified,
    it defaults to Save. If the user names or selects
    a file then clicks OK, Put returns a FileName for
    that file. If the user names an existing file,
    Put queries to replace the existing file. If the
    user clicks Cancel, Put returns nil.

FileDialog.Show(.shp, Shape Files , )
9
Create fields/Add Values
  • We have a table w/o fields. To create fields in
    the dBASE file, we must create fields in the
    VTab. Field is a class associated with VTab. The
    following script creates two new field objects,
    then adds them to the VTab, and thus to the file
    on disk.
  • 'Create two fields.. one integer, one character
  • myTable av.FindDoc("xyz")
  • theVTab myTable.GetVTab
  • f1 Field.Make("ID",FIELD_SHORT,5,0)
  • f2Field.Make("Name",FIELD_CHAR,13,0)
  • 'Add Fields
  • theVTab.AddFields(f1,f2)
  • 'Add 100 records and set initial values to match
    ID value
  • for each i in 1 .. 100
  • rec theVTab.AddRecord
  • theVTab.SetValue(f1,rec,i)
  • theVTab.SetValue(f2,rec,"Cookeville"
    i.AsString)
  • end

10
Field.Make
  • Field.Make (aName, aFieldType, aWidth,
    aPrecision)
  • For numeric fields, aWidth includes a count for
    the decimal point the field containing 123.4567
    is 8 wide with precision 4. For non-numeric
    fields, aPrecision must be 0.
  • aVTab.SetValue (aField, aRecordNumber, anObj)
  • Sets the current value of aField (if editable) of
    record aRecordNumber to anObj.

11
Sorting and Promoting
  • myTable.PromoeSelection move selected records to
    top
  • myTable.Sort(aField, ascending) sort table on
    field

12
Exercise
  • Creating a table with file name Radius_Area.dbf
  • Add three fields in the table named
  • f1 Field.Make("ID",FIELD_SHORT,5,0)
    f2Field.Make(Radius,FIELD_DECIMAL, 5,2),
    f3Field.Make(AreaFIELD_DECIMAL,14,2)
  • have 10 records in each field and calculate the
    areas of the circle with radius from 1 to 10)
    radius ID 2, Area 3.14RadiusRadius
  • Bring it into the current project, and
  • SetName(Radius_Area)

13
Exercise create table with ID, Two random
numbers and populated with 5 points
  • Use the following script
  • theMaxX -85.26
  • theMinX -85.68
  • theMaxY 36.22
  • theMinY 36.08
  • nBig 100
  • XRandom Number.MakeRandom(0, nBig)/nBig
    (theMaxX - theMinX) theMinX
  • YRandom Number.MakeRandom(0, nBig)/nBig
    (theMaxY - theMinY) theMinY
  • MsgBox.Info("The XRandom is " XRandom.AsString,
    "X Random")
  • MsgBox.Info("The YRandom is " YRandom.AsString,
    "Y Random")
  • 'msgBox.ListAsString(theMinX.AsString,
    TheMaxX.AsString, theMinY.AsString,
    theMaxY.AsString, XRandom.AsString,
    YRandom.AsString, "", "")
  • theRandomPoint Point.Make(XRandom, YRandom)

14
Flashing shapes
  • theView av.FindDoc("Putnam County")
  • theDisplay theView.GetDisplay
  • theXYTheme theView.FindTheme("XY")
  • theFTab theXYTheme.GetFTab
  • theShapeField theFTab.FindField("Shape")
  • Milliseconds 500
  • Times 1
  • for each i in 0..4
  • theShape theFTab.returnValue(theShapeField,
    i)
  • '
  • aGraphic GraphicShape.Make(theShape)
  • theSymbol aGraphic.GetSymbol
  • theDisplay.FlashShape(theShape, theSymbol,
    Milliseconds, Times)
  • end

15
Run script from another script
  • ChineseZodiac MsgBox.Input(What is your
    Chinese Zodiac symbol?,Symbol,)
  • av.Run(AnotherScriptName,valuesToPass)

16
Homework 3
  • Due on midnight of 9/18/03
Write a Comment
User Comments (0)
About PowerShow.com