National Oceanic and
Atmospheric Administration
United States Department of Commerce

Values associated with pixels

Values associated with pixels

Question:

Is there any way to plotthe value of each pixel on the plot?

Example:

 

Explanation:

Actually, there are two different ways to get values associatedwith pixels.

  • The method displayed above uses brute force to display the value of every grid cell in a particular region. An example script for this plot is given below.
  • The second method is to use the digitize.jnl script which allows you to mouse click on a pixel and obtain that pixels value and, optionally, surrounding values.

Solution:

! etopo5 is a 5 minute bathymetry
use etopo5

! a region of the Indonesian through flow
set region/x=118:120/y=-6:-4

! I could use the repeat command with /x= and /y= but then
! Ferret would be interpolating so I'd like to find out what
! indices are associated with the region of interest. Then
! the plotted values will lie on top of the grid cells. 
! Lets notate just some of the values, a 1x1 degree box.

let i1 = i[gx=rose,x=118.5]
let i2 = i[gx=rose,x=119.5]
let j1 = j[gy=rose,y=-5.5]
let j2 = j[gy=rose,y=-4.5]

! a nice palette and levels for bathymetries
palette dark_land_sea
shade/lev=(-10500,-5500,5000)(-5500,0,500)(0,2000,250)(2000,6000,1000)
rose

! Now use a nested repeat with the indices we just obtained.
! By default, the Label command places labels at world coordinate
! positions. The back tics force x[g=rose] and y[g=rose] be
! evaluated before they are passed to the label command. In
! the context of the REPEAT loop, `rose` will be evaluated at
! each I and J position and this number will be passed to the
! label command as a string.
repeat/i=`i1`:`i2`:1 (repeat/j=`j1`:`j2`:1 label `x[g=rose]` `y[g=rose]` 0 0 .06 "`rose`")

 


Last modified: Thu Apr 27 2000