The GRID_INPUT procedure preprocesses and sorts two-dimensional scattered data points, and removes duplicate values. This procedure is also used for converting spherical coordinates to Cartesian coordinates.
GRID_INPUT, X, Y, F, X1, Y1, F1 [, DUPLICATES=string ] [, EPSILON=value ] [, EXCLUDE=vector ]
or
GRID_INPUT, Lon, Lat, F, Xyz, F1, /SPHERE [, /DEGREES] [, DUPLICATES=string ] [, EPSILON=value ] [, EXCLUDE=vector ]
or
GRID_INPUT, R, Theta, F, X1, Y1, F1, /POLAR [, /DEGREES] [, DUPLICATES=string ] [, EPSILON=value ] [, EXCLUDE=vector ]
These are input arguments for scattered data points, where X, and Y are location. All of these arguments are N point vectors.
The function value at each location in the form of an N point vector.
These are input arguments representing scattered data points on a sphere, specifying location (longitude and latitude). All are N point vectors. Lon, Lat are in degrees or radians (default).
These are scattered data point input arguments representing the R and Theta polar coordinate location in degrees or radians (default). All arguments are N point vectors.
These output arguments are processed and sorted single precision floating point data which are passed as the input points to the GRIDDATA function.
Upon return, a named variable that contains a 3-by-n array of Cartesian coordinates representing points on a sphere.
By default, all angular inputs and keywords are assumed to be in radian units. Set the DEGREES keyword to change the angular input units to degrees.
Set this keyword to a string indicating how duplicate data points are handled per the following table. The case (upper or lower) is ignored. The default setting for DUPLICATES is "First".
The tolerance for finding duplicates. Points within EPSILON distance of each other are considered duplicates. For spherical coordinates, EPSILON is in units of angular distance, as set by the DEGREES keyword.
An N-point vector specifying the indices of the points to exclude.
Set to indicate inputs are in polar coordinates.
Set to indicate inputs are in spherical coordinates. In this case, the output argument Xyz is set to a 3-by-n array containing the spherical coordinates converted to 3-dimensional Cartesian points on a sphere.
The following example uses the data from the irreg_grid1.txt ASCII file included in the examples/data subdirectory of the IDL distribution. This file contains scattered elevation data of a model of an inlet. This scattered elevation data contains two duplicate locations. The GRID_INPUT procedure is used to omit the duplicate locations.
; Import the Data: ; Determine the path to the file. file = FILE_SEARCH(!DIR, 'irreg_grid1.txt') ; Import the data from the file into a structure. dataStructure = READ_ASCII(file) ; Get the imported array from the first field of ; the structure. dataArray = TRANSPOSE(dataStructure.field1) ; Initialize the variables of this example from ; the imported array. x = dataArray[*, 0] y = dataArray[*, 1] data = dataArray[*, 2] ; Display the Data: ; Scale the data to range from 1 to 253 so a color table can be ; applied. The values of 0, 254, and 255 are reserved as outliers. scaled = BYTSCL(data, TOP =!D.TABLE_SIZE - 4) + 1B ; Load the color table. If you are on a TrueColor, set the ; DECOMPOSED keyword to the DEVICE command before running a ; color table related routine. DEVICE, DECOMPOSED = 0 LOADCT, 38 ; Open a display window and plot the data points. WINDOW, 0 PLOT, x, y, /XSTYLE, /YSTYLE, LINESTYLE = 1, $ TITLE = 'Original Data, Scaled (1 to 253)', $ XTITLE = 'x', YTITLE = 'y' ; Now display the data values with respect to the color table. FOR i = 0L, (N_ELEMENTS(x) - 1) DO PLOTS, x[i], y[i], PSYM = -1, $ SYMSIZE = 2., COLOR = scaled[i] ; Preprocess and sort the data. GRID_INPUT will ; remove any duplicate locations. GRID_INPUT, x, y, data, xSorted, ySorted, dataSorted ; Display the results from GRID_INPUT: ; Scale the resulting data. scaled = BYTSCL(dataSorted, TOP =!D.TABLE_SIZE - 4) + 1B ; Open a display window and plot the resulting data points. WINDOW, 1 PLOT, xSorted, ySorted, /XSTYLE, /YSTYLE, LINESTYLE = 1, $ TITLE = 'The Data Preprocessed and Sorted, Scaled (1 to 253)', $ XTITLE = 'x', YTITLE = 'y' ; Now display the resulting data values with respect to the color ; table. FOR i = 0L, (N_ELEMENTS(xSorted) - 1) DO PLOTS, $ xSorted[i], ySorted[i], PSYM = -1, COLOR = scaled[i], $ SYMSIZE = 2.
Introduced: 5.5