2

I have four rasters, each of 32 bits (single band), with the same cell size, the same number of rows and columns and identical extension. I need to make something like a "Spatial join", I mean, I need one of these four raster contains in its attribute table cell values of the other three raster.

enter image description here

I am programming this with Python and I've tried several tools, including "Combine" that generates me a raster with the combination of the four raster and its attribute table contains columns with the values of each raster, however, I want the cell value is not altered and hold the raster MLWS, only adding to its attribute table three columns with the values of the other three raster (HAT , LAT , MHWS ). For this I need to generate some kind of spatial Join, looking for the corresponding cell in the other raster and bring value to my raster attribute table. This is an image for the obtained with the "Combine" tool:

enter image description here

It works perfectly, I just need the final raster represents only MLWS values and not the combination of the four rasters, containing in the attribute table columns with the values of the other three raster.

1

You can try the following:

  1. First add a column with that has "double" format to your combined raster and name it "UID", you can use the following code in field calculator to generate unique id's for the new "UID" field you added.

    # Code to put in the code block
    rec=0 
    def autoIncrement(): 
     global rec 
     pStart = 1  
     pInterval = 1 
     if (rec == 0):  
      rec = pStart  
     else:  
      rec += pInterval  
     return rec
    
    # the following in the space underneath
    autoIncrement()
    
  2. Then add another column named MLWS_UID...Make this "Double" too. And concatenate the MLWS and UID values using Field calculator. MLWS_UID = [MLWS][UID]. By this stage your combined raster should have two additional columns.
  3. Run the Look up function and use the MLWS_UID column to do your look up analysis... let's say you named this file LU_MLWSUID.
  4. Now Join your combined raster and your new LU_MLWSUID raster using the 'VALUE' field of your LU_MLWSUID raster and the 'MLWS_UID' column of your combined dataset. Because the added UID on the MLWS values makes each cell unique you will have the values disaggregated in the same groups as your combined raster.
  5. Now your homework should be coming up with a colour map that will visualize MLWSUID values by only the MLWS part of the value and ignoring the UID part of the value.

Note: You cannot create an MLWS value raster that in its value attribute table disaggregates in higher category/class than what is already in your Value column.

Note2: Did you try using a field calculator on VALUE and simply replacing the values with [MLWS] values? I assume ArcGIS will crash with this.. but who knows.

  • Thanks for your answer. Previously I tried this option, however, the Join with the table "Combine_rasters" assigns incorrectly values to each cell, being that the raster attribute table MLWS not contains one row per cell, instead there are groups per cell value as shows the "Count" field. So, applying the join does not take into account the spatial position of each cell and assigns the values incorrectly. – Cony Jun 20 '16 at 22:06
  • I see I edited the answer... to address that. – yanes Jun 20 '16 at 22:09
  • Applying join not assign values appropriately, as the Identify tool on a cell, Raster_join values are not the same for each raster LAT , HAT , MHWS . While applying "Combine " I can assign values correctly in the attribute table, but there is no way to keep me the pixel value (MLWS). – Cony Jun 20 '16 at 22:12
  • I was also thinking of some way to make the join with an X-coord and Y_coord field, but the tool "Calculate geometry" is not applicable to raster, which is expected as each row in the attribute table does not represent a single cell, but a group of cells with the same value. I tried also converting raster to points and performing spatial join, obtaining the table with columns and appropriate values, however, I didn´t find a way to turn back to raster with this new raster containing the attributes of the point layer. Neither of these options has given me the desired result. – Cony Jun 20 '16 at 22:14
  • Just a second I am editing the answer.. – yanes Jun 20 '16 at 22:17

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.