setting to data projection

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

setting to data projection

Post by joleenf »

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
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: setting to data projection

Post by bobc »

Hi Joleen -

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
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: setting to data projection

Post by joleenf »

Thanks Bob, this is incredibly helpful.

Joleen
Post Reply