Forum

Author Topic: Batch exporting all products in a chunk  (Read 556 times)

p_pereira

  • Newbie
  • *
  • Posts: 3
    • View Profile
Batch exporting all products in a chunk
« on: March 22, 2024, 02:28:11 PM »
Hello all,

I have a big project coming and I've been preparing for it. So far I've encountered some problems, many of them probably resulting of my inexperience in some topics.

This is the current situation I'm on:

I have a chunk with a LAS imported. For each LAS I'll need to create: ortho, DEM and DSM. As you see in the Image_1 there's also a shape. This shape contains a grid with areas of 1sq kilometers. Given the data volume, exporting every product manually would take a lifetime as for each square kilometer I'll need to export 3 products from Metashape (DEM, DSM and ortho).

So my idea is to import a LAS that cover a considerable amount of squares and make a big product and then clip it by the grid. At this stage I'm trying scripting but I'm a bit limited by my knowledge.

I've been using a script I found looking around the forum (from the user Paulo if I'm not mistaken), and it kind of meets my needs: I can currently export the DEM and ortho with the script.

The first problem: when exporting, I can only export one of the DEMs and the orto (as you can see in Image_1, theres two DEM's I need to export both with the script but i can only do it if I export one of them first, then select the other and run the script again. This would work but given the volume I would like to know if I can export both "DEMs" at the same time and also the ortho.

The second problem: as for the products exported (DEM/DSM and ortho) there seems to be a problem with the clipping (Image_2). Basically when I export the files (I've tried manually exporting also) it seems that i get a pixel (not the same size in both sides) cut off in the right and bottom side of the products (the red line in the Image_2 is the grid used to clip the export). However this is not the only problem, the ortho and DEM are exporting in different sizes. From my understanding it might be related to the pixel size when generating (?) but the thing is that these products have specific characteristics and one of them is the pixel being 25cm for the ortho and the DEM.

Any help would be appreciated.

Thanks in advance.

*I hope the user doesn't mind but I'll also attach the script in this topic*

Image_1


Image_2
« Last Edit: March 25, 2024, 09:26:01 PM by p_pereira »

Paulo

  • Hero Member
  • *****
  • Posts: 1350
    • View Profile
Re: Batch exporting all products in a chunk - Various Topics
« Reply #1 on: March 22, 2024, 03:46:26 PM »
Hello p_pereira,

for your second problem. To avoid having a gap at right and bottom, of each exported product, you must assure that the grid size (length and width) is an exact multiple of your resolution. Fo a square grid of 1km by 1km and resolution of 25 cm by 25 cm then there should be no gap  as:
Code: [Select]
1 km = 1000 m divided by 25 cm is exactly 4000but if grid is 1000.1 m by 1000.1 m then there will be a gap of 10 cm at right and bottom...

For first problem. script could be modified looping thru all dems in chunk....

Best Regards,
Paul Pelletier,
Surveyor

p_pereira

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Batch exporting all products in a chunk - Various Topics
« Reply #2 on: March 22, 2024, 05:43:35 PM »
Hello p_pereira,

for your second problem. To avoid having a gap at right and bottom, of each exported product, you must assure that the grid size (length and width) is an exact multiple of your resolution. Fo a square grid of 1km by 1km and resolution of 25 cm by 25 cm then there should be no gap  as:
Code: [Select]
1 km = 1000 m divided by 25 cm is exactly 4000but if grid is 1000.1 m by 1000.1 m then there will be a gap of 10 cm at right and bottom...

For first problem. script could be modified looping thru all dems in chunk....

Hello Paulo,

Thanks a lot for the answer. My second problem goes accordingly to what I was thinking.

For my first problem, since I don't know how to write programming languages (very limited syntax), could you give me some help on the looping? Is the code complex?

Thanks in advance (and thanks for the base script, very useful).

Paulo

  • Hero Member
  • *****
  • Posts: 1350
    • View Profile
Re: Batch exporting all products in a chunk - Various Topics
« Reply #3 on: March 22, 2024, 06:09:39 PM »
Hi pereira,

if I understand you have 2 dems to export for every shape. SO if you a loop over all dems in chunk then it could export 2 dems for each shape..

named something like DEM1_shapelabel.tif and DEM2_shapelabel.tif...

look at attachment if this can be ok...
Best Regards,
Paul Pelletier,
Surveyor

p_pereira

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Batch exporting all products in a chunk - Various Topics
« Reply #4 on: March 22, 2024, 07:53:36 PM »
Hi pereira,

if I understand you have 2 dems to export for every shape. SO if you a loop over all dems in chunk then it could export 2 dems for each shape..

named something like DEM1_shapelabel.tif and DEM2_shapelabel.tif...

look at attachment if this can be ok...

Hello Paulo, once again thanks for the answer.

I tested the script and it runs smoothly, just as expected.

Thanks very much.