Arcgis Raster Calculator Use Con To Replace Values






ArcGIS Raster Calculator: Use Con to Replace Values – Calculator & Guide


ArcGIS Raster Calculator: Use Con to Replace Values

Conditional Logic Simulator & Map Algebra Syntax Generator


Map Algebra Logic Simulator

Simulate how the arcgis raster calculator use con to replace values on a 10×10 pixel grid.




Select the comparison operator for the ‘Con’ statement.

Please enter a valid numeric threshold.



Value assigned if condition is TRUE.

Please enter a valid numeric replacement.


Generated Map Algebra Syntax
Con(“Raster” < 50, 0, "Raster")

Pixels Modified
0

New Mean Value
0.00

Net Sum Change
0


Input Raster (Simulated)

Hover over grid to see values

Output Raster (Result)

Pixel Value Distribution


Summary Statistics


Statistic Input Raster Output Raster Difference

Understanding ArcGIS Raster Calculator Use Con to Replace Values

In the field of Geographic Information Systems (GIS), spatial analysis often requires precise manipulation of pixel data. One of the most powerful and frequently used operations involves conditional logic. Specifically, the method to arcgis raster calculator use con to replace values is a fundamental skill for any GIS analyst working with raster datasets. Whether you are reclassifying land cover, correcting Digital Elevation Models (DEMs), or managing null data, the Con function is your primary tool.

What is the Con Function in ArcGIS?

The “Con” function stands for Conditional. It allows you to perform an if/then/else evaluation on each cell (pixel) of an input raster. If a cell meets a specific condition (e.g., elevation is less than 0), you can assign it a new value. If it does not meet the condition, you can either keep the original value or assign a different one.

This function is typically accessed via the Raster Calculator tool within the Spatial Analyst extension of ArcGIS Pro or ArcMap. It essentially automates the decision-making process for millions of pixels instantly.

Who Should Use It?

  • Hydrologists: To fill sinks or remove negative elevation values in DEMs.
  • Cartographers: To mask out specific data ranges for visualization.
  • Data Scientists: To preprocess satellite imagery before machine learning classification.

Map Algebra Formula and Explanation

To effectively master how the arcgis raster calculator use con to replace values, you must understand the Map Algebra syntax. The general formula follows this structure:

Output_Raster = Con(condition, true_expression, {false_expression})

Let’s break down the variables used in this calculation:

Variable Meaning Typical Data Type
condition The logical test applied to every pixel. Boolean Expression (e.g., “DEM” > 1000)
true_expression Value assigned if the condition is TRUE. Constant Value or Another Raster
false_expression (Optional) Value assigned if the condition is FALSE. Constant Value or Original Raster

Practical Examples of Reclassification

Example 1: Correcting Negative Elevation Data

Imagine you have a Digital Elevation Model (DEM) where water bodies are incorrectly recorded as -9999 (NoData) or negative values. You want to flatten these to 0 meters (sea level).

  • Input: “DEM_Raw”
  • Logic: If value < 0, change to 0. Otherwise, keep "DEM_Raw".
  • Expression: Con("DEM_Raw" < 0, 0, "DEM_Raw")

Example 2: Binary Reclassification (Masking)

You need to identify all areas with high slope (risk zones). Slopes greater than 30 degrees are "Risk" (1), and everything else is "Safe" (0).

  • Input: "Slope_Raster"
  • Logic: If value > 30, change to 1. Else, change to 0.
  • Expression: Con("Slope_Raster" > 30, 1, 0)

How to Use This Simulator

Our tool above simulates the logic of the arcgis raster calculator use con to replace values without needing to open heavy GIS software. Here is how to use it:

  1. Generate Data: Click "Generate New Random Raster Data" to create a simulated 10x10 grid of values (0-100).
  2. Set Condition: Choose an operator (e.g., Less Than) and a Threshold Value (e.g., 50).
  3. Set Outcomes: Define the "True Value" (what the pixel becomes if the condition is met) and the "False Value".
  4. Analyze: Watch the "Output Raster" update in real-time. The "Pixels Modified" metric tells you how many cells were affected by your query.

Key Factors Affecting Raster Calculation Results

When performing these calculations in real environments like ArcGIS Pro, consider these factors:

  • Processing Extent: Ensure your environment settings match the extent of your input raster, or you may inadvertently crop data.
  • Cell Size (Resolution): Performing calculations on rasters with different resolutions requires resampling, which can alter values.
  • Snap Raster: Align your output pixels to a grid to avoid slight shifts in spatial registration.
  • NoData Handling: Understand how null values are treated. Often, if a pixel is NoData in the input, it remains NoData unless explicitly handled using IsNull logic.
  • Pixel Depth: Ensure your output format supports the range of new values (e.g., don't try to store negative numbers in an unsigned integer raster).
  • Projection: Calculations should be done on projected data (e.g., UTM) rather than geographic coordinates (Lat/Long) for accurate area/distance measurements.

Frequently Asked Questions (FAQ)

Can I use multiple conditions in one Con statement?

Yes. You can use nested Con statements or Boolean operators. Example: Con(("Raster" > 10) & ("Raster" < 50), 1, 0).

What is the difference between SetNull and Con?

SetNull is specific to creating NoData values. SetNull("Raster" < 0, "Raster") sets values below 0 to NoData. Con is more general and can replace values with any number.

Why does my output raster look black?

This is often a symbology issue. Calculate statistics for the new raster or stretch the symbology histogram to cover the new data range.

Does this work in ModelBuilder?

Absolutely. The Raster Calculator tool (and the Con tool specifically) is fully compatible with ModelBuilder for automated workflows.

Can I replace values with another raster?

Yes. Instead of a constant number like '0', you can use another raster layer name as the true or false argument.

Is Python faster than Raster Calculator?

Using ArcPy with the Spatial Analyst module (arcpy.sa) is efficient for batch processing, but the underlying engine is effectively the same as the Raster Calculator.

How do I handle floating point errors?

When comparing floats, avoid ==. Instead, check if the value is within a small range of the target.

Do I need the Spatial Analyst license?

Yes, the Raster Calculator and Con tool usually require the Spatial Analyst or 3D Analyst extension license.

Related Tools and Internal Resources

Explore more about spatial analysis and data management with these internal resources:

© 2023 GIS Analytics Tools. All rights reserved.


Leave a Comment