1

In arcpy, I'm trying to join an list of .csv files with data of emissions per country, with the attribute table of a raster in order to make lookup tables later on. So far this is my script:

ras_countries = "E:\\eco_services\\data\\EU_28"

arcpy.env.workspace = "G:\\AIR_QUALITY\\paper\\GAINS_emission\\emission_gains"
landuse_tables = arcpy.ListTables ("emiss*")
for landuse in landuse_tables:
    tableViewName = landuse [6:-4]
    arcpy.MakeTableView_management(landuse, tableViewName)
    arcpy.AddJoin_management(ras_countries, "cou_abb", tableViewName, "cou_abb")

But I always get the same error message:

ERROR 000840: The value is not a Table View. ERROR 000825: The value is not a layer or table view ERROR 000840: The value is not a Raster Catalog Layer. ERROR 000840: The value is not a Mosaic Layer. WARNING 000970: The join field COU_ABB in the join table EU_28 is not indexed. To improve performance, we recommend that an index be created for the join field in the join table.

I also tried converting the .csv files to .dbf but still no success.

any suggestions?

Failed to execute (AddJoin).

1

You should convert your raster to a raster layer prior to joining fields to its attribute table. Use the Make Raster Layer tool:

favorite

ras_countries = "E:\\eco_services\\data\\EU_28"
arcpy.MakeRasterLayer_management(ras_countries, "ras_layer")

arcpy.env.workspace = "G:\\AIR_QUALITY\\paper\\GAINS_emission\\emission_gains"
landuse_tables = arcpy.ListTables ("emiss*")
for landuse in landuse_tables:
    tableViewName = landuse [6:-4]
    arcpy.MakeTableView_management(landuse, tableViewName)
    arcpy.AddJoin_management("ras_layer", "cou_abb", tableViewName, "cou_abb")
  • Thanks for your reply, I was considering only the tables and not the raster...However, I still didn't manage to make the join I always get the same error:"ERROR 000728: Field COU_ABB does not exist within table Failed to execute (AddJoin)." Is it because when converting to raster layer the raster attribute table disappears? – vizpi Oct 19 '15 at 9:04
  • No, the attribute table is still there in the layer, your code works with my data. Are you sure the field is also there in the table view you try to join? – GISGe Oct 21 '15 at 11:45
  • Dear GISGe, I finally got the solution: the problem was that the field name of the raster layer was "COU_ABB" and not "cou_abb" so the addJoin_management didn't work because was looking for exactly the same name. I solved the problem using arcpy.JoinField_management that accepts different field names. – vizpi Oct 22 '15 at 13:56
  • Dear GISGe, I finally got the solution: the problem was that the field name of the raster layer was "COU_ABB" and not "cou_abb" so the addJoin_management didn't work because was looking for exactly the same name. I solved the problem using arcpy.JoinField_management that accepts different field names. The issue is that fields in raster layer are always in capital letters... – vizpi Oct 22 '15 at 14:12
  • Great! If you use Join Field you don't even need to convert your data to layer or view first. I was not sure you have access to it since it requires an Advanced license. – GISGe Oct 22 '15 at 16:03

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.