Thank you for the code example, it worked . It was my primaryIndex parameter that had to be forced with Uint32()
Original Message:
Sent: 08-19-2020 00:17
From: Anshul Goel
Subject: Raster SDK merge method in Python
Hi Seydou,
Try the below sample code for raster Merge operation.
import clr
import sys
from os.path import abspath, join, dirname, exists
from System import UInt32
clr.AddReference("MapInfo.RasterEngine.IO")
clr.AddReference("MapInfo.RasterEngine.Common")
clr.AddReference("MapInfo.RasterEngine.Operations")
from MapInfo.RasterEngine.IO import DriverIDExtensions, DriverID
from MapInfo.RasterEngine.Operations import RasterProcessing
from MapInfo.RasterEngine.Common import MergeType, RasterResampleMethod, MergeOperator, RasterCreationOptions, MergeMultiResolutionMode
from MapInfo.RasterEngine.Common import RasterApiOptions, RasterCompressionType, RasterCompressionOptions, RasterEnvelope
cwd = dirname(__file__)
inputFile1 = abspath(join(cwd, "..\\Data\\SeattleElevation.grd"))
inputFile2 = abspath(join(cwd, "..\\Data\\seattleelevation_shifted_reprojected.grd"))
outputFile = abspath(join(cwd, "..\\Data\\SeattleMerge.mrr"))
outputFileTab = abspath(join(cwd, "..\\Data\\SeattleMerge.tab"))
inputFiles = [inputFile1, inputFile2]
mergeOffset = [0.0, 0.0]
primaryRasterIndex = UInt32(0)
outputRasterDriverID = DriverIDExtensions.GetString(DriverID.MRR)
mergeOperator = MergeOperator.Stamp
mergeType = MergeType.Union
rasterResampleMethod = RasterResampleMethod.Nearest
creationOptions = RasterCreationOptions(RasterCompressionOptions(RasterCompressionType.LZMA, 5), -1)
apiOptions = RasterApiOptions()
apiOptions.CreationOptions = creationOptions
rasterEnvelope = RasterEnvelope(501971.54, 5233455.52, 584719.71, 5304829.39)
RasterProcessing.Merge(inputFiles, primaryRasterIndex, outputFile, outputRasterDriverID,
mergeOperator, mergeType, rasterResampleMethod, False, MergeMultiResolutionMode.OptimumMinimum ,
rasterEnvelope, apiOptions, None)
if exists(outputFile) and exists(outputFileTab):
print('merged!')
table = pro.Catalog.OpenTable(outputFileTab)
if table:
do('map from {}'.format(table.Alias))
Thanks
Anshul
------------------------------
Anshul Goel
Knowledge Community Shared Account
Shelton CT
Original Message:
Sent: 08-18-2020 10:01
From: Seydou DiopMena
Subject: Raster SDK merge method in Python
Hi everyone,
I am testing the python integration in MapInfo and I was trying to use the method merge (MapInfo.RasterEngine.Operations ) but I get this error :
"TypeError : No method matches given arguments for Merge: (<class 'list'>, <class 'int'>, <class 'str'>, <class 'str'>, <class 'int'>, <class 'int'>, <class 'int'>)"
It seems my input parameters are at fault, however since there is no python documentation I don't kow which one of the parameters is not correct.
I was trying to replicate the same parameters as the one that are on the .NET documentation :
This is my code :
"
RasterProcessing.Merge(gridList,0, strOutFilePath, DriverIDExtensions.GetString(DriverID.MRR),2, 0, 2)
variable gridList is a list of strings and the variable strOutFilePath is a string
"
My questions are :
-Does somebody have an example of the merge method used in python ?
-Does anybody knows the exact python data type that need ot be put in parameters for the merge method ?
Thanks in advance !
Seydou
------------------------------
Seydou DiopMena
KOREM
Quebec QC
------------------------------