Forum

Raster Transformation (EPSG 4326 to 2154) in Python

Started by Sylvain M., July 29, 2024, 05:50:26 PM

Previous topic - Next topic

Sylvain M.

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?

chunk.exportRaster(ortho_folder, source_data = Metashape.OrthomosaicData)

Thank you in advance for your help!  :)

Alexey Pasumansky

Hello Sylvain,

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


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.

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.

@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

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