raster calculator

1011
6
11-18-2011 01:15 PM
by Anonymous User
Not applicable
Original User: luke.kaim

Hi everyone,

Okay, I made a interpolated surface of bathymetry and it looks really good, but my problem is that it also interpolates values on land. How do I set the cells on land to be some arbitrary number like 70,000. I made a mask of the raster that are all cells on land, but now how do I merge them using the raster calculator such that all land values have the same arbitrary value? What I am trying to do should not be that hard. I think I am just struggling with the syntax.

Thank you,
Luke Kaim

Thank you
Luke Kaim (SIE)
Lucas.Kaim@maine.edu
(914)263-7866
0 Kudos
6 Replies
AnthonyTimpson2
Occasional Contributor
You could set the Raster symbology to make anything over a certain value show up as a constant.

-or-

You could create a raster using your mask which has a large value over land and a 0 value over water, do a raster calculate to add those two together.

-or-

you could Resample the dem and assign anything over a certain value a constant.
0 Kudos
by Anonymous User
Not applicable
Original User: lpinner

Something like: Con(IsNull(landmask), bathymetry, 70000) in the raster calculator.
0 Kudos
by Anonymous User
Not applicable
Original User: luke.kaim

Thank you so much lpinner. I definitely owe you a beer. This is what I put in the Raster Calculator and it does the trick. Con(IsNull("%Ftoraster3%"),"%idw20meter2%", 70000)

Would you or anyone else be able to explain in words what this expression means though? Is there a good online tutorial that discusses what con and IsNull?
0 Kudos
Luke_Pinner
MVP Regular Contributor
Con means 'conditional', it's basically an if/else statement - see the Con reference.
IsNull means just that, it determines which cells in the input raster have no data and which do - see IsNull reference.
So the raster calculator statement I gave you above means:

If a landmask cell has no data (is not land) then assign the value of the bathymetry raster (from the cell at the same coordinates) to the output raster, otherwise assign 70000 to that cell.
0 Kudos
by Anonymous User
Not applicable
Original User: luke.kaim

Does Raster calculator not work within Python and IDL?

This is what I have, but it gives errors every time I try to run the code.

Ftoraster3 = "Ftoraster3"
FinRast_r = "finRast"



# Process: Feature to Raster
arcpy.FeatureToRaster_conversion(PolygonFeature, "FID", Ftoraster3, "20")


# Process: Raster Calculator
#arcpy.gp.RasterCalculator_sa("Con(IsNull(\"%Ftoraster3%\"),\"%idw20meter2%\", -1)", FinRast_r)
0 Kudos
Luke_Pinner
MVP Regular Contributor
From the ArcGIS 10 Help page on the raster calculator:
Note:

The Raster Calculator tool is intended for use in the ArcGIS Desktop application only as a GP tool dialog box or in ModelBuilder. It is not intended for use in scripting and is not available in the ArcPy Spatial Analyst module.


However, you can use map algebra operators and functions directly in python.

E.g.
from arcpy.sa import *
import arcpy

arcpy.CheckOutExtension("Spatial")
landmask=Raster(r'C:\SomeDirectory\landmask')
bathymetry=Raster(r'C:\SomeDirectory\bathy')

masked_bathymetry=Con(IsNull(landmask), bathymetry, 70000)
masked_bathymetry.save(r'C:\SomeDirectory\maskbath')
0 Kudos