Home arrow GIS Organizations arrow AGRC arrow Current Projects arrow UDSH Preservation arrow Historic Preservation, Address Categorization Strategy
Historic Preservation, Address Categorization Strategy PDF Print E-mail

Written by Bert Granberg,

This page is to compile and update notes regarding classes of addresses within the SH-HP Database:

Observations:

 

 

Categories:

 

 

Other:

 

 

Sample Code for taking a table with Placename and Multiple Zipcodes and converting to a .csv text file:

 

Public Sub cityAndMultipleZipsToFileExample()

    'Open a new text file to write to
     Open "c:/cityzip_intermediate.csv" For Output As #1
   
     Dim pMxDoc As IMxDocument
     Dim pMap As IMap
     Dim pTC As ITableCollection
   
     Dim ptable As ITable
     Dim pRow As IRow
     Dim zipStr As String
     Dim z() As String
     Dim x As Long
     Dim pQFilter As IQueryFilter
    
     Set pMxDoc = ThisDocument
     Set pMap = pMxDoc.FocusMap
     Set pTC = pMap

    
     'Get reference to layer in table of contents (0 is topmost layer)
     Set ptable = pTC.Table(3)
   
     'if desired, Use a Query Filter to select a subset of tables using
     'a simple SQL where clause
     Set pQFilter = New QueryFilter
     pQFilter.WhereClause = ""
   
     'Establish a cursor used for looping
     Dim pCursor As ICursor
     Set pCursor = ptable.Search(pQFilter, True)
     Set pRow = pCursor.NextRow

   
     'Loop thru all tables and write attributes to output file
     Do Until pRow Is Nothing
        
        zipStr = pRow.Value(2)
        z = Split(zipStr)
       
        For x = 0 To UBound(z)
            Debug.Print pRow.Value(1) & "," & z(x)
        Next x
       
        Set pRow = pCursor.NextRow
   
     Loop
   
     Close #1

End Sub

 

Public Sub dumpIntermediateTableToList()
   
    'Set parameters
    Dim outFileLocation As String
  
    outFileLocation = "C:\placenamezip.txt"

    'Get reference to current ArcMap session
    Dim pMxDoc As IMxDocument
    Dim pMap As IMap
    Set pMxDoc = ThisDocument
    Set pMap = pMxDoc.FocusMap
  
    'Get reference to street layer
    Dim pTC As ITableCollection
    Dim pTable As ITable
    Dim pDS As IDataset
       
    Set pTC = pMap
    Set pTable = pTC.Table(7)
    Set pDS = pTable
    Debug.Print pDS.BrowseName
   
    Dim pTS As ITableSort
    Set pTS = New TableSort
   
    With pTS
        Set .Table = pTable
        .Fields = "Placename,RelType,ZipCode"
        .Sort Nothing
    End With
   
    Dim pcursor As ICursor
    Dim pRow As IRow
    Dim prevPN As String
    Dim currPN As String
    Dim zipStr As String
   
    Set pcursor = pTS.Rows
    Set pRow = pcursor.NextRow
   
    prevPN = ""
    Open outFileLocation For Output As #1
    Do Until pRow Is Nothing
        currPN = pRow.Value(pTable.FindField("Placename"))
        If currPN <> prevPN And prevPN <> "" Then
            Print #1, prevPN & ":" & zipStr
            zipStr = pRow.Value(pTable.FindField("Zipcode"))
        Else
            If prevPN <> "" Then
                zipStr = zipStr & "," & pRow.Value(pTable.FindField("Zipcode"))
            Else
                zipStr = pRow.Value(pTable.FindField("Zipcode"))
            End If
        End If
       
        prevPN = currPN
        Set pRow = pcursor.NextRow
    Loop
    Print #1, prevPN & ":" & zipStr
    Close #1
   
End Sub


Users' Comments  
 

No comment posted

Add your comment

01, Aug. 2009
Last Updated ( 16, Sep. 2009 )
 
< Prev

AGRC Contacts | UGIC Contacts

feed image feed image

Utah GIS Portal © 2009 AGRC

Optimized for