Subscribe to this thread
Home - General / All posts - Scripting Image Merge: Resolved
joebocop
537 post(s)
#18-Apr-25 00:17

Ok so I figured this out (Scripting Image Merge). Adamw was correct in questioning the coordinate system of the data sources. Perhaps you already knew this.

The Sheet in my original post creates the Manifold SQL to 1) create all the data sources, and 2) create a map from all the Image components exposed by those data sources. From there, the "Edit --> Merge --> Merge Images" functionality was producing an empty table for me.

What I was missing was correctly assigning the coordinate system to each of the data source image components prior to attempting the merge automation.

We can do that with SQL by updating the mfd_meta table for each of the data sources. With that done, we can open the Map component and successfully execute the merge.

So the full SQL to get the map file correctly created and ready to process with "Edit --> Merge --> Merge Images" looks like this:

CREATE DATASOURCE [5367045_BE] (

 PROPERTY 'Source' '{ "Source": "C:\\\\Users\\\\getin\\\\Downloads\\\\ASCII\\\\5367045_BE.txt", "SourceCacheExternal": true }'

 PROPERTY 'Type' 'xyz'

 PROPERTY 'Folder' 'be_ascii');

CREATE DATASOURCE [5367046_BE] (

 PROPERTY 'Source' '{ "Source": "C:\\\\Users\\\\getin\\\\Downloads\\\\ASCII\\\\5367046_BE.txt", "SourceCacheExternal": true }'

 PROPERTY 'Type' 'xyz'

 PROPERTY 'Folder' 'be_ascii');

-- etc, etc, etc..... for the 150 files on this project (takes 0 seconds), then

UPDATE [5367045_BE]::[mfd_meta] SET [Value] = 'EPSG:26907,mfd:{ "LocalOffsetX": ' & StringJsonValue([Value]'LocalOffsetX'FALSE) & ', "LocalOffsetY": ' & StringJsonValue([Value]'LocalOffsetY'FALSE) & '}' WHERE [Property] = 'FieldCoordSystem.Tile';

UPDATE [5367046_BE]::[mfd_meta] SET [Value] = 'EPSG:26907,mfd:{ "LocalOffsetX": ' & StringJsonValue([Value]'LocalOffsetX'FALSE) & ', "LocalOffsetY": ' & StringJsonValue([Value]'LocalOffsetY'FALSE) & '}' WHERE [Property] = 'FieldCoordSystem.Tile';

-- etc, etc, etc..... for each of the data sources created (takes 90 seconds for my 150 files), then generate the map like

CREATE MAP [Map] (

 PROPERTY 'CoordSystem' 'EPSG:26907'

 PROPERTY 'Item.0' '{"Entity": "[5367045_BE]::[5367045_BE]", "Group": 1, "Z":1}'

 PROPERTY 'Item.1' '{"Entity": "[5367046_BE]::[5367046_BE]", "Group": 1, "Z":2}'

 [ETC, ETC, ETC]

 PROPERTY 'Item.150' '{"Folder": "ascii_be", "Group": 0, "Z": 0 }');

danb

2,085 post(s)
#21-Apr-25 00:42

Thanks for posting. Always useful to know. Do you know how to do the ...

"Edit --> Merge --> Merge Images"

bit from SQL or script? It would be great to fully automate this process.


Landsystems Ltd ... Know your land | www.landsystems.co.nz

joebocop
537 post(s)
#22-Apr-25 03:33

I haven't sorted that out, no. Adamw's original response indicates it's not currently possible to do this in pure SQL, so I'm betting this can be accomplished with the API, I just haven't yet gotten my head around it (not a Manifold problem, that).

There's some very recent discussion here from Dimitri around how Release 9's API follows a modern approach of reading and writing values inside Tables, which probably means there actually IS (going to be?) a way to do these sorts of operations on an arbitrary number of components in SQL alone.

apo
193 post(s)
#22-Apr-25 07:33

assuming that all the components you want to merge are in the same system and share the same resolution, I was able to insert the tiles of each in a new table taking care to modify the x and y index values according to the component's min value. This presupposes that you have identified the min values over all components, so that you can then inject the correct coordinate system parameters.

I used this approach for my recursive process of cutting a part of dem, sending it to a powershell script and getting the result back to be injected in a result table as described here

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.