I want to use ArcPy and pycharm to do zonal statistics. When I loaded shapefile just as I did in the python console in arcgis, the pycharm identifies the shapefile as string type and I got the ERROR 000865: Input value raster: D:/target/New File Geodatabase.gdb\elev does not exist. So how to fix this? Below is my code:

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.workspace = "D:/target/New File Geodatabase.gdb"
featureClass = "D:/target/New File Geodatabase.gdb/target"
inZoneData = "target.shp"   # shapefile
zoneField = "FID"           # the FID field of target shapefile
inValueRaster = arcpy.Raster("elev.img")
outZonalStatis1 = arcpy.sa.ZonalStatistics(inZoneData,"Id",inValueRaster,"MAXIMUM")
  • Is your raster in a file geodatabase or is it in the folder that holds your file geodatabase? If the latter try moving it and giving a full pathname to it. – PolyGeo May 10 '19 at 3:06
  • Thank you. The raster is in a file geodatabase and it could be loaded properly. The problem is loading the shapefile (target.shp). It was loaded as a string rather than a feature or shapefile. – Ying Tian May 10 '19 at 3:17
  • Can you include a picture of the Catalog window showing your file geodatabase with your raster in it? – PolyGeo May 10 '19 at 3:33
  • 3
    You are setting the workspace to a geodatabase, so arcpy will look for all inputs and output all outputs to the database unless you specify full paths, for example inZoneData = r"C:\somefolder\target.shp" – BERA May 10 '19 at 5:40

Your Answer

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

Browse other questions tagged or ask your own question.