Select to view content in your preferred language

preserving original raster values when combining

4727
8
07-21-2011 07:13 AM
ClaireBrittain
New Contributor
Hi, I see that when combining raster layers the output layer produces new values for the cells but is there any way of 'carrying over' the values from the original layers?
I have two raster layers that I would like to combine and be able to see the original values of both. Basically I would like an equivalent of the 'union' tool for rasters - does this exist?
Thanks
Claire
0 Kudos
8 Replies
ChrisSnyder
Regular Contributor III
You hit it on the head: The Combine tool: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z0000007r000000.htm

Note that this tool will "integerize" any inputs that are floating point, so if you need to preserve precision in the floating point data, do someting like int(MyFloatGrid * 1000) first and then in the output combine tool just divide the field by 1000 to get your original float value back.

Also, note that the tool performs MUCH faster if all the input rasters and the output raster are all in GRID format (as opposed to all inputs and outputs datasets being FGDB fomat).
0 Kudos
ClaireBrittain
New Contributor
Hi Chris,
Thanks for your response. The output of combine does preserve the initial values of the rasters combined which is great but only produces output for where the 2 rasters overlap. I would like the output to include the whole of both rasters or at least the extent of the larger raster. Is there a way you know to do this?
Thanks
Claire
0 Kudos
ChrisSnyder
Regular Contributor III
Right.... Combine works like intersect - and you want a union.

The way I do this is to expand the extent of the original input rasters - that is make new rasters - where the null area outside the original extent gets reclassed to some recognizable value like -9999. That way you are still doing what basically amounts to an intersect, but have simply normalized the extents of the input rasters. I generally use the Analysis Extent & SnapRaster Environment settings in conjunction with the Con() tool to do that. Once the extents are all the same, then you shouldn't have any problems.
0 Kudos
ChrisSnyder
Regular Contributor III
It's for a different purpose, but this Python code: http://forums.arcgis.com/threads/8579-Adding-Together-Rasters?p=26307&viewfull=1#post26307

Has a part of it that does the extent normalization/con() routine that I am describing above. Take a look at the section of code that has the comment "#Process: Now build some new grids that have the max extent"
0 Kudos
ClaireBrittain
New Contributor
Hi Chris
I understand your reasoning but am having a little trouble with implementing it. One of my rasters is smaller so essentially i want to create a new raster expanding the original small raster to the extent of the larger raster (after which I can use combine). I am trying to use the raster calculator using the con function to specify where the smaller raster has a value 1 is True and should be coded 9999 and where it is false it should be coded -9999. Within the calculator I set the raster geoprocessing environments - snap and analysis extent to the larger raster but when the calculator has run this the output is still the extent of the smaller raster file (with the new True/False codings).
Claire
0 Kudos
ChrisSnyder
Regular Contributor III
In v9.3 or v10? BTW: The new v10 Map Algebra and I don't get along...

If was doing this process in v93 Python it would look something like this (code not verified):

#assumes that the extent of littleRaster fits entirely within extent bigRaster 
bigRaster = r"C:\big"
littleRaster = r"C:\little"
gp.extent = bigRaster
#Note: no need to set the snap raster if we are just using the extent of bigRaster
somaExp = "con(isnull(" + littleRaster + "), -9999, " + littleRaster + ")" #recode NoData to -9999, otherwise keep the original values
littleRasterNew = r"C:\little_new"
gp.SingleOutputMapAlgebra_sa(somaExp, littleRasterNew)
comboRaster = r"C:\combo"
somaExp = "combine(" + bigRaster + "," + littleRasterNew + ")"
gp.SingleOutputMapAlgebra_sa(somaExp, comboRaster)
0 Kudos
JeffreySwain
Esri Regular Contributor
The two fundamental concepts are that you will need the spatial extent to expand so you will need to change the environment setting for the Output Extent to match the larger raster or the 'Union of Inputs' from the Environment Settings.  Also you will have to alter the Null/NoData values to a value so that when you combine them, then you can see. Please see the forum post here for more specific description.

Once you have modified the data and the extent of the output you should be able to achieve the desired results.
0 Kudos
ClaireBrittain
New Contributor
Great, thanks to you both. I got there eventually. I kept thinking that when I copied the smaller raster and changed the extent to the larger raster's that it wasn't working but I just couldn't see that it had worked until I then used the calculator to set the null values to zero.
After I had done that I could see the small raster had increased in extent just as it was supposed to and I was able to use the combine tool exactly how I wanted.
Thanks again
Claire
0 Kudos