This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Valentijn,
Thanks for the quick respons. Could you tell us how we can extract the LATLON for each pixel using Jython?
Yes, past the following jython routine into your IDV user jython library (Menu: Edit->Formulas->Jython Libraries) def processImage (d): domain = d.getDomainSet() cs = domain.getCoordinateSystem() len = domain.getLength() #Pass in 0 as false so we don't copy the values rangeValues = d.getFloats(0) samples = domain.getSamples(0) latlon = cs.toReference(samples) print "len=",len for i in xrange(len): value = rangeValues[0][i] lat = latlon[0][i] lon = latlon[1][i]This gets the latlon values of the spatial domain and the image values and iterates through them.
To use this make a formula (Menu: Edit->Formulas->Create Formula) The name can be anything. the Fomula: needs to call the above procedure processImage(theImage) Now, you should have the formula show up in the Data Selector window.Now, load in some satellite imagery. Right click on the formula. You should see
a popup menu. One of the items is "Evaluate Formula". Select that. You will be prompted to select the value for the "theImage" parameter.Select *one time* from imagery. Do not select the "All Times" field since the
processImage routine is expecting one time.If you want to visualize the results of some processing we'll leave that to another day. (Basically, the above routine needs to create a new image data set and return it).
-Jeff