1

I have two rasters representing travelling speed: one for road (with speed values for different types of roads and "0" values where there is no roads) and one for land-cover (with lower values, but no "0").

I would like to combine them in a single travelling speed raster this way: Keeping road values where there is a road (so where the road raster is not 0) and, elsewhere, having the value of land-cover.

I do it all the time with the raster calculator in ArcGIS with the following command: Con(roads > 0 , roads, landcover)

I'd like to insert it in an ArcPy script so I did it this way:

raster = arcpy.gp.RasterCalculator_sa("""Con(roads>landCover, roads, landCover)""", tmpPath + "/friction")

When I do it in ArcGIS, it works perfectly well but when I do it in my ArcPy code, it only gives me the roads value as a result but ignore the landcover values...

I can't find why.

What could cause this expression to work in ArcGIS but not in my ArcPy code?

  • Have you tried using the Con arcpy function as opposed to RasterCalculator_sa as described here? – Ali Jul 4 at 14:39
  • Raster calculator is only for use as a tool or in model builder, not scripting gis.stackexchange.com/a/265654/2856 – user2856 Jul 6 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.