I'd like to be able to alter raster values, through fairly simple equations, without using the module ArcPy.
Is that possible?
It seems like gdal, numpy, and rasterlang might make this possible but I'm having trouble figuring out exactly how.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Yes, but you must know Python (and not just ArcPy):
There are lots of examples on the Web but to begin, look at
It depends on the type of operations you'd like to carry out and the languages you already know...
R (with the
raster library) are good open source solutions.
Since it seems you're more into Python, here is a good place to start -- especially lessons 4-6.
Here is a small example of applying a threshold to a raster:
import os, sys, numpy, gdal from gdalconst import * os.chdir('path/to/your/raster') # register all of the GDAL drivers gdal.AllRegister() # open the image inDs = gdal.Open('my_raster.img', GA_ReadOnly) if inDs is None: print 'Could not open my_raster.img' sys.exit(1) # get image size rows = inDs.RasterYSize cols = inDs.RasterXSize # read the input data inBand = inDs.GetRasterBand(1) inData = inBand.ReadAsArray(0, 0, cols, rows).astype(numpy.Float) #simple raster algebra outData = numpy.where(inData >= 5, 10, 0) # create the output image driver = inDs.GetDriver() outDs = driver.Create('highpass1.img', cols, rows, 1, GDT_Float32) if outDs is None: print 'Could not create highpass1.img' sys.exit(1) outBand = outDs.GetRasterBand(1) # write the output data outBand.WriteArray(outData, 0, 0) # flush data to disk, set the NoData value and calculate stats outBand.FlushCache() stats = outBand.GetStatistics(0, 1) # georeference the image and set the projection outDs.SetGeoTransform(inDs.GetGeoTransform()) outDs.SetProjection(inDs.GetProjection()) inDs = None outDs = None