Hi,
Is there a way to set the projection of a display to the data projection from scripting without relying on auto-set projection being set to true in the default preferences? Conversely, is there a way to verify that auto-set projection is either on or off from scripting?
Thanks,
Joleen
setting to data projection
Re: setting to data projection
Hi Joleen -
To return the current state of auto-set projection in a display, you can use getUseProjectionFromData():
Assuming this returns True, you can set it to False with setUseProjectionFromData():
Now that you have auto-set projection disabled, you can go and display some data, for example:
This displays the data w/o reprojecting it, since auto-set projection was disabled. If you are interested, you can print out the native projection of the layer with getDataProjection():
To set the display to use the projection of the layer, you can use setProjection() and pass through the name of the layer:
I will add a note to the documentation of setProjection() that along with passing in a projection in the Projections>Predefined menu, you can also pass through a layer object.
Please let me know if you have any questions about this.
- Bob Carp
To return the current state of auto-set projection in a display, you can use getUseProjectionFromData():
Code: Select all
panel = buildWindow()
print panel[0].getUseProjectionFromData()
Assuming this returns True, you can set it to False with setUseProjectionFromData():
Code: Select all
panel[0].setUseProjectionFromData(False)
Now that you have auto-set projection disabled, you can go and display some data, for example:
Code: Select all
data = loadADDEImage(server='adde.ucar.edu', dataset='RTIMAGES', descriptor='GE-IR', size='ALL')
layer = panel[0].createLayer('Image Display', data)
This displays the data w/o reprojecting it, since auto-set projection was disabled. If you are interested, you can print out the native projection of the layer with getDataProjection():
Code: Select all
print layer.getDataProjection()
To set the display to use the projection of the layer, you can use setProjection() and pass through the name of the layer:
Code: Select all
panel[0].setProjection(layer)
I will add a note to the documentation of setProjection() that along with passing in a projection in the Projections>Predefined menu, you can also pass through a layer object.
Please let me know if you have any questions about this.
- Bob Carp
Re: setting to data projection
Thanks Bob, this is incredibly helpful.
Joleen
Joleen