calculate Altitude difference in a Raster

4683
8
12-28-2014 12:39 AM
flohBärtschi
New Contributor II

Hey,

I should know, if in my 100 by 100km grid cell is an altitude difference of 1000m. each grid cell that has at least that much difference schould get the value 1, all others the value 0.

I start with a SRTM DEM with 90m resolution, and a grid with 100km resolution.

which is the appropriate tool for this?

Thanks a lot

Floh

in German:

Hallo,

Ich habe folgende Frage:

Ich möchte in einer 100x100km Rasterzelle wissen, ob es mindestens 1000m Höhenunterschied hat. Jedes Raster, welches die bedingung erfüllt soll den wert 1 bekommen, alle anderen den wert 0.

als Grundlage dafür habe ich ein DEM mit 90m Auflösung, (SRTM) und eine Rasterdatei mit 100km auflösung.

nach welchem tool soll ich suchen?

Besten Dank für eure tipps

Floh

Tags (2)
0 Kudos
8 Replies
XanderBakker
Esri Esteemed Contributor

Are you looking for a local difference or determining those extreme cells with highest and lowest values?

For local differences you could use the Focal Statistics tool with the range statistic type

In case of the determining the highest and lowest you could use some simple python code:

import arcpy
from arcpy.sa import *

dem = r"path\and\name\to\your\dem"
ras = arcpy.Raster(dem)
dem_min = ras.minimum
dem_max = ras.maximum

result = Con((ras - dem_min) >= 1000, 1, Con((dem_max - ras) >= 1000), 1, 0)
result.saveas(r"path\and\name\to\your\output raster")
0 Kudos
Jean-PierreDEBOOS1
Esri Contributor

If you don't know python code you can use tool : Con Aide ArcGIS (10.2, 10.2.1 et 10.2.2)

0 Kudos
XanderBakker
Esri Esteemed Contributor

Or the link to the German Help page would be: ArcGIS-Hilfe (10.2, 10.2.1 und 10.2.2)

0 Kudos
flohBärtschi
New Contributor II

thanks a lot for the answers, i think it should work with the "Con" tool. I am working on global scale therefore my DEM is a Mosaic Raster dataset. So i have troubles with the "path and name to your dem" thing in the python code... how do i define the path to a Mosaic raster dataset?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Good point... that is a little more complex and I'm not sure if you can convert the mosaic raster dataset to a raster object... This is what I did (and I corrected some errors in the code):

import arcpy, os
from arcpy.sa import *
arcpy.env.overwriteOutput = True
ws = r"C:\Forum\rasCat\bla.gdb"

arcpy.CheckOutExtension("Spatial")

mosa = os.path.join(ws, "mosa")
dem = os.path.join("IN_MEMORY", "dem01")
arcpy.CopyRaster_management(in_raster=mosa,out_rasterdataset=dem,
                            config_keyword="#",background_value="#",
                            nodata_value="-3,402823e+038",onebit_to_eightbit="NONE",
                            colormap_to_RGB="NONE",pixel_type="#",
                            scale_pixel_value="NONE",RGB_to_Colormap="NONE")

ras = arcpy.Raster(dem)
dem_min = ras.minimum
dem_max = ras.maximum
print dem_min, dem_max

result = Con((ras - dem_min) >= 1000, 1, Con((dem_max - ras) >= 1000, 2, 0))
result.save(os.path.join(ws, "outras01"))

arcpy.CheckInExtension("Spatial")

In the code:

  • ws contains the path to the file geodatabase.
  • mosa is the path to the mosaic dataset in the file geodatabase
  • dem is a intermediate raster, result from converting the mosaic dataset to a raster (in memory)
0 Kudos
flohBärtschi
New Contributor II

nice try, but my DEM-mosaic is like 150GB big, so i can't copy it into my memory...

  1. mosa = os.path.join(ws, "mosa"
  2. dem = os.path.join("IN_MEMORY", "dem01"

when i tried it the  "ERROR 000426: Out Of Memory Failed to execute (CopyRaster)." occurred.

Do you have another idea?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Yeah, 150 GBs is a little big to load into memory. See the answer by Curtis Price‌ for alternative methods. Remember that the resulting raster will be big too...

0 Kudos
curtvprice
MVP Esteemed Contributor

Have you considered the Aggregate tool?

Use the tool Environments button and set the processing cell size to 100 and explicitly set the extent so the lower left corner aligns with your 100,000-m grid cells. Then run Aggregate with a factor of 1000 to process each block. There is no RANGE option but you could run the tool with MINIMUM and MAXIMUM to make two 100km grids which you can then subtract.

Once you have this 100km min and max grids calculated, you can subtract and classify as 1,0 in a single step using the Raster Calculator. (No script coding!)

Con(("max100" - "min100") > 1000, 1, 0)

Test with a small extent first, as this processing may take quite a while. 150GB is a lot of data. You may even need to run your analysis in extent pieces to get it to work, and merge the results together using the Mosaic tool.