Forum

Author Topic: Exporting shapes in a different coordinate system  (Read 10171 times)

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Exporting shapes in a different coordinate system
« on: March 09, 2017, 05:00:48 PM »
Hello,
I'm currently willing to be exporting shapes in a different coordinate system than my project's.
My photos are in WGS 84 so are my dense clouds etc. but I can export them in Lambert 93 / CC 48 without any issue. The only exception is the shapefiles I have, is there any way to do it?

Some coworker suggested me to use ogr2ogr from GDAL but I don't really understand how.

Any help is appreciated.
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14010
    • View Profile
Re: Exporting shapes in a different coordinate system
« Reply #1 on: March 09, 2017, 05:03:58 PM »
Hello Thibaud,

Do you have a EPSG code for this system?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Exporting shapes in a different coordinate system
« Reply #2 on: March 09, 2017, 05:08:06 PM »
Hello Alexey,

Sure: Lambert 93 / CC48 code is EPSG::3948
« Last Edit: March 09, 2017, 05:17:58 PM by Thibaud Capra »
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14010
    • View Profile
Re: Exporting shapes in a different coordinate system
« Reply #3 on: March 09, 2017, 05:54:18 PM »
Hello Thibaud,

Then you probably should use the following:
Code: [Select]
crs = PhotoScan.CoordinateSystem("EPSG::3948")
chunk.exportShapes(path, projection = crs)
Doesn't it work correctly on your projects?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Exporting shapes in a different coordinate system
« Reply #4 on: March 13, 2017, 11:29:29 AM »
Hello Alexey,

On my projects, I choose the crs during the exports individually, ie. the orthomosaics are exported as follows:

Code: [Select]
        # Export Orthophoto
        path_ortho = path_export_chk + chunk.label + "_Ortho" + ".jpg"
        chunk.exportOrthomosaic(path_ortho, format = "jpg",
        raster_transform = PhotoScan.RasterTransformNone,
        projection = PhotoScan.CoordinateSystem("EPSG::3948"),
        write_world = True)

I tried using your code (PhotoScan version 1.2.6) and it's not working, projection = crs being and incompatible keyword. Here's my current code, more or less working. More less than more though, as I get the error message "Can't export shapes." when running it.

Any idea why?

Code: [Select]
import os
import PhotoScan

print(""">>> Initialisation du script IV <<<""")

doc = PhotoScan.app.document

path_export = PhotoScan.app.getExistingDirectory("""Spécifiez le dossier
 contenant les exports en fin de traitement""")
path_export += "\\"

print(""">>> Génération des fichiers de sortie <<<""")

for chunk in doc.chunks:
        # Create a new folder
        path_export_chk = path_export + "_SHP"
        if not os.path.exists(path_export_chk):
            os.makedirs(path_export_chk)
        path_export_chk += "\\"

        path_export_shp = path_export_chk + chunk.label
        if not os.path.exists(path_export_shp):
            os.makedirs(path_export_shp)
        path_export_shp += "\\"

        crs = PhotoScan.CoordinateSystem("EPSG::3948")
        chunk.exportShapes(path_export_shp)
       
        PhotoScan.app.update()

print(""">>> Fichiers exportés ! <<<""")

doc.save()

PhotoScan.app.update()
print(""">>> Script Partie IV terminé <<<""")
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Exporting shapes in a different coordinate system
« Reply #5 on: March 15, 2017, 01:11:34 PM »
Bumping topic, is it because my shapes are in a different layer that is not the default one?
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14010
    • View Profile
Re: Exporting shapes in a different coordinate system
« Reply #6 on: March 15, 2017, 01:23:11 PM »
Hello Thibaud,

In the version 1.2.6 it wasn't possible to specify the export coordinate system for shapes, so it has been exported in actual shapes.crs system.

In your code line crs = PhotoScan.CoordinateSystem("EPSG::3948") is meaningless, as crs variable is not utilized after that. But export problem seems to be related to the incorrect path specified. The last modification of the export path variable is path_export_shp += "\\" - it means that the path is not ending with the file extension, for example, ".shp", but is the path to the folder.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Exporting shapes in a different coordinate system
« Reply #7 on: March 15, 2017, 01:29:02 PM »
Hello Alexey,

I thought that since the exportShapes command created multiple files with different types, it did not require any extension for the path.

Thanks for your help, I'll run it ASAP and see if the fix works.
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14010
    • View Profile
Re: Exporting shapes in a different coordinate system
« Reply #8 on: March 15, 2017, 01:32:58 PM »
Hello Thibaud,

There could be additional files if you are saving in .shp format, but you still need to specify the full export path including filename to that .shp file.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Exporting shapes in a different coordinate system
« Reply #9 on: March 15, 2017, 01:39:24 PM »
Hello Alexey,

Thanks for the explicit answer!

To get my shapes in the coordinate system I want, could there be a way to get them by transforming the project's coordinate system from WGS84 to L93/CC48 before exporting the files? If so, how can I do it in 1.2.6 ?
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14010
    • View Profile
Re: Exporting shapes in a different coordinate system
« Reply #10 on: March 15, 2017, 02:00:28 PM »
Hello Thibauld,

Switching the coordinate system of the chunk wouldn't help, because the shape coordinate system is stored separately. I think the only way inside PhotoScan would be transforming the coordinates of every shape in the project from the source coordinate system to the new one.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Exporting shapes in a different coordinate system
« Reply #11 on: March 15, 2017, 02:05:17 PM »
Hello Alexey,

How would you do this in 1.2.6? I understood you can't change it during exports?
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14010
    • View Profile
Re: Exporting shapes in a different coordinate system
« Reply #12 on: March 15, 2017, 03:33:29 PM »
Hello Thibaud,

I would modify the coordinates of the shape vertices recalculating the coordinates from WGS84 to L93/CC48, then (when all the modifications are performed) re initialize shapes.crs to the new coordinate system and then export shapes.

For testing you can use a single simple shape.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Exporting shapes in a different coordinate system
« Reply #13 on: April 12, 2017, 07:06:49 PM »
Hello Alexey,

I'm kind of bumping this topic because I haven't figured out how to do it.

A simple piece of code exporting the shape from whatever his coordinate system is (here I believe it's WGS84) into L93/CC48 would do... Could you help me once again ?
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Thibaud Capra

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Exporting shapes in a different coordinate system
« Reply #14 on: April 13, 2017, 12:21:33 PM »
I guess I should use something the like of:

Code: [Select]
PhotoScan.Shapes.crs.transform(EPSG::4326, EPSG::3948)
PhotoScan.Shapes.crs.update

Then I'd export my shapes, right?
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--