Routines (alphabetical) > Routines: S > SPH_SCAT

# SPH_SCAT

The SPH_SCAT function performs spherical gridding. Scattered samples on the surface of a sphere are interpolated to a regular grid. This routine is a convenient interface to the spherical gridding and interpolation provided by TRIANGULATE and TRIGRID.

This routine is written in the IDL language. Its source code can be found in the file `sph_scat.pro` in the `lib` subdirectory of the IDL distribution.

## Examples

; Create some random longitude points:
lon = RANDOMU(seed, 50) * 360. -180.
; Create some random latitude points:
lat = RANDOMU(seed, 50) * 180. -90.
; Make a function to fit:
z = SIN(lat*!DTOR)
c = COS(lat*!DTOR)
x = COS(lon*!DTOR) * c
y = SIN(lon*!DTOR) * c
; The finished dependent variable:
f = SIN(x+y) * SIN(x*z)
; Interpolate the data and return the result in variable r:
r = SPH_SCAT(lon, lat, f, BOUNDS=[0, -90, 350, 85], GS=[10,5])

To view the result of the variable `r`, type:

PRINT, r

## Syntax

Result = SPH_SCAT( Lon, Lat, F [, BOUNDS=[lonmin, latmin, lonmax, latmax]] [, BOUT=variable] [, GOUT=variable] [, GS=[lonspacing, latspacing]] [, NLON=value] [, NLAT=value] )

## Return Value

Returns a regularly-interpolated grid of the function.

## Arguments

### Lon

A vector of sample longitudes, in degrees.

Note: Lon, Lat, and F must all have the same number of points.

### Lat

A vector of sample latitudes, in degrees.

### F

A vector of data values which are functions of Lon and Lat. Fi represents a value at (Loni, Lati).

## Keywords

### BOUNDS

Set this keyword to a four-element vector containing the grid limits in longitude and latitude of the output grid. The four elements are: [Lonmin, Latmin, Lonmax, Latmax]. If this keyword is not set, the grid limits are set to the extent of Lon and Lat.

Note: To cover all longitudes, you must explicitly specify the values for the BOUNDS keyword.

### BOUT

Set this keyword to a named variable that, on return, contains a four-element vector (similar to BOUNDS) that describes the actual extent of the regular grid.

### GOUT

Set this keyword to a named variable that, on return, contains a two-element vector (similar to GS) that describes the actual grid spacing.

### GS

Set this keyword to a two-element vector that specifies the spacing between grid points in longitude (the first element) and latitude (the second element).

If this keyword is not set, the default value is based on the extents of Lon and Lat. The default longitude spacing is (Lonmax - Lonmin)/(NLON-1). The default latitude spacing is (Latmax - Latmin)/(NLAT-1). If NLON and NLAT are not set, the default grid size of 26 by 26 is used for NLON and NLAT.

### NLON

The output grid size in the longitude direction. The default value is 26.

Note: NLON need not be specified if the size can be inferred from GS and BOUNDS.

### NLAT

The output grid size in the latitude direction. The default value is 26.

Note: NLAT need not be specified if the size can be inferred from GS and BOUNDS.

## Version History

4.0 | Introduced

## See Also

TRIANGULATE, TRIGRID