Using OR operator in NumPy Array to Append multiple items

100 views Asked by At

I am using a NumPy array to feature class in Esri ArcGIS. I have a tuple of items that I am appending to a NumPy array. One field/column should be able to use multiple values depnding on the proxy input, i.e. if the category is a bulky item then the field sccatdesc should be sbi, if the category is e-waste, the sccatdesc should be mbe. This example shows the basic logic working with the NumPy array. How can I succesfully use multiple values for one field.

dt = np.dtype([('Address', 'U40'),
        ('Y_CoordShape', '<f8'),
        ('X_CoordShape', '<f8'),
        ('Y_Coord', '<f8'),
        ('X_Coord', '<f8'),
        ('ReasonCode','U128'),
        ('NUMBERCYLA', 'U40'),
        ('SRNumber', 'U40'),
        ('FullName', 'U40'),
        ('RESOLUTION_CODE','U128'),
       ('HOME_PHONE', 'U40'),
        ('CreatedDate', 'U128'),
        ('UpdatedDate', 'U128'),
        ('ItemDesc', 'U128'),
        ('Category', 'U128',),
         ('SCHEDULE_DATE', 'U128'),
        ('CYLA_District', 'U128'),
        ('SCCatDesc ', 'U128'),
        # ('Collect_Day', 'U128'),
        # ('Description', 'U128'),
       ('Prior_RESOLUTION_CODE', 'U128',),
        ('CYLA_DISTRICT', 'U128',),


        ])




    items.append((Address,
             x,
            y,
              x,
              y,
              ReasonCode,
              SRNumber,
             SRNumber,

             FullName,
              ResolutionCode,
              HomePhone,
              CreatedDate,
              UpdatedDate,
              BulkyItemInfo,
             k_bulky_comm or k_manual_pickup_comm,
              ServiceDate,
             CYLA_DISTRICT,
             SCCatDesc,
            # ServiceNotes,

             Prior_Resolution_Code,
             CYLA_DISTRICT,




            ))


    sr = arcpy.SpatialReference(4326)
arr = np.array(items,dtype=dt)


NumPyArray = arcpy.da.NumPyArrayToFeatureClass(arr, fc, ['Y_CoordShape', 'X_CoordShape'], sr)
1

There are 1 answers

0
Dan On BEST ANSWER

Instead of doing the "OR" inside the append, you'll need to do an if statement:

if category == 'bulky item':
        items.append((Address,
             x,
            y,
              x,
              y,
              ReasonCode,
              SRNumber,
             SRNumber,
             FullName,
              ResolutionCode,
              HomePhone,
              CreatedDate,
              UpdatedDate,
              BulkyItemInfo,
             k_bulky_comm,
              ServiceDate,
             CYLA_DISTRICT,
             SCCatDesc,
            # ServiceNotes,
             Prior_Resolution_Code,
             CYLA_DISTRICT,
            ))
elif category == 'e-waste':
        items.append((Address,
             x,
            y,
              x,
              y,
              ReasonCode,
              SRNumber,
             SRNumber,
             FullName,
              ResolutionCode,
              HomePhone,
              CreatedDate,
              UpdatedDate,
              BulkyItemInfo,
             k_manual_pickup_comm,
              ServiceDate,
             CYLA_DISTRICT,
             SCCatDesc,
            # ServiceNotes,
             Prior_Resolution_Code,
             CYLA_DISTRICT,
            ))