Changing Image Layer Extents Programatically in TIBCO Spotfire® using IronPython Scripting
Last updated:
7:14am Jan 08, 2019

Back to main IronPython Scripting page

Introduction

The following provides an example of how to change the extents for an Image Layer in Map Visualizations using IronPython. Credit to Shandilya Peddi for this solution.

Code Sample

# Copyright © 2019. TIBCO Software Inc. Licensed under TIBCO BSD-style license.

from Spotfire.Dxp.Application.Visuals import *
from Spotfire.Dxp.Application.Visuals.Maps import *
from Spotfire.Dxp.Application.Visuals import PieMarker

# Set 'v' as your map visualization in Script Parameters
map=v.As[MapChart]()

# Set Extents
Xmin=-150
Xmax=-50
Ymin=20
Ymax=50

# Find Image Layer and apply extents
i = -1 
for layer in map.Layers:
    i = i+1
    if layer.Title == "Image Layer":
        imageLayer=Application.GetService(Maps.ImageLayer)
        imageLayer=layer
        # Use 'Projection.None' for no CRS projection
        # Use 'Projection.WebMercator' for EPSG 3857 projection
        # Use 'Projection.Wgs84' for EPSG 4326 projection
        myExtent = GeographicExtent.Create(Projection.Wgs84, Xmin, Ymin, Xmax, Ymax)
        imageLayer.SetExtent(myExtent)

 

Bonus

Set extents through Document Properties to easily adjust values with sliders, input fields, etc. Create a Document Property for Xmin, Xmax, Ymin, Ymax and then replace lines 9-13 in code with:

# Set Extents
Xmin=Document.Properties["Xmin"]
Xmax=Document.Properties["Xmax"]
Ymin=Document.Properties["Ymin"]
Ymax=Document.Properties["Ymax"]

 

References

None

License: TIBCO BSD-Style License