Invalid floating point operation. arcpy (ArcSDE only)

5124
13
02-26-2015 05:50 AM
MarcGoetzke
New Contributor II

I always get this Error when i do simple raster calculations with arcpy. i use PyScripter 2.7.5 and ArcGIS 10.2.1 :

Invalid floating point operation

Exception class: EInvalidOp

Exception message: Invalid floating point operation.

Exception address: 00007FF93BB646BE

------------------------------------------------------------------------------

PyScripter version : 2.5.3.0 x64

Python DLL : python27.dll

Python Engine : peInternal

I think its an ArcSDE only memory/cache problem. I tried things like arcpy.ClearWorkspaceCache_management() but it didnt help.

Any suggestions?

Thx

My Program:

#simple raster calculation of a list of rasters

outRas = Int(Raster('test1') + Raster('test2'))

outRas.save(destination + '/' + 'test3')

0 Kudos
13 Replies
DanPatterson_Retired
MVP Emeritus

Where is destination defined?  something is incomplete, does your first posted line work? have you tried

outRas.save()   without specifying a location?

0 Kudos
VandanaRaghunathan
New Contributor III

Hello Marc,

Can you try adding a .tif extension to your output raster?

outRas = Int(Raster('test1') + Raster('test2'))

outRas.save(destination + '\\' + 'test3.tif')

-or-

import os

outRas.save(os.path.join(destination, 'test3.tif')

Thanks,

Vandana

0 Kudos
DanPatterson_Retired
MVP Emeritus

without the extension, it will produce an esri grid, which is preferable to tifs

0 Kudos
VandanaRaghunathan
New Contributor III

Hello Dan,

That is correct, without extension it will be an esri grid. However, esri grid has the following limitations and if they are not met, it will error out:

Storage limitation

The name of a grid is limited as follows:

It cannot be stored using spaces.
It cannot start with a number.
It cannot be longer than 13 characters (a multiband grid is allowed up to 9 characters).


There is a limit to the number of files that can be stored in an INFO directory for both coverages and grids. This total is approximately 10,000. Therefore, this limits the number of grids you can store in a workspace. For example, the following lists the theoretical maximum number of grid datasets that can be stored in a single workspace directory:

Fewer than 5,000 floating point grids, or
Fewer than 3,333 integer grids, with VATs (fewer than 5,000 if no VATs), or
Fewer than 10,000 grid stacks

In addition, there is a limit on the number of characters allowed for a GRID path in windows. The path cannot be longer than 120 characters (including the GRID name)

Esri Grid format—Help | ArcGIS for Desktop

35317 - Do GRID paths have a limit on the number of characters allowed on Windows platforms?

Thanks,

Vandana

DanPatterson_Retired
MVP Emeritus

and none of these are an issue if you know what you are doing... sorry ... you are barking at the wrong old dog

0 Kudos
XanderBakker
Esri Esteemed Contributor

Apart from the output destination being unclear, the inputs are also "incomplete". Running your code from PyScripter, will require the import of arcpy and defining where the inputs can be found. If not specifying the entire path to the input data you should defined the arcpy.env.workspace where the data resides. May need to checkout the spatial analyst extension too.

So please post the entire code you are running. If possible attach (part of) the inputs or provide more information on the type of raster, size, projection, etc. These could all influence.

Did you try to run the code from the python window inside ArcMap? If so, is the same error occurring?

0 Kudos
MarcGoetzke
New Contributor II

Sorry this is the whole program:

import arcpy, os

from arcpy import env

from arcpy.sa import *

arcpy.CheckOutExtension("spatial")

arcpy.env.overwriteOutput = True

def main():

           

            OD_path = 'S:/Project/Raster1'

            DD_path = 'S:/Project/Raster2'

            destination = 'S:/Project/Output'

            liste = ('n','nh4','no3')

            for chem in liste:

                liste2 = ('te','tu','ta')

                for item in liste2:

                    OD = OD_path + '/' + '%s_s%s09'%(chem, item)

                    DD = DD_path + '/' + '%s_t%s09'%(chem, item)

                    Out = '%s_f%s09'%(chem, item)

                    outRas = Raster(OD) + Raster(DD)

                    outRas.save(destination + '/' + Out)

            arcpy.ClearWorkspaceCache_management()

if __name__ == '__main__':

    main()

0 Kudos
MarcGoetzke
New Contributor II

thx for the replies

0 Kudos
XanderBakker
Esri Esteemed Contributor

The problem might be data related, but could you try and replace the + with using arcpy.sa.Plus?

import arcpy, os
from arcpy.sa import *

def main():
    OD_path = r'S:\Project\Raster1'
    DD_path = r'S:\Project\Raster2'
    destination = r'S:\Project\Output'

    liste = ('n','nh4','no3')
    liste2 = ('te','tu','ta')

    arcpy.env.overwriteOutput = True
    arcpy.CheckOutExtension("SPATIAL")

    for chem in liste:
        for item in liste2:
            OD = os.path.join(OD_path, "{0}_s{1}09".format(chem, item))
            DD = os.path.join(DD_path, "{0}_t{1}09".format(chem, item))

            Out = "{0}_f{1}09".format(chem, item)

            # outRas = Raster(OD) + Raster(DD)
            outRas = Plus(OD, DD)
            outRas.save(os.path.join(destination, Out))

    # arcpy.ClearWorkspaceCache_management()
    arcpy.CheckInExtension("SPATIAL")

if __name__ == '__main__':
    main()

BTW: you can increase readability of the code by using syntax highlighting for your code (see: Posting Code blocks in the new GeoNet )

0 Kudos