Hi,
I took this code from another post (Luke Lynx; Run MapInfo Raster Clip operation through python) and updated it for my version of MI Pro (21.3) and am getting the following error and would greatly appreciate some guidance. It appears to be related to the file extension. Kathy
ERROR:
RasterException : Invalid file extension.
at MapInfo.RasterEngine.Common.MIRasterError.VerifyRetValue(Int32 iRetVal)
at MapInfo.RasterEngine.Operations.RasterProcessing.Clip(String inputRasterFilePath, String inputTabFilePath, String outputRasterFilePath, String outputRasterDriverID, Boolean retainInsideRegions, RasterApiOptions apiOptions, IRasterProgressTracker progressTracker)
CODE:
#Raster Clip Operation using Tab File Input
import string
import clr
import os
import sys
from os.path import abspath, join, dirname, exists
sys.path.insert(0,"C:\\Program Files\\MapInfo\\Professional\\Raster")
clr.AddReference("MapInfo.RasterEngine.IO")
clr.AddReference("MapInfo.RasterEngine.Common")
clr.AddReference("MapInfo.RasterEngine.Operations")
from MapInfo.RasterEngine.Operations import RasterProcessing
from MapInfo.RasterEngine.Common import RasterInputDetails, RasterApiOptions, RasterClipExtent
from MapInfo.RasterEngine.IO import DriverIDExtensions, DriverID
#Input and output file path
rasterInput = r"C:\\path_to_input\\filename.mrr"
rasterOutput = r"C:\\path_to_output\\output_filename.mrr"
outputRasterDriverID = DriverIDExtensions.GetString(DriverID.ASC)
tabInput = r"C:\\path_to_geometry_to_clip raster_to\\Vermont.tab"
retainInsideRegion = True
apiOptions = RasterApiOptions(RasterClipExtent())
RasterProcessing.Clip(rasterInput, tabInput, rasterOutput, outputRasterDriverID, retainInsideRegion,
------------------------------
Kathy Gillis
AT&T
SAN RAMON OR
------------------------------