arcpy.Clip_management -> Error: Floating point division by zero.

2385
4
09-02-2014 03:14 AM
MarcGoetzke
New Contributor II

i am using the arcpy.Clip_management tool with python and i always get the error: Floating point division by zero. In the past it worked. Has somebody an idea?

i have one raster map: test (folder)

and one clipping file: schab.shp

my Python code:

import arcpy

def main():

    arcpy.env.workspace = r'F:/2007/test_rastered'

    arcpy.Clip_management('test', "#", 'F:/2007/test_clipped/test', 'F:/Schablone/schab.shp' , "0", "ClippingGeometry", "NO_MAINTAIN_EXTENT")

    

if __name__ == '__main__':

    main()

0 Kudos
4 Replies
MarcGoetzke
New Contributor II

I have checked the projections in ArcMap of the raster and the .shp and they are both correct, they have the same projection. Do not know where the problem is:(

0 Kudos
FilipKrál
Occasional Contributor III

Strange..., try setting some more environments settings:

in_raster = r'c:\path\to\the\raster'

arcpy.env.snapRaster = in_raster

arcpy.env.extent = arcpy.Describe(in_raster).extent

Consider also arcpy.env.cellSize and other environment settings listed towards the end of the Tool's help.

Also, I think the tool may fail if the polygon you are trying to clip the raster with is too small (relative to the raster cell size). Does your polygon cover more than just a few cells?

MarcGoetzke
New Contributor II

Thx Filip. Good idea but it did not help. I still get the error: Floating point division by zero. My polygon for clipping is not small, it is 1/9 of the size of Germany. I want to clip a state of Germany. In did a new polygon who doesnt overlap but it didnt help.

I get the error since i ran ccleaner. perhaps it deleted important temporary files.

i put these in front of the calculation:

arcpy.env.snapRaster = in_raster

arcpy.env.extent = arcpy.Describe(in_raster).extent

arcpy.env.cellSize= in_raster

arcpy.Clip_management(in_raster, "#", out_raster, shapef, "0", "ClippingGeometry", "NO_MAINTAIN_EXTENT")

0 Kudos
MarcGoetzke
New Contributor II

the error info:

Exception class: EZeroDivide

Exception message: Floating point division by zero.

Exception address: 00007FFE5C004C5D

0 Kudos