arcgis raster calculator use con to replace values – Syntax & Logic Tool


arcgis raster calculator use con to replace values

Generate precise Map Algebra syntax for conditional raster operations.


The name of the raster layer in your Contents pane.



The numeric value to compare against.
Please enter a valid number.


Output value (or raster) if the condition is met.


Output value if condition is not met. Use “NoData” for null.


Map Algebra Syntax:

Con(“Elevation_Raster” > 500, 1, 0)

Logic Summary: If pixel in Elevation_Raster is greater than 500, set to 1; otherwise set to 0.
Python Equivalent: out_raster = Con(Raster("Elevation_Raster") > 500, 1, 0)
Calculation Mode: Boolean/Conditional Replacement

Visual Logic Preview (3×3 Raster)

Before 450 600 510

300 800 499

After 0 1 1

0 1 0

Example visualization applying logic to sample values (450, 600, 510, 300, 800, 499)

What is arcgis raster calculator use con to replace values?

The arcgis raster calculator use con to replace values is a method used within Geographic Information Systems (GIS) to perform conditional processing on raster datasets. Using the `Con` function—short for “Conditional”—users can examine each pixel (cell) in a raster and assign a new value based on whether a specific condition is met. This is a fundamental skill for spatial modeling, environmental analysis, and data cleaning.

Who should use it? Hydrologists use it to mask out elevations below a flood level, urban planners use it to identify suitable building zones, and remote sensing specialists use it to isolate specific vegetation indices. A common misconception is that you need complex Python scripts for simple replacements; in reality, the Raster Calculator provides a user-friendly interface for these powerful Map Algebra expressions.

arcgis raster calculator use con to replace values Formula and Mathematical Explanation

The mathematical logic follows a simple “If-Then-Else” structure. The syntax follows this pattern:

Con(Condition, Value_if_True, Value_if_False)

Step-by-step derivation:

  • Evaluation: The system looks at cell (x,y) in the input raster.
  • Test: Is the pixel value relative to the threshold (e.g., Raster > 100)?
  • Assignment: If the test returns a boolean ‘True’, the output cell receives Value A. If ‘False’, it receives Value B.
Variable Meaning Unit Typical Range
Condition The logical test applied to pixels Boolean Expression Any logical operator
Value_if_True Result if condition is met Integer/Float/Raster -∞ to +∞ or NoData
Value_if_False Result if condition is not met Integer/Float/Raster -∞ to +∞ or NoData

Practical Examples (Real-World Use Cases)

Example 1: Flood Inundation Mapping

Suppose you have a Digital Elevation Model (DEM) called “City_DEM” and want to identify all areas below 5 meters as “At Risk” (Value 1) and areas above as “Safe” (Value 0).

  • Input: City_DEM < 5
  • Value if True: 1
  • Value if False: 0
  • Resulting Syntax: Con("City_DEM" < 5, 1, 0)

Example 2: Masking NoData Values

If you have an NDVI raster where values less than 0 are erroneous or water, and you want to set them to a null value (NoData) while keeping valid vegetation data as they are.

  • Input: "NDVI_Layer" < 0
  • Value if True: NoData
  • Value if False: "NDVI_Layer"
  • Resulting Syntax: Con("NDVI_Layer" < 0, SetNull("NDVI_Layer"), "NDVI_Layer")

How to Use This arcgis raster calculator use con to replace values Calculator

  1. Raster Name: Enter the exact name of your layer as it appears in ArcGIS Pro or ArcMap.
  2. Choose Operator: Select your logical test (e.g., "Equal To" for specific reclassification).
  3. Threshold: Define the numeric boundary for your test.
  4. Replacement Values: Decide what the pixel should become if it passes the test, and what it should be if it fails.
  5. Generate Syntax: The calculator updates in real-time. Copy the string into the Raster Calculator tool in ArcGIS.

Key Factors That Affect arcgis raster calculator use con to replace values Results

  • Pixel Depth: Ensure your replacement values match the bit-depth of your raster (e.g., don't use 256 for an 8-bit signed raster).
  • Spatial Resolution: The `Con` function operates cell-by-cell; if your rasters have different resolutions, ArcGIS will resample them, potentially affecting accuracy.
  • Coordinate Systems: Misaligned rasters can cause the `Con` function to produce unexpected spatial offsets.
  • NoData Handling: If the input pixel is NoData, the result is usually NoData unless specific `IsNull` functions are nested.
  • Performance: Large global rasters require significant processing power; consider using "Image Analyst" extensions for server-side processing.
  • Map Algebra Version: ArcGIS Pro uses Python-based Map Algebra, whereas older ArcMap versions used a slightly different parser.

Frequently Asked Questions (FAQ)

Can I use multiple conditions in one Con statement?

Yes, you can nest them: Con(R1 > 10, 1, Con(R1 > 5, 2, 0)). This creates multiple classes.

How do I set values to Null using Con?

In ArcGIS, you typically use the `SetNull` tool, but inside Raster Calculator, you can use the `SetNull` function as the True/False argument.

Does this change my original data?

No, arcgis raster calculator use con to replace values always creates a new temporary or permanent output raster layer.

What is the difference between Con and Reclassify?

Reclassify is a GUI tool for multiple ranges; Con is a Map Algebra function best for logical "if-then" scenarios and dynamic masking.

Can I use another raster as the replacement value?

Absolutely. Instead of "1", you can put another raster name to pull values from that layer where the condition is met.

Why does my formula return an error?

Common issues include missing quotes around raster names, missing commas, or mismatched parentheses.

Is "arcgis raster calculator use con to replace values" case sensitive?

The function `Con` is generally not case sensitive in the calculator, but raster names must match exactly.

Can I use "AND" or "OR" in the condition?

Yes, using the bitwise symbols: Con(("R1" > 5) & ("R1" < 10), 1, 0).

Related Tools and Internal Resources

© 2023 GIS Expert Tools - Advanced arcgis raster calculator use con to replace values resources.


Leave a Reply

Your email address will not be published. Required fields are marked *