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. # Author - Neil Kanungo & Shandilya Peddi, TIBCO Software, January 2019 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 (input your own here) Xmin=-150 #West Xmax=-50 #East Ymin=20 #South Ymax=50 #North # 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
Recommended Comments
There are no comments to display.