Hello everyone,
Greetings!
Is there any API from where i can get complete data about ground_control_points?
like its pixel position,geo position etc.
I tired below code , it gives out only the names of ground control points.
product_name = ‘I:/Desktop/pavan/output.dim’
product = ProductIO.readProduct(product_name)
gcp_group = product.getGcpGroup()
print(gcp_group.getNodeCount())
for i in range(gcp_group.getNodeCount()):
gcp = gcp_group.get(i)
print(gcp)
Please do the needful
Best Regards
Pavan
ABraun
May 10, 2020, 4:59am
#2
From the gui perspective, the ground control point layer is empty by default. It is a container for user coordinates. Do you maybe mean the tie-point-grid? Reading bands and Tie Point Grids in snappy
1 Like
@ABraun Thanks for the reply
In my case we are having few ground_control_points that are manually added. I want to access these in my python code.
Is there any way to access these manually added GCP’s
PS: I am not looking for tie points
ABraun
May 10, 2020, 8:53am
#4
Sorry for the misunderstanding
1 Like
marpet
May 10, 2020, 11:13am
#5
You are actually on the right way, Pavan.
The gcp you get from the group is a Placemark (Api Doc ).
You can use getGeoPos()
, getPixelPos()
, getLabel()
and so on.
2 Likes
@marpet I get this above error while using the method you suggested.
Best Regards
Pavan
marpet
May 13, 2020, 1:08pm
#7
You call it on the group.
gcp = gcp_group.get(i)
gp = gcp.getGeoPos()
print(gp)
lat = gp.getLat()
lon = gp.getLon()
1 Like
@marpet i tried as you have suggested, still it is giving the attribute error because the variable gp is not Placemark java package.
Code Snippet:
from snappy import ProductIO
product_name = ‘I:/Desktop/pavan/output.dim’
product = ProductIO.readProduct(product_name)
gcp_group = product.getGcpGroup()
for i in range(gcp_group.getNodeCount()):
gcp = gcp_group.get(i)
gp = gcp.getGeoPos()
print(gp)
lat = gp.getLat()
lon = gp.getLon()
marpet
May 14, 2020, 5:22am
#9
Ah, I forgot that this diesn’t work directly in Python.
You need to cast the gcp first.
Do this once at the beginning of your script:
Placemark = jpy.get_type('org.esa.snap.core.datamodel.Placemark')
Then you can later do:
node = gcp_group.get(i)
gcp = snappy.jpy.cast(node, Placemark)
gp = gcp.getGeoPos()
1 Like
@marpet Thankyou so much it works now