Krig result differences help

840
3
10-09-2012 03:16 AM
JamesCrandall
MVP Frequent Contributor
ArcGIS 9.3.1
Python 2.5

I am getting differences in raster outputs when a point layer is run thru Kriging process via the Spatial Analyst toolbar/extension and when run in code (Python 2.5).  I am wondering if there are some default values the SA tool uses when no values are present in the dialog.

There are only 2 inputs I am attempting: Semivariogram model: Ordinary/Linear and Output Cell Size: 528 (the Lag size gets set to this as well).  Everything remains the same in the Python code I am using but the output raster is MUCH smoother than the output generated by the Python code.

Even after reclassifying the output raster, it is still very coarse in comparison to the output (temporary) raster that gets generated by the SA tool.

Any input is much appreciated!

def genContourKRIG(inPTS, zfld):
    try:
        # Set the output workspace name
        path = oLoc #os.path.expanduser("~")
        gp.Workspace = path
        
        rastername = str(gp.GetParameter(1))
        gp.overwriteoutput = 1
        
        # Set the input feature dataset
        inputFeatureDataset = inPTS
    
        # Set the output raster name
        if rastername !="":
           outputRaster = rastername
        else:
           outputRaster = "Krig_1" 
        
        # Don't write out the variance raster
 Output_variance_of_prediction_raster = ""
       
        # Set the output extent
        desc = gp.describe(inPTS)
        xmin = 877223.554167 #desc.Extent.XMin #hard-coded for now
        ymin = 368517.887500 #desc.Extent.YMin #hard-coded for now
        xmax = 877223.554167 #desc.Extent.XMax #hard-coded for now
        ymax = 368517.887500 #desc.Extent.YMax #hard-coded for now
              
        gp.Extent = "877223.554167 368517.887500 877223.554167 368517.887500" #hard-coded for now
        
        # Set the attribute field
        attributeName = zfld
    
        # Check out Spatial Analyst extension license
        gp.CheckOutExtension("Spatial")
        
        # Process: Kriging...
        gp.Kriging_sa(inputFeatureDataset, attributeName, outputRaster, "Linear", "528", "VARIABLE 12", Output_variance_of_prediction_raster)

    except:
        # If an error occurred while running a tool, then print the messages
        gp.AddMessage(gp.GetMessages())
0 Kudos
3 Replies
JamesCrandall
MVP Frequent Contributor
[ATTACH=CONFIG]18288[/ATTACH]

[ATTACH=CONFIG]18289[/ATTACH]

Images attached to show differences I am seeing.  First image Krige was run from SA toolbar.  Second image is from Python code.
0 Kudos
EricRice
Esri Regular Contributor
That looks like a display issue. Check the resampling on each in the layer properties. I bet one is nearest neighbor (the blocky one), and one is bilinear. Another way to see if you got different answers is to just subtract one from the other. You should get all zero's.

Best,
Eric
0 Kudos
JamesCrandall
MVP Frequent Contributor
That looks like a display issue. Check the resampling on each in the layer properties. I bet one is nearest neighbor (the blocky one), and one is bilinear. Another way to see if you got different answers is to just subtract one from the other. You should get all zero's.

Best,
Eric


Eric,

Thanks for your input.  I did check the resampling property and you were correct that it was set differently for the output generated by the Python code.  Although I am not sure this was the complete reason for my issue --- the cell size @528 was ok in the SA tool but when I changed the cell size to 50 (from 528) in the Python script and it generated a much closer representation of what gets built by the SA defaults.

Basically, I just set the Semivariogram model to Linear (as needed) and the new cell size:


gp.Kriging_sa(inputFeatureDataset, attributeName, outputRaster, "Linear", "50.00995", "VARIABLE 12", Output_variance_of_prediction_raster)



Thanks a bunch for your help!
0 Kudos