#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Need code to place spreadsheet fields into GIS attribute table as fields


    Thanks for reading this.

    I am trying to get my spreadsheet (3 of them) into a GIS attribute table (arcgis 10.0). I have developed an update cursor code, but I just dont know what I am doing. I was able to make the code work to place a Unique ID into an attribute table, but I cant figure out how to modify the code to make it work for me and my tables.

    When I am done with that, I want to change all of my geographic coordinate systems into the same one, and I have placed all of my files into a geodatabase. I just cant remember how to do it, and I thought it would be cool if I could do it using Python.

    Finally, I would like a suggestion for a good tutorial to learn Python. I have been using Codeacademy, and it is great. I want more. I will now try to figure out how to place my code into this gui.
    Thanks ahead of time,
    Kim

    #Purpose: To add my table to a table in ArcGIS
    #Syntax: AddField_management (in_table, field_name, field_type, {field_precision},
    #{field_scale}, {field_length}, {field_alias}, {field_is_nullable}, {field_is_required}, {field_domain})

    import arcpy arcpy.env.workspace = "C:\Users\Kim\Documents\Lava_Beds_GIS\KLavaBedsK\LavaBeds.mdb\\" arcpy.AddField_management("2011_LABE_Boundary.shp", "place_name", "LONG") cur = arcpy.UpdateCursor("2011_LABE_Boundary.shp") #create Update cursor for LABE_Boundary, which is where I want the new attributes to go to for row in cur: row.place_name = row.id + row.place_name cur.updateRow(row) del cur, row Code:
    import arcpy
    arcpy.env.workspace = "C:\Users\Kim\Documents\Lava_Beds_GIS\KLavaBedsK\LavaBeds.mdb\\"
    arcpy.AddField_management("2011_LABE_Boundary.shp", "place_name", "LONG")
    cur = arcpy.UpdateCursor("2011_LABE_Boundary.shp") #create Update cursor for LABE_Boundary, which is where I want the new attributes to go to
    for row in cur:
        row.place_name = row.id + row.place_name
        cur.updateRow(row)
    del cur, row
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    153
    Rep Power
    5
    I'm afraid I don't know arcpy (when I help our GIS guy here he usually just asks me to convert things to dbf), and I'm not really clear on what your specific question is.

    But I did want to tell you that there are a lot of great lectures for people of any Python skill level available for free at pyvideo.org, which come from various python conventions. The SciPy conventions often have a lot of GIS-related talks that might be of interest to you.

IMN logo majestic logo threadwatch logo seochat tools logo