3

Im storing s-57 data in an MDB which is being symolised via a layer. Some attributes in s-57 data can be a list of enumerations and I want to find a way to show the actual values the enumeration represents, please see example below.

My feature has a column called colour, this can be represented as a single number (i.e. 1 = white) or it can be represented by a list (ie. 2,3,2 = black, red, black).

I have included the enumeration table in the MDB which has values similar to those shown below.

VALUE COLOUR

1 white

2 black

3 red

where a single colour is listed in the field a simple join to the enumeration table works fine and I can set it up so the users see the full attribute values instead of the enumeration but when a list of enumerations I still need to convert it to full attribute values, is this possible?

so in summary if I have a colour field that contains '2,3,2' using the enumeration table above I would like to be able to get the layer to display black, red, black instead of 2,3,2 in the attribute table, is this possible?

3

In Field Calculator, you can try this Python code:

",".join({"1":"White","2":"Black","3":"Red"}[val.strip()] for val in !INPUT_FIELD_NAME!.split(","))

All you need to do is to pick your enumeration field for !INPUT_FIELD_NAME! and make sure you are using Python Parser!

UPDATE


OK, the below is another solution by creating a look-up table (dbf table in this case) to join your original data in ArcMap. I have not tested it but should work in built-in Python Interpreter.

Create a dbf file in a temporary location and add two fields for look-up.

look_up_table=arcpy.CreateTable_management(r"C:\Temp","s_57_LookUp.dbf")[0]
look_up_fields=["Color_Coded","Color_Expanded"]
for field in look_up_fields:
    arcpy.AddField_management(look_up_table,field,"TEXT",field_length=255)

Collect unique colour entries and add them into look-up table.

source_s_57_file=r'C:\Temp\Scratch.mdb\My_s57_file' #YOUR TABLE
look_up_values=[]
ins_cursor=arcpy.InsertCursor(look_up_table)
with arcpy.da.SearchCursor(source_s_57_file,"Color") as cursor: #THE FIELD WHERE COLOR INFO IS GIVEN CODED
    for row in cursor:
        if row[0] not in look_up_values:
            look_up_values.append(row[0])
            ins_row=ins_cursor.newRow()
            [ins_row.setValue(field,val) for field,val in zip(look_up_fields,[row[0],",".join({"1":"White","2":"Black","3":"Red"}[val.strip()] for val in row[0].split(","))])]
            ins_row.insertRow(ins_row)

del ins_cursor

I hope you would not come across any 64-bit geoprocessing issue as explained here.

5
  • The problem with the field calculator is that it edits the data, I dont want to edit the data at all I want it to remain in the s-57 coded values, I just want to display it in the attribute table in a better way via the layer or some kind of database join
    – Javrel
    Jul 8 '15 at 15:38
  • This isnt exactly the solution I will use but it has inspired me to think of a solution to my problem so thank you very much, the idea of creating extra entries in the lookup table for the listed attributes is great and I can accomplish this in FME as I convert the data to MDB, instead of using the standard s-57 enumeration tables I can create a lookup table for each MDB as they are created that only contain the required lookups! I did upvote but I dont have enough rep yet for it to be public
    – Javrel
    Jul 9 '15 at 9:34
  • No problem at all. Do you mind sharing your solution here once you get one? It is important for others with similar issue to get help here and I would love to see an FME alternative to this question (FME unfortunately is not a so popular tag).
    – fatih_dur
    Jul 9 '15 at 11:15
  • 1
    not sure how to post my solution as FME is quite graphical, I basically made a custom transformer that I fed all the attributes I want to create lookup tables for, split them into lists around the comma then create lookup tables by replacing the numeric values. This generates the lookup tables specific to that ENC as I convert to MDB and all the joins to show the full values in these tables are handled in the layer that symbolizes the MDB
    – Javrel
    Jul 14 '15 at 8:57
  • No worries, I was assuming this transformer could fit in a snapshot but I think you have given enough explanation.
    – fatih_dur
    Jul 14 '15 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.