# ncl_c_shgetnp man page

c_shgetnp — find the nearest points to a specified point in 3-space

## Function Prototype

```
int c_shgetnp(float, float, float, int, float *, float *, float *,
int, int *);
```

## Synopsis

`int c_shgetnp (px, py, pz, n, x[], y[], z[], iflag, ier );`

## Description

- px
- (float) The X coordinate value for a point P whose nearest neighbor is to be found.
- py
- (float) The Y coordinate value for a point P whose nearest neighbor is to be found.
- pz
- (float) The Z coordinate value for a point P whose nearest neighbor is to be found.
- n
- (int) The number of input data points, n > 1.
- x
- (float) An array of length n containing the X coordinate values for the input data points.
- y
- (float) An array of length n containing the Y coordinate values for the input data points.
- z
- (float) An array of length n containing the Z coordinate values for the input data points.
- iflag
- (int) A flag that equals 0 if this is the first call to this subroutine for the given dataset and equals 1 otherwise.
- ier
- (pointer to int) An error return value. If *ier is returned as 0, then no errors were detected. If *ier is non-zero, then look at the man page for shgrid_errors for details.

## Usage

c_shgetnp is called to find the nearest point to a specified point in 3-space. Successive calls to c_shgetnp will determine the point nearest the specified point exclusive of the points found in previous calls, i.e. successive calls can be used to find the N nearest points for any N between one and the maximum number of points in the input dataset.

c_shgetnp returns an integer, say np, such that (x[np],y[np],z[np]) is the nearest input data point to P. np = -1 if *ier is not zero. On successive calls to this function after the first (that is when iflag=1) you can find the Mth closest point to (px,py,pz) with the Mth call.

## Access

To use c_shgetnp, load the NCAR Graphics library ngmath.

## See Also

shgetnp, c_shgrid, c_shseti, c_shgeti, shgrid_params.

Complete documentation for Sh is available at URL

http://ngwww.ucar.edu/ngdoc/ng/ngmath/s…

## Copyright

Copyright (C) 2000

University Corporation for Atmospheric Research

The use of this Software is governed by a License Agreement.