Subscribe to this thread
Home - General / All posts - modifying coordsystem of linked images
ych6126 post(s)
#21-Mar-25 16:15

I have 668 linked jpeg2000 images. I need to modify the CenterLat and FalseNorthing and Name values for each 668 corresponding [mfd_meta] tables.

Issue : the linked jpeg2000 images have a CoordSystem definition Manifold does not cope with due to a CenterLat = 90 value.

In order to get the right CoordSystem the values of the CenterLat and FalseNorthing need to be changed imperatively. In order to avoid confusion I also modify the value of "Name".

The one thing that changes (668 times) is the corresponding source linkname

Source linknames are e.g. [OMWRGB24VL_K291n] , [OMWRGB24VL_K291z] or [OMWRGB24VL_K308n] ...

I have already this sql code written for 1 source (it is working well) > [OMWRGB24VL_K291n]::[mfd_meta].

-- SQL code

UPDATE [OMWRGB24VL_K291n]::[mfd_meta]

SET value = stringReplace(value,'"CenterLat": 90,','"CenterLat": 50.79936,')

WHERE PROPERTY = 'FieldCoordSystem.BGR'

UPDATE [OMWRGB24VL_K291n]::[mfd_meta]

SET value = stringReplace(value,'"FalseNorthing": 5400088.438,','"FalseNorthing": 165372.956,')

WHERE PROPERTY = 'FieldCoordSystem.BGR'

UPDATE [OMWRGB24VL_K291n]::[mfd_meta]

SET value = stringReplace(value,'"Name": "Belge 1972 \/ Belgian Lambert 72 (EPSG:31370)"', '"Name": "Belge 1972 \/ Belgian Lambert 72 ALTERNATE (EPSG:31370)",')

WHERE PROPERTY = 'FieldCoordSystem.BGR'

-- end code

I need to do this 668 times, and would like to avoid doing so manually.

What is the best flexible approach ? Each linked jpeg2000 image is approx. 264 MB.

a) merge all jpeg2000 images to 1 image, then consequently apply the changes needed . How can I merge all linked jpeg2000 images ?

b) keep the 668 jpeg2000 images separate and modify each corresponding [mfd_meta] table separately, by sql or script ?

Any ideas or coding is welcome !

Dimitri


7,558 post(s)
#22-Mar-25 06:22

There are many ways to automate what is, in effect, a search and replace of desired mfd_meta table properties. One way is a script.

In this thread, there is afixlayouts.cs script that goes through a project and for each layout checks if the properties need updating to new default properties (which were introduced in a newer build) and if so fixes them. It's a great illustrated example of how to do such things that should get you started on an adaptation to do the modifications you want. It also shows how to use an SQL expression within a script.

You could also organize your project to make it easier to loop through only those images you want to change. For example, you could put all the images to be fixed in a folder called jpegs and then that gives you a Folder property you can test with an if to see if it is jpegs when you iterate through images.

Dimitri


7,558 post(s)
#22-Mar-25 07:26

Here's the script as a project and also as a .cs file.

Attachments:
fixlayouts.zip

joebocop
537 post(s)
#18-Apr-25 00:26

Since I am dumb and can't seem to learn C# or the Manifold Release 9 object model I usually combine some brute-force ways of generating the SQL statements to do this sort of thing with linked components.

1) In the folder containing all your source files, on windows, run dir *.jpg /b > files.txt from a command prompt

2) open that text file, copy all the rows and paste into Excel or Google Sheets

3) Write your update statement in the cell next to the first file name, substituting the adjacent cell value or whatever, and terminate each statement with the semicolon, of course

4) Fill all the cells downward

5) Copy and paste those lines into a command window in manifold, and run

I use the same strategy to generate the SQL to create the Map component that has all the images. Then, you open the map and use "Edit --> Merge --> Merge Images", which is the easy part.

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