6

I'm using ArcMap 10.3.1

When I use the gp tool to extract by mask, I get the correct result with any area outside the mask set as NoData.

When I do the same thing in a script, I end up with cells with other values outside the mask. gp result then script result

Note the values within the mask are correct, the stretching is different because the black cells outside the mask have a value of -32768 (the minimum value in a 16 bit signed raster).

It looks like something to do with tiling?

Note when using the gp tool, I get the message "WARNING 000632: Datum conflict between map and output." I don't know if this is relevant?

Below is my script.

Any ideas?

import arcpy
from arcpy import sa as sa
ws = 'c:/temp/test/'
arcpy.env.workspace = ws
outMask = sa.ExtractByMask('band2.tif', 'Clip109071.shp')
outMask.save('band2clipped.tif')
  • 1
    Set environment extent, snap raster and cell size 'equal' parent raster and output to grid stored in folder. – FelixIP Sep 18 '17 at 4:25
  • Thats very interesting. Im guessing that you have reprojected the image on the fly, then created a mask shp. The Shp would then have a different datum. My next guess is then that using the GP tool by picking from a layer in the dataframe actually uses a reprojected temp file for that layer, not the original file. So no conflict, but the script uses the original and so there is a conflict. I cannot find any reference to this on the web, but it would be easy to test - run the GP tool but select from the original file not the layer. I would be really interested to hear what happens. – AnserGIS Sep 19 '17 at 19:24
4
+100

I repeated your script line by line from Python window.

OUTPUT: enter image description here

I removed 2 lines in your script and added:

d=arcpy.Describe('Clip109071.shp')
arcpy.env.extent=d.extent
outMask = sa.ExtractByMask('band2.tif', 'Clip109071.shp')
outMask.save('asGrid')

OUTPUT:

enter image description here

is what one expects to see.

So exporting to grid format fixed the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.