Merging rasters and keep raster table fields

12036
5
Jump to solution
06-19-2013 01:25 PM
DianeMcConnaughey
Occasional Contributor
Having the ability to use attributes in Raster Calculator would be really nice,  why was it taken away?  I don't care if it is the old "dot" syntax or some other syntax. Please bring it back, soon.   I need to merge/mosic 11 GRIDs which presumably do not overlap, but might a little around the edges as as artifact of how they were created.   Mosaic does not let me use an item either.  Two text items have to be used for the desisred attributes in the GRIDs.  So  I've concatenated the two fields into a new field, then added added a new field for an integer crosswalk of the concatenated fields. I plan to mosaic the GRIDs after adding & calculating the two new fields in all of them, thne using the "lookup" function to create new grids with value = newfield, hten mosaic.  What a lot of work.   Is there an easier way ? ( speaking of merge, the merge function was really nice too, why was it disappeared?)
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor
Is this also the solution for a simple combine with rasters with descriptive attributes?  ...  Combining the rasters takes about 2 minutes.


The Spatial Analyst tools are designed to work with the main cell values (Value attribute). This allows for the most efficient storage and analysis of raster data, for example complex map algebra expressions can do very sophisticated things (using three or more tools nested using the Raster Calcualtor tool) very easily. (This is why the combine takes only two minutes!) Because of this design approach, if you have descriptive attributes, the best way to work with them is as standalone tables.

For example, export the raster table from your Combine output raster to a standalone table, join to each of your input tables to make a big wide joined table, and then use the Merge tool to create a table that has all the attributes you want to access together. (you could join this to your raster if you want, but why not keep it by itself?)

An easier [but less efficient] workflow to just tack on a few attributes back on to the VAT is to use the Join Field tool (as I described above), but in general I like to keep the tabular data separate from my raster so I don't have to worry about having to another join after the next step.

There used to be a neat tool called MERGEVAT in ArcInfo Workstation GRID ... but honestly the general approach of handling the tabular data separately is less painful.

View solution in original post

0 Kudos
5 Replies
curtvprice
MVP Esteemed Contributor
Having the ability to use attributes in Raster Calculator would be really nice,  why was it taken away?


The Lookup function is the new way to do it. The redesign of the Raster Calculator tool at 10.x was a retooling that allowed a single syntax (arcpy map algebra) to work across ArcGIS. At 9.x, we had SOMA, MOMA, Raster Calculator, the command line, and tool interface. Each of these had a different syntax (for example, SOMA did not support "dot" syntax), and Raster Calculator even had its own unique geoprocessing environment(!). So going forward I think it is an improvement, although there is a learning curve.

the merge function was really nice too, why was it disappeared?)


The Merge and Mosaic tools were combined. In some situations, I have found Cell Statistics useful to merge datasets together.

I need to [mosaic] 11 GRIDs which presumably do not overlap, but might a little around the edges as as artifact of how they were created.   Mosaic does not let me use an item either.  Two text items have to be used for the desisred attributes in the GRIDs.  So  I've concatenated the two fields into a new field, then added added a new field for an integer crosswalk of the concatenated fields. I plan to mosaic the GRIDs after adding & calculating the two new fields in all of them, thne using the "lookup" function to create new grids with value = newfield, hten mosaic.  What a lot of work.   Is there an easier way ?

If your raster codes are not unique (ie value 2 means different things for two of your 11 rasters) you do have a sticky processing problem.

The best way I can think is to convert your 11 rasters so all cells are unique across the  11 rasters and mosaic them, then join your attributes back in.

Step 1. Set up your value in each VAT

NEWVAL = [VALUE] + 1000

Step 2. Copy all your raster attribute tables to standalone tables (you could use Copy Rows in a iterator model), and join them all together with the Merge tool.

Step 3. Convert your rasters to these values and mosaic them:

ras1 = "grid1" + 1000
ras2 = "grid2" + 2000

Mosaic To New Raster to merge ras1-ras11

Step 4. Join Field your new mosaicked raster's RAT to the table created in step 2.


An entirely different approach that may work is this. May be easiest in the Python window:

1. Set the extent to cover all 11 rasters

2. For all 11 rasters, over the entire extent, convert nodata to a missing value (say, zero):

x1 = Con(IsNull("grid1"),0,"grid1")
x2 = Con(IsNull("grid2"),0,"grid1")
...

3. Combine these together. You'll get a pretty wide RAT with 11 fields that match VALUE in your 11 raster tables included.

Combine(x1,x2... x11)

4. Add your text fields to this combined raster.

5. One by one, select for each of your fields ("RAS11" <> 0), add join and calc over your text fields, remove join.

Hope this helps!

DianeMcConnaughey
Occasional Contributor
Is this also the solution for a simple combine with rasters with descriptive attributes?  I need to combine/overlay 8 or 9 rasters.  The combine works fine, but I lose the descriptive attributes, and have to get them back into the combined grid with a Join operation.  A little tedious, but it works, usually.  I just had a join fail.  It added all the fields a join would add, but the records were all NULL for the joined items.  So I did a virtual join, and calculated the null values to the the values in the joined table.  I would do this in vector, but it keeps blowing up (maybe it is the network here, but this also happens on a local drive).   Only one of the datasets started out as raster, which was vectorized, but doing these as polygons fails, immediately or after several hours.   So the vector data all had to be rasterized. Combing the rasters takes about 2 minutes.
0 Kudos
curtvprice
MVP Esteemed Contributor
Is this also the solution for a simple combine with rasters with descriptive attributes?  ...  Combining the rasters takes about 2 minutes.


The Spatial Analyst tools are designed to work with the main cell values (Value attribute). This allows for the most efficient storage and analysis of raster data, for example complex map algebra expressions can do very sophisticated things (using three or more tools nested using the Raster Calcualtor tool) very easily. (This is why the combine takes only two minutes!) Because of this design approach, if you have descriptive attributes, the best way to work with them is as standalone tables.

For example, export the raster table from your Combine output raster to a standalone table, join to each of your input tables to make a big wide joined table, and then use the Merge tool to create a table that has all the attributes you want to access together. (you could join this to your raster if you want, but why not keep it by itself?)

An easier [but less efficient] workflow to just tack on a few attributes back on to the VAT is to use the Join Field tool (as I described above), but in general I like to keep the tabular data separate from my raster so I don't have to worry about having to another join after the next step.

There used to be a neat tool called MERGEVAT in ArcInfo Workstation GRID ... but honestly the general approach of handling the tabular data separately is less painful.
0 Kudos
DianeMcConnaughey
Occasional Contributor
Thank you for the explanation and the suggestion for stand alone tables.  The stand alone tables are working, just another step or two in the process.  I also found the suggestions for stand alone tables on another post.  So it sounds as if I'd be better off by making all of the VAts with descriptive attributes stand alone, then join them as needed when combining the GIRDs.  Actually only one of the inputs is raster to begin with, everything else is Vector.  Its just that when we converted the raster to vector, then tried to overlay it with other vector data, the process blew up after a few hours
0 Kudos
curtvprice
MVP Esteemed Contributor

Hey Diane, check out this document I just posted this weekend:

Implementing merge() in ArcPy map algebra