Forum

Author Topic: Raster Transformation (EPSG 4326 to 2154) in Python  (Read 4997 times)

Sylvain M.

  • Newbie
  • *
  • Posts: 13
    • View Profile
Raster Transformation (EPSG 4326 to 2154) in Python
« on: July 29, 2024, 05:50:26 PM »
Further to this thread, I'm opening a new thread about reprojecting an Orthomosaic via Metashape's Python module.

I have an orthomosaic in WGS 84 (EPSG 4326), which I'd like to export in Lambert 93 (EPSG 2154).

I haven't found the right syntax for this kind of task.

Could you help me adapt this part of my code?

Code: [Select]
chunk.exportRaster(ortho_folder, source_data = Metashape.OrthomosaicData)
Thank you in advance for your help!  :)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15366
    • View Profile
Re: Raster Transformation (EPSG 4326 to 2154) in Python
« Reply #1 on: July 29, 2024, 06:00:08 PM »
Hello Sylvain,

I think that the following approach should work for your needs:

Code: [Select]
proj = Metashape.OrthoProjection()
proj.crs = Metashape.CoordinateSystem("EPSG::2154")
chunk.exportRaster(path, source_data = Metashape.OrthomosaicData, projection = proj)
Best regards,
Alexey Pasumansky,
Agisoft LLC

Sylvain M.

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Raster Transformation (EPSG 4326 to 2154) in Python
« Reply #2 on: July 29, 2024, 06:21:55 PM »
Thank you Alexey!
That's pretty much what I came up with!
I can't test it right now as my workstation is locked on heavy processing, but I think it should work! (if not, I'll come back here  ;))

Sylvain M.

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Raster Transformation (EPSG 4326 to 2154) in Python
« Reply #3 on: July 30, 2024, 11:29:13 AM »
@Alexey Pasumansky
Related to this thread, do you think it's better to reproject when exporting the orthomosaic, or directly when building it (and therefore also reproject the DEM)?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15366
    • View Profile
Re: Raster Transformation (EPSG 4326 to 2154) in Python
« Reply #4 on: July 30, 2024, 03:30:40 PM »
Hello Sylvain,

From my experience it is better to generate all the assets in the same system that is used for georeferencing. I mean, if you have control points (and/or camera locations) in certain system, then it is better to generate all the processing products in the same system and also draw the shapes, if needed, in the same system as well. But on export you can choose a different system. I assume that it is more convenient, because you can choose datum transformation parameters same for all the products.

Another approach is to convert the coordinates of the reference points in Metashape to the desired system prior to the data processing and in such way get the results in the desired system by default.
Best regards,
Alexey Pasumansky,
Agisoft LLC