Forum

Author Topic: Get center coordinates  (Read 6389 times)

r0xx

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Get center coordinates
« on: May 15, 2015, 11:13:56 AM »
How can I get the center coordinates from the project and set them to the same coordinates but with another bounding box size?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14851
    • View Profile
Re: Get center coordinates
« Reply #1 on: May 15, 2015, 01:43:23 PM »
Hello r0xx,

Could you please provide additional info on this matter? I just don't get what task you are trying to solve.
Best regards,
Alexey Pasumansky,
Agisoft LLC

r0xx

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Get center coordinates
« Reply #2 on: May 15, 2015, 01:49:01 PM »
I am trying to automatically export mesh files in different sizes.
So for example I have a grid with center coordinates (in coordinate system 21781) and generate the dense cloud with a bounding box size of 1 km.
How could I get the center coordinates of the current bounding box, set the size of the bounding box to 500 meter, generate a new mesh, export this mesh and do the same thing again with 250 meters?

Basically I have all the parts except how I can get the center coordinates from the current bounding box.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14851
    • View Profile
Re: Get center coordinates
« Reply #3 on: May 15, 2015, 02:12:28 PM »
Hello r0xx,

You can use the following script as a reference:
http://wiki.agisoft.com/wiki/Split_in_chunks.py

In splitChunks() function copies of the original chunk are created with the different bounding box.

Note that chunk.region.center is in the internal coordinate system, so if you wish to use geographic coordinates you need to convert them to the internal system:

chunk.transform.matrix.inv().mulp(chunk.crs.unproject(point)), where point is PhotoScan.Vector with geographic coordinate system values.
Best regards,
Alexey Pasumansky,
Agisoft LLC

r0xx

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Get center coordinates
« Reply #4 on: May 15, 2015, 06:19:40 PM »
This is what I'm using at the moment but this doesn't work:

doc = PhotoScan.app.document

  # Get the current chunk
  chunk  = doc.chunk
 
  c = chunk.region.center
  centerCoords = chunk.transform.matrix.inv().mulp(chunk.crs.unproject(c))

  # Get center coordinates
  print("Center Coordinates: " + str(centerCoords))

This does output some other coordinates... What is wrong with the code?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14851
    • View Profile
Re: Get center coordinates
« Reply #5 on: May 15, 2015, 06:20:46 PM »
Hello r0xx,

chunk.region.center coordinates are already in internal system, they are not geographic.
Best regards,
Alexey Pasumansky,
Agisoft LLC

r0xx

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Get center coordinates
« Reply #6 on: May 18, 2015, 09:49:54 AM »
Ok thank you. And how can I print the geographic coordinates now?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14851
    • View Profile
Re: Get center coordinates
« Reply #7 on: May 18, 2015, 11:16:49 AM »
Hello r0xx,

To print geographic coordinates of the region center you can use the following:

Code: [Select]
chunk.crs.project(chunk.transform.matrix.mulp(chunk.region.center))
Best regards,
Alexey Pasumansky,
Agisoft LLC

r0xx

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Get center coordinates
« Reply #8 on: May 18, 2015, 01:51:02 PM »
Awesome thanks alot!