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")
arcpy.sa.ZonalStatisticsAsTable(r"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
arcpy.CheckOutExtension("Spatial")
# 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"
arcpy.sa.ZonalStatisticsAsTable(input_feat, "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.