Raster calculator problem with python

707
3
12-10-2020 03:48 PM
HectorCN
New Contributor

I wanted to do some radiometric corrections on band 1 but raster calculator fails and it gives me this message. I already uninstaled and reinstaled arcgis but te problem stays. My teacher didn't know what to do either.

Nueva imagen de mapa de bits.jpg

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

Lots of places things can go wrong

BUG-000115280: Raster Calculator returns the Error 000539 when the .. (esri.com)

if the expression originated from modelbuilder for instance

Error: ERROR 000539: Error running expression: rcexec() (esri.com)

or dozens more links

Esri Support Search-Results

 

But in short, try saving the output to a simple folder as a tif file rather than into a geodatabase in the Users folder (ie c:\temp\answer.tif)  And make sure you are using the Raster Calculator in the Spatial Analyst Toolbar.  And finally... if you are using arcmap switch to ArcGIS Pro

 


... sort of retired...
LizGraham
New Contributor II

Hello,

I see in the error message that a *.tif is trying to be written into an fgdb, *.tif cannot be written to an fgdb.

LizGraham_0-1607972027173.png

Try removing the *.tif from the output raster name, or write a *.tif to a folder not to an fgdb. 

Thanks,

Liz

 

RachelGomez
New Contributor II

With GDAL, you can read and write several different raster formats in Python. Python automatically registers all known GDAL drivers for reading supported formats when the importing the GDAL module. Most common file formats include for example TIFF and GeoTIFF, ASCII Grid and Erdas Imagine .img -files.

Landsat 8 bands are stored as separate GeoTIFF -files in the original package. Each band contains information of surface reflectance from different ranges of the electromagnetic spectrum. You can read more information about Landsat 8 here.

Let's start with inspecting one of the files we downloaded:

In [ ]:
from osgeo import gdal

filepath = r"LandsatData/LC81910182016153LGN00_sr_band4.tif"

# Open the file:
raster = gdal.Open(filepath)

# Check type of the variable 'raster'
type(raster)

Regards,

Rachel Gomez

0 Kudos