# Tag Info

Accepted

### Passing additional arguments to ST_MapAlgebra callback?

Additional arguments are passed as the 6th, and so on, arguments, after the custom function signature: ST_MapAlgebra(b1.rast, -- raster to operate on 1, -- band '...
• 2,578
Accepted

### ArcPy map algebra equivalent for "any"?

You could sum the rasters and test whether the total is greater than 0. list_of_rasters = [Raster(a), Raster(b), Raster(c)] z = CellStatistics(list_of_rasters, "SUM") > 0
• 67.2k

### Arcpy reclassify with function

This is how I would do it (it requires the Spatial Analyst extension which I think you have): import arcpy from arcpy.sa import * arcpy.CheckOutExtension = "Spatial" ndvi_raster = Raster("...
• 3,785

### Calculate NDVI using ArcPy Spatial Analyst

I presume you're using ArcGIS Desktop which uses python 2x, not ArcGIS Pro which uses python 3x. Side note: this is one example of why it's important to specify the software you are using. In python ...
• 67.2k

### Identifying row and column location of a raster image using ArcGIS 10.1

The \$\$RowMap, \$\$ColMap, \$\$XMap and \$\$YMap variables (and some others) are no longer (directly) supported as of ArcGIS 10.0. You can use it via python: arcpy.env.extent = arcpy.Extent(0, 0, 10, 10) #...
• 67.2k
Accepted

### Calculate NDVI using ArcPy Spatial Analyst

Are the red_band_raster and the nir_band_raster values integers? It seems likely that you should move the float() commands around each raster variable call in your equations, and not around the result ...
• 2,100
Accepted

### Adding two rasters using map algebra in ArcPy?

What @Joseph says. The Raster class needs a string containing the path to your raster. You've correctly assigned this to a variable, so you then need to pass those variables to instantiate your ...
• 2,166
Accepted

### Merging two rasters, obtain only highest values, overwrite raster in ArcGIS Desktop?

You can do this just by using the Mosaic to New Raster geoprocessing tool. Just choose maximum for your Mosaic Operator and the new raster will use the high value anywhere that they overlap.
• 1,946

### ArcGIS Raster Calculator Con-Statement

@FelixIP comment is correct, you need to convert your raster file to a raster object using arcpy.Raster() before using Con(). Here is the code that worked for me: import arcpy from arcpy.sa import * ...
• 41.1k
Accepted

### Gdal_calc NDVI for many rasters

Nearly there. Couple of small problems: You've used the bash syntax instead of cmd. i.e. \$ instead of %. Your --outfile parameter isn't specified explicitly, and looks a bit jumbled. Try: for %i in ...
• 2,166
Accepted

### Getting rid of small objects on raster in ArcMap?

You can use the Majority Filter to remove cells that are surrounded by your green cells. This would also influence the boundary of your dominant green area as this tool works a local level. In your ...
• 43.9k
Accepted

### Raster multiplication script not executing

You're inputting your variables as string. Try without the quotes. outRas = Raster(in_raster1) * Raster(in_raster2) * Raster(in_raster3)
• 596
Accepted

### Creating custom Operation for encapsulating some map algebra using GeoTools?

It sounds like you need jiffle which is contained in the gt-process-raster module. Once you have constructed a Process you can pass in a list of source rasters and bands for it to process in the ...
• 82.2k
Accepted

### Showing two sets of points from two different fields in QGIS?

Union (geoprocessing) feature make a "union" of 2 dataset (C = A united to B). Probably you are tring to JOIN two dataset. Try this: Go to JOIN settings: (right click -> properties -> Join) Add ...
Accepted

### Raster result is different for arcpy.sa CON and arcpy.gp.Con_sa

As mentioned by @Luke, set arcpy.env.scratchWorkspace before running Spatial Analysis tool will redirect that result to scratch workspace.
• 149

### PostGis's ST_MapAlgebra rasters do not have the same alignment

To work, rasters passed to the two rasters variant of ST_MapAlgebra() must: 1) be in the same coordinate system. You can reproject one raster to the coordinate system of the other raster with ...
• 2,578
Accepted

### Looping Map Algebra using Python

You must put a slash after the "work.gdb" on that last line. It is assuming you are saving it as a work.gdbraster file name (e.g. it is appending whatever string "raster" represents to "work.gdb". ...
• 4,489

### Working with 2 rasters, having different extents but same resolution, in ArcGIS raster calculator?

If you set your environment extent correctly to raster 1, then the extent of the output raster will be that of raster 1, but you will only get data where raster 2 has data (because Value + NoData == ...
• 67.2k

### Showing two sets of points from two different fields in QGIS?

If the two source layers have the same fields, you could combine them together using the merge tool. Using the data you currently have, you would have to rely on the coalesce function to handle the ...
• 42.3k
Accepted

### What is this Map Algebra expression performing in ArcGIS ModelBuilder?

The Set Null tool takes the following parameters: SetNull (in_conditional_raster, in_false_raster_or_constant, {where_clause}) which are described in the tool's documentation as follows: ...
• 5,998

### Rescaling DEM for Blender

As @Marcos Salto said, I would bet on the view distance. If you could share an screenshot this could be more easy to figure it out. Here is where you have to set the view:
• 3,494

### Map algebra with loop and SetNull not working

Earlier in the code inRaster is assigned to the output from ListRasters(), which makes it a list of rasters. This variable is called in the for loop, instead of the variable raster, and doesn't appear ...
• 3,706
Accepted

### Raster calculator multiple expressions

See the Map Algebra operators and complex statements documentation: == is the equals operator. & is the boolean and operator. | is the boolean or operator. you need to put () parentheses around ...
• 67.2k
Accepted

### Moderate raster values based on another raster

A trick I have used in the past to answer this sort of question is to multiply your erosion risk layer by 10 so you have values 10,20,30,40 & 50. You then add your land cover raster to this ...
• 43.9k
1 vote

### Working with 2 rasters, having different extents but same resolution, in ArcGIS raster calculator?

If you set the extent to raster1 image, then you can use Con with IsNull functions to convert the Null data of your output raster to 0 as follows: Con(IsNull("OutputRaster.img"),0,"OutputRaster.img") ...
• 41.1k
1 vote

### ExecuteError: ERROR 000539 while running expression rcexec()

Raster calculator as such is not recognized as a tool in Python script. You can have more info on this issue on the link below. https://support.esri.com/en/technical-article/000011928 In your case, ...
• 49.8k
1 vote

### Working with 2 rasters, having different extents but same resolution, in ArcGIS raster calculator?

I have always had a hard time trying to get rasters of differing spatial extents to output to the "Union of Inputs". You could try setting this up first before trying the steps outlined below. First ...
• 3,776
1 vote

### Converting DEM units using Map Algebra and Python

Thank you @FelixIP for the help. I managed to correct my mistake. By using the arcpy.Raster() function I, then, had to check out a Spatial Analyst license in the script. Below is my final draft of the ...
• 345
1 vote

### Reclassify in python doesn't reclassify things

The RemapValue is an arcpy.sa (Spatial Analyst) object. By not referencing the spatial analyst module, the script doesn't know what to do with your RemapValue statement. The easiest fix would probably ...
• 979
1 vote
Accepted

### Get argmax of PostGIS raster bands

Here is an example that works with two bands. Up to you to generalize to four bands. WITH raster AS ( SELECT ST_AddBand(ST_AddBand(ST_AddBand(ST_SetValue(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0 ,1)...
• 2,578

Only top scored, non community-wiki answers of a minimum length are eligible