AnsweredAssumed Answered

arcpy.Clip_management having different output from using Python and not

Question asked by zxy1219 on Apr 6, 2016
Latest reply on Apr 7, 2016 by akk602dev


Dear All,

 

I use the Clip in the Raster Processing to clip some grid from a raster file. But the outputs are different from using Python or not.

Here is my code:

 

import arcpy
import os
from arcpy import env


# Set environment settings
env.workspace = "C:/data"


# Clip the layer, remove the points located outside of Texas boundary
output_path="C:/NDVI/2012/"


# Read datafiles for clip
in_path = "C:/NDVI_data/2012/MOD13A3_out/"
shp_list = []
date_id = []
tile_id = []
for dirpath, dirnames, files in os.walk(in_path):
for f in files:
  if f.lower().endswith("_reproj.dat"):
   fullpath = os.path.join(dirpath, f)
   shp_list.append(fullpath)
   date_id.append(f[9:16])
   tile_id.append(f[17:23])


# Count the elements in shp_list
N=len(shp_list)


# Clip raster
for i in range(0,1):
in_raster = shp_list[i]
out_feature = "NDVI_clip"+date_id[i]+tile_id[i]
Rectangle = "-106.928314 25.611530 -93.605938 35.355261"
Clip_feature = "C://PM_Site/IMPROVE_2011_1km_albers.shp"
arcpy.Clip_management(in_raster,Rectangle,out_feature, Clip_feature,"-999","ClippingGeometry","MAINTAIN_EXTENT")

 

And the output looks like this:

 

But if I don't use the Python.

The output is looks like this:

Why there are two grids missing by using the Python?

 

I will really appreciate your help!

 

Sue-ying

Outcomes