function map_patch_lambert, Image_Orig, Lon, Lat, x=x_,y=y_,bbox=bbox, missing=missing,_extra=extra, south=south, center_lon=center_lon common map_patch_count,count if n_elements(count) eq 0 then count=0 if n_elements(x_) eq 0 then begin project_lambert,lon=lon,lat=lat,x=x,y=y, south=south,center_lon=center_lon end else begin x=x_ y=y_ end ; surface, lat junk=where(~finite(x),count) if count gt 0 then begin message,"This image points off of the Earth and cannot be processed at present." ; message,"This image points off of the Earth and cannot be processed at present.", /INFORMATIONAL ; RETURN, -1 end s = size(Image_Orig) Nx = s[1] ; # of columns if s[0] eq 2 then Ny = s[2] else Ny = 1 ; # of rows n = N_elements(Image_orig) max_value = max(Image_orig,/nan,min=min_value) if n_elements(missing) eq 0 then missing = 0 xi=floor(x+0.5) yi=floor(y+0.5) xmin=min(xi,max=xmax) x=x-xmin ymin=min(yi,max=ymax) y=y-ymin bbox=[xmin,ymin,xmax,ymax] ;Triangle making code adapted from IDL MAP_PATCH nr = nx - 1 nr1 = 2 * (ny-1) i = (nx-1) * 6 t = lonarr(nr * 6, /NOZERO) for i=0, nr-1 do t[i*6] = ([i,i+1, i, i,i+1,i+1] mod nx) + [0, nx, nx, 0, 0, nx] triangles = lonarr(nr1 * nr * 3, /NOZERO) j = 0L y0 = 0 y1 = ny-2 for iy= y0, y1 do begin triangles[j] = t + iy * nx j = j + 6*nr endfor count++ ; print,'before trigrid',count ; help,/mem ;Interpolate from the triangular grid, in lat/lon onto an image bitmap. x = trigrid(x, y, image_orig, triangles, MAX_VALUE=max_value, MISSING = missing,nx=xmax-xmin+1,ny=ymax-ymin+1) ; print,'after trigrid',count ; help,/mem ; print,size(x,/dim) return, x end