AnsweredAssumed Answered

Different results when running arcpy outside ArcMap?

Question asked by JamesRamm on Oct 9, 2014
Latest reply on Jun 8, 2017 by curtvprice

I am trying to run ZonalStatisticsAsTable using python.


I have a feature class in a FGDB and a raster within an SDE database (SQL Server).


If I load these into layers within arcmap, open the python console (within arcmap) and execute:


arcpy.CheckOutExtension("Spatial")"Site Boundary\Site", "Site", "sde_jbacfm.JBAGISEDITOR.River09Q1000D", "TempTable")

I get a table of results.


If I run this code, from a python console outside of arcmap:



import arcpy

# In these filepaths I have purposefully replaced the full path with '...' for clarity. This is just for this example
arcpy.env.workspace = r"C:\...\Output.gdb" # This is an empty geodatabase initiated with a WGS84 projection

input_feat = r"C:\...\SitePolygon.gdb\Site Boundary\Site"
raster = r"C:\...\connection.sde\sde_jbacfm.JBAGISEDITOR.River09Q1000D"
output = "TempTable", "Site", raster, output)


This works but I get an entirely different result for the statistics.


I am trying to work out what is going on? The only thing I can think of is that the projection of each input (and the output database) is different, but I had understood that arcpy would handle different projections automatically?


In any case, I would still expect to get the same result using python through arcmap as I did not reproject anything there either.