Skip to main content
6 votes
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 '...
Pierre Racine's user avatar
6 votes
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
user2856's user avatar
  • 67.2k
6 votes

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("...
umbe1987's user avatar
  • 3,785
5 votes

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 ...
user2856's user avatar
  • 67.2k
4 votes

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) #...
user2856's user avatar
  • 67.2k
4 votes
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 ...
traggatmot's user avatar
  • 2,100
4 votes
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 ...
RoperMaps's user avatar
  • 2,166
4 votes
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.
cl3's user avatar
  • 1,946
3 votes

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 * ...
ahmadhanb's user avatar
  • 41.1k
3 votes
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 ...
RoperMaps's user avatar
  • 2,166
3 votes
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 ...
Hornbydd's user avatar
  • 43.9k
3 votes
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)
Ken's user avatar
  • 596
3 votes
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 ...
Ian Turton's user avatar
  • 82.2k
3 votes
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 ...
gianfranco di pietro's user avatar
2 votes
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.
Henri Lim's user avatar
  • 149
2 votes

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 ...
Pierre Racine's user avatar
2 votes
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". ...
jbchurchill's user avatar
  • 4,489
2 votes

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 == ...
user2856's user avatar
  • 67.2k
2 votes

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 ...
JGH's user avatar
  • 42.3k
2 votes
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: ...
Marcelo Villa's user avatar
2 votes

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:
César Arquero Cabral's user avatar
2 votes

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 ...
SMiller's user avatar
  • 3,706
2 votes
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 ...
user2856's user avatar
  • 67.2k
2 votes
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 ...
Hornbydd's user avatar
  • 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") ...
ahmadhanb's user avatar
  • 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, ...
radouxju's user avatar
  • 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 ...
Keagan Allan's user avatar
  • 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 ...
Smithw1's user avatar
  • 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 ...
Lovette's user avatar
  • 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)...
Pierre Racine's user avatar

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