Tonyalmeida

Multiple spatial Joins with field mapping

Discussion created by Tonyalmeida on Apr 13, 2012
I am trying to do a Multiple spatial Joins with field mapping but it seem that my second spatial join attributes are null. I don't get an error.
Anyone know what i am doing wrong?

Thanks.


# Import arcpy module
import sys,arcpy


# Local variables:
ParcelTool = "C:\\GIS\\PARCEL TOOL\\temp\\ParcelTool.shp"
FEMA09 = "Database Connections\\**\".FEMA09"
FEMA = "C:\\GIS\\PARCEL TOOL\\temp\\FEMA.shp"
IRRG = "Database Connections\\**\".IRRIGATON_DIST_NEW"
IRRG2 = "C:\\GIS\\PARCEL TOOL\\temp\\IRRG.shp"

def Layers(ParcelTool,FEMA09,IRRG):
    FieldMapString = "" \
                + """ACCOUNT "ACCOUNT" true true false 11 Text 0 0 ,First,#,""" + ParcelTool + """,ACCOUNT,-1,-1;"""\
                + """ACRES "ACRES" true true false 11 Double 3 10 ,First,#,""" + ParcelTool + """,ACRES,-1,-1;"""\
                + """Instrument "Insterment" true true false 10 Text 0 0 ,First,#,""" + ParcelTool + """,Instrument,-1,-1;"""\
                + """SiteAddres "SiteAddres" true true false 106 Text 0 0 ,First,#,""" + ParcelTool + """,SiteAddres,-1,-1;"""\
                + """SiteCity "SiteCity" true true false 32 Text 0 0 ,First,#,""" + ParcelTool + """,SiteCity,-1,-1;"""\
                + """SiteZip "SiteZip" true true false 10 Text 0 0 ,First,#,""" + ParcelTool + """,SiteZip,-1,-1;"""\
                + """SubName "SubName" true true false 20 Text 0 0 ,First,#,""" + ParcelTool + """,SubName,-1,-1;"""\
                + """OwnerName "OwnerName" true true false 100 Text 0 0 ,First,#,""" + ParcelTool + """,OwnerName,-1,-1;"""\
                + """OwnerSec "OwnerSec" true true false 64 Text 0 0 ,First,#,""" + ParcelTool + """,OwnerSec,-1,-1;"""\
                + """Address "Address" true true false 64 Text 0 0 ,First,#,""" + ParcelTool + """,Address,-1,-1;"""\
                + """City "City" true true false 32 Text 0 0 ,First,#,""" + ParcelTool + """,City,-1,-1;"""\
                + """State "State" true true false 4 Text 0 0 ,First,#,""" + ParcelTool + """,State,-1,-1;"""\
                + """ZipCode "ZipCode" true true false 10 Text 0 0 ,First,#,""" + ParcelTool + """,ZipCode,-1,-1;"""\
                + """Legal "Legal" true true false 254 Text 0 0 ,First,#,""" + ParcelTool + """,Legal,-1,-1;"""\
                + """Sec "Sec" true true false 2 Text 0 0 ,First,#,""" + ParcelTool + """,Sec,-1,-1;"""\
                + """Twp "Twp" true true false 2 Text 0 0 ,First,#,""" + ParcelTool + """,Twp,-1,-1;"""\
                + """Rng "Rng" true true false 2 Text 0 0 ,First,#,""" + ParcelTool + """,Rng,-1,-1;"""\
                + """Quarter "Quarter" true true false 2 Text 0 0 ,First,#,""" + ParcelTool + """,Quarter,-1,-1;"""\
                + """FLD_ZONE "FLD_ZONE" true true false 55 Text 0 0 ,First,#,"""+ FEMA09 + """,FLD_ZONE,-1,-1;"""\
                + """NAME "NAME" true true false 60 Text 0 0 ,First,#,"""+ IRRG + """,NAME,-1,-1;"""\
  #              + """ZONE_DESC "ZONE_DESC" true true false 50 Text 0 0 ,First,#,"""+ ZONING + """,ZONE_DESC,-1,-1;"""\


    fieldmappings = arcpy.FieldMappings()
    fieldmappings.loadFromString(FieldMapString)
    return fieldmappings

def main(args=None):
        if args is None:
                args = sys.argv

arcpy.SpatialJoin_analysis(ParcelTool, FEMA09, FEMA,
                           "JOIN_ONE_TO_ONE", "KEEP_ALL", Layers(ParcelTool,FEMA09,IRRG))

arcpy.SpatialJoin_analysis(FEMA, IRRG, IRRG2,
                           "JOIN_ONE_TO_ONE", "KEEP_ALL", Layers(ParcelTool,FEMA09,IRRG))

Outcomes