ArcGIS Raster Calculator ‘Con’ Tool Syntax Generator


ArcGIS Raster Calculator: Con Tool Syntax Generator

Create flawless conditional expressions to replace raster values using the ‘Con’ tool.



The name for your new raster dataset.


The raster to evaluate (e.g., “elevation”, “land_use”). Must be a valid layer name.


Refers to each cell’s value in the conditional raster.

The value to compare against.



The new value if the condition is met. Can be a number (constant) or a raster name (e.g., “other_raster”).


The new value if the condition is NOT met. Leave blank to assign NoData.

Generated Map Algebra Expression

Understanding the ‘Con’ Tool for Raster Value Replacement

The arcgis raster calculator use con to replace values is a fundamental task in GIS analysis. The `Con` (Conditional) tool is a powerful function within ArcGIS’s Spatial Analyst extension that allows you to perform an if-then-else evaluation on each cell of a raster. This calculator simplifies the process of creating the correct syntax for the Raster Calculator tool, helping you avoid common errors and streamline your workflow.

What is the ArcGIS Con Tool?

At its core, the `Con` tool evaluates a logical condition for every pixel in an input raster. If the condition proves true for a pixel, it assigns a specified value to that pixel in the output raster. If the condition is false, it assigns a different, second value. This is invaluable for tasks like reclassifying data, isolating specific features, or replacing values based on a set criteria. For example, you could replace all elevation values above 1500 meters with a value of 1 and all values below with 0, effectively creating a binary raster of high-elevation areas.

The `Con` Tool Formula and Explanation

The syntax for the `Con` tool within the ArcGIS Raster Calculator can be expressed in a couple of ways, but the most common structure this calculator generates is:

Output_Raster = Con("conditional_raster", true_value, false_value, "where_clause")

This syntax is a direct and powerful way to use con to replace values in the ArcGIS raster calculator.

Syntax Variable Explanations
Variable Meaning Unit / Type Typical Range
conditional_raster The input raster whose cell values are evaluated. Raster Layer Name e.g., “elevation”, “landuse”, “slope_degrees”
true_value The value assigned to the output cell if the condition is true. Constant (Number) or Raster Any numeric value or a raster layer name.
false_value The value assigned to the output cell if the condition is false. If omitted, NoData is assigned. Constant (Number) or Raster Any numeric value or a raster layer name.
where_clause The logical expression used to test each cell. Uses “Value” to refer to the cell value. String (SQL-like) e.g., “Value > 100”, “Value = 5”

Visualizing the Logic

The `Con` tool follows a simple flowchart for every single cell in your raster. This diagram illustrates the decision-making process.

Input: Cell from “elevation”
Condition: Is “Value” == 1000?
↓ True
Output Value = 1

↓ False
Output Value = 0

Practical Examples

Example 1: Creating a Binary Elevation Raster

Imagine you have an elevation raster and want to create a new raster that simply shows areas above and below 2500 meters. This is a classic use case to arcgis raster calculator use con to replace values.

  • Inputs:
    • Conditional Raster: “dem_25m”
    • Condition: “Value” > 2500
    • Value if True: 1
    • Value if False: 0
  • Resulting Expression: Con("dem_25m", 1, 0, "Value > 2500")
  • Interpretation: The output raster will have a value of 1 for all areas with an elevation greater than 2500 meters, and 0 for all other areas. You can explore more about raster operations in the ArcGIS Raster Functions guide.

Example 2: Replacing a Specific Land Use Class

Suppose you have a land use raster where the value ‘4’ represents ‘Forest’, and you want to isolate these forested areas, setting all other land use types to a NoData value.

  • Inputs:
    • Conditional Raster: “land_use_2020”
    • Condition: “Value” == 4
    • Value if True: 1 (or you could keep the original value by using “land_use_2020” here)
    • Value if False: (Leave blank for NoData)
  • Resulting Expression: Con("land_use_2020", 1, "", "Value == 4")
  • Interpretation: The output will contain cells with the value 1 only where the original land use was forest. All other cells will be NoData, effectively masking out non-forest areas. For more complex reclassification, check out our guide on advanced raster reclassification.

How to Use This ‘Con’ Tool Syntax Calculator

Using this tool is straightforward and designed to prevent syntax errors in the ArcGIS Raster Calculator.

  1. Enter Output Raster Name: Provide a name for your new file.
  2. Enter Conditional Raster: Type the exact name of the raster layer you want to analyze.
  3. Define the Condition: Use the dropdown to select a logical operator (like ‘>’, ‘==’, etc.) and enter the value to test against.
  4. Set True/False Values: Enter the numeric values or raster names to be assigned for true and false outcomes. If you want to assign NoData for a false condition, simply leave the ‘Value if False’ field empty.
  5. Generate & Copy: The full Map Algebra expression is generated in real-time. Click the “Copy Expression” button.
  6. Execute in ArcGIS: Paste the copied expression directly into the Raster Calculator tool in ArcMap or ArcGIS Pro and run it.

Key Factors That Affect ‘Con’ Tool Usage

  • Data Type: The output data type (integer or float) depends on the input values. If your ‘true’ or ‘false’ values are floating-point numbers (e.g., 1.5), the output raster will be a float. If both are integers, the output will be an integer.
  • Using Rasters vs. Constants: For the ‘true’ and ‘false’ values, you can input a constant number OR the name of another raster. If you use a raster, the output cell will take its value from the corresponding cell in that ‘true’ or ‘false’ raster.
  • Handling NoData: The `Con` tool is NoData-aware. If a cell in the conditional raster is NoData, it will be NoData in the output. Leaving the ‘false’ value blank is the standard way to assign NoData for cells that don’t meet the condition.
  • Complex Expressions: You can nest `Con` statements to create complex, multi-level logic (e.g., `Con(“raster”, 1, Con(“raster”, 2, 0, “Value < 50"), "Value < 25")`). Our guide on writing complex expressions can help.
  • Performance: For very large rasters, running a single, well-formed `Con` expression in the Raster Calculator is generally more efficient than running multiple separate geoprocessing tools.
  • `where_clause` Keyword “Value”: The special keyword “Value” is a placeholder that refers to the value of the cell being processed from the `in_conditional_raster`.

Frequently Asked Questions (FAQ)

1. What’s the difference between `Con(“elev”, 1, 0, “Value > 1000”)` and `Con(Raster(“elev”) > 1000, 1, 0)`?

Both achieve the same result. The first uses a `where_clause`, which is explicit and often easier to read. The second performs the logical test directly on the raster object, creating an intermediate boolean (0/1) raster that `Con` then evaluates. The `where_clause` method is generally preferred for clarity when using the tool interactively.

2. How do I handle multiple conditions, like “Value > 100” AND “Value < 200"?

You can combine conditions in the `where_clause` using ‘AND’ and ‘OR’ operators. The expression would look like: "Value > 100 AND Value < 200".

3. Can I replace a value with a value from another raster?

Yes. Instead of a number, just type the name of the other raster (e.g., "other_raster") in the 'Value if True' or 'Value if False' field. Make sure the rasters have the same extent and cell size for predictable results.

4. Why is my output all NoData?

This can happen if your `where_clause` condition was never met and you left the `false_value` blank. Double-check your condition and the range of values in your conditional raster.

5. Can I use this tool for floating-point rasters?

Absolutely. The `Con` tool works seamlessly with both integer and floating-point rasters. If any of your inputs (true/false values) are floats, the output will be a float raster.

6. How do I replace existing NoData values with a number like 0?

You need a different tool for that: `IsNull`. The expression would be: Con(IsNull("your_raster"), 0, "your_raster"). This says, "If a cell in 'your_raster' is NoData, make it 0; otherwise, keep its original value."

7. Is the syntax the same in ArcMap and ArcGIS Pro?

Yes, for the `Con` tool and basic Raster Calculator expressions, the Map Algebra syntax is consistent between ArcMap and ArcGIS Pro, making this calculator useful for both.

8. What is the maximum length of the expression?

The `where_clause` in the `Con` tool has a character limit, which is typically quite large (e.g., 4096 characters), but it's best to avoid extremely long, unreadable expressions.

Related Tools and Internal Resources

Expanding your knowledge of raster analysis is key to mastering GIS. Here are some related tools and guides:

This tool is for educational purposes to demonstrate how to arcgis raster calculator use con to replace values. Always verify expressions with your specific data and ArcGIS version.



Leave a Reply

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