MAP_PATCH
The MAP_PATCH function warps an image (or other dataset) to the current map projection. Mapping coordinates should be setup via a call to MAP_SET before using MAP_PATCH.
MAP_PATCH works in object (data) space. It divides the input data set, Image_Orig, into triangular patches, either directly from the implicit rectangular grid, or by triangulating the data points on the surface of the sphere using the TRIANGULATE procedure. These triangular patches are then projected to the map plane in the image space of the destination array and then interpolated. The time required by MAP_PATCH depends mainly on the number of elements in the input array.
Note: MAP_PATCH is more efficient than MAP_IMAGE when the destination area is large compared to the input data set. If the converse is true, MAP_IMAGE is more efficient.
This routine is written in the IDL language. Its source code can be found in the file map_patch.pro
in the lib
subdirectory of the IDL distribution.
Examples
; Form a 24 x 24 dataset on a sphere:
n = 24
; Specify equally gridded latitudes:
lat = replicate(180./(n-1),n) # findgen(n) - 90
; Specify equally gridded longitudes:
lon = findgen(n) # replicate(360./(n-1), n)
; Convert to Cartesian coordinates:
x = cos(lon * !dtor) * cos(lat * !dtor)
y = sin(lon * !dtor) * cos(lat * !dtor)
z = sin(lat * !dtor)
; Set interpolation function to scaled distance squared
; from (1,1,0):
f = BYTSCL((x-1)^2 + (y-1)^2 + z^2)
; Set up projection:
MAP_SET, 90, 0, /STEREO, /ISOTROPIC, /HORIZ
; Grid and display the data:
TV, MAP_PATCH(f, XSTART=x0, YSTART=y0), x0, y0
; Draw gridlines over the map and image:
MAP_GRID
; Draw continent outlines:
MAP_CONTINENTS
; Draw a horizon line:
MAP_HORIZON
Syntax
Result = MAP_PATCH( Image_Orig [, Lons, Lats] [, LAT0=value] [, LAT1=value] [, LON0=value] [, LON1=value] [, MAX_VALUE=value] [, MISSING=value] [, /TRIANGULATE] [, XSIZE=variable] [, XSTART=variable] [, YSIZE=variable] [, YSTART=variable] )
Return Value
Returns the image or dataset warped to the current map projection.
Arguments
Image_Orig
A one- or two-dimensional array that contains the data to be overlaid on the map. If the TRIANGULATE keyword is not set, Image_Orig must be a two-dimensional array. Rows and columns must be arranged in increasing longitude and latitude order. Also, the corner points of each cell must be contiguous. This means that the seam of a map must lie on a cell boundary, not in its interior, splitting the cell.
Lons
An optional vector that contains the longitude value for each column in Image_Orig. If Lons is a one-dimensional vector, longitude (Image_Orig[i,j]) = Lons[i]; if Lons is a two-dimensional vector, longitude (Image_Orig[i,j]) = Lons[i,j].
This argument can be omitted if the longitudes are equally-spaced and the beginning and ending longitudes are specified with the LON0 and LON1 keywords.
Lats
An optional vector that contains the latitude value for each row in Image_Orig. If Lats is a one-dimensional vector, latitude (Image_Orig[i,j]) = Lats[i]; if Lats is a two-dimensional vector, latitude (Image_Orig[i,j]) = Lats[i,j].
This argument can be omitted if the latitudes are equally-spaced and the beginning and ending latitudes are specified with the LAT0 and LAT1 keywords.
Keywords
LAT0
The latitude of the first row of data. The default is -90.
LAT1
The latitude of the last row of data. The default is +90.
LON0
The longitude of the first column of data. The default is -180.
LON1
The longitude of the last column of data. The default is 180 - (360/number of rows)
MAX_VALUE
The largest data value to be warped. Values in Image_Orig greater than this value are considered missing. Pixels in the output image that correspond to these missing values are set to the value specified by the MISSING keyword.
MISSING
Set this keyword to a value to be used for areas outside the valid map coordinates (i.e., the “background color”). If the current plotting device is PostScript, the default is 255 (white). Otherwise, the default is 0 (usually black).
TRIANGULATE
Set this keyword to convert the input data to device space and triangulate them. This keyword must be specified if the connectivity of the data points is not rectangular and monotonic in device space.
XSIZE
Set this keyword to a named variable in which the width of the output image is returned, in graphic coordinate units. If the current graphics device has scalable pixels (PostScript, for example), the values returned by XSIZE and YSIZE should be passed to the TV procedure.
XSTART
Set this keyword to a named variable in which the X coordinate where the left edge of the image should be placed on the screen is returned.
YSIZE
Set this keyword to a named variable in which the height of the output image is returned, in graphic coordinate units. If the current graphics device has scalable pixels (PostScript, for example), the values returned by XSIZE and YSIZE should be passed to the TV procedure.
YSTART
Set this keyword to a named variable in which the Y coordinate where the bottom edge of the image should be placed on the screen is returned.
Version History
4.0 |
Introduced |
See Also
MAP_CONTINENTS Procedure, MAP_GRID Procedure, MAP_IMAGE, MAP_SET Procedure