X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 02 Sep 2010 08:06 AM by  anon
Warped Output image
 0 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
02 Sep 2010 08:06 AM
    I’ve encountered what has been an ENVI/IDL conundrum for me. I wrote some IDL code to compute fractional values for a class; each fractional value is based on the number of high resolution pixels existing within a coarse resolution pixel. I’m using images with a North EASE projection (NSIDC). Here’s my routine. I have one image that is a 300 m classification map. I have one image that is 25 km. I clip the 25 km image so that the dimensions are the same as the 300 m map. I then use these dimensions to create a grid with integers ranging from 0 to the number of pixels-1 (via out_grid=lindgen(x,y) ). I then take this output, coarse, grid (specify that it has 25 km pixels in the header file), and then re-sample using nearest neighbor to 300 m. This provides me with a fine-resolution grid. My code is then set up to input both the coarse and fine grids, and the 300 m classification map. The code goes through and finds the fine grid pixels that have the same value as one coarse pixel, finds the count for this, and then determines which of these matches a certain class value contained within the classification map. Here’s the problem. I ran the code on a regional image (clipped from the full pan-Arctic image) and it turned out just fine. Now I’m trying to run it for the pan-Arctic and I’m getting this strange warping, swirly thing within the image. I tried starting over from the beginning just in case there was an image or grid corruption problem, but I get the same result each time. I’ve double checked my ENVI header file and it seems to be fine. I’ve asked around, but no one has had any good ideas for what is causing the problem. 25 km image (basis for the coarse grid) input classification map Output image, with strange "swirl" pro fractional_water_extraction_linux ;created by J. Watts (August 2010) using code from Matt Jones. ; input: 1)file with fine spatial resolution data (300 m in this example) ; 2)grid file of coarse resolution (25 km in this example). create using lingen(). ; 3)grid file with fine resolution (create by resampling the coarse resolution grid to the resolution of ; the input fine with fine resolution data; generates pixels with id values with that of the coarse res. grid). ; This grid was cliped to the same spatial extent of the fine resolution input data. ; output: a coarse resolution (25 km) file with fractional coverage information for each pixel. ; program objective: Determine fractional coverage of a certain DN value for all fine resolution pixels within each ; coarse resolution pixel. Output fractional value for each coarse pixel in envi binary file. ; Open index grids and store in arrays coarse_grid = lonarr(368,390) fine_grid = lonarr(30595,32478) OPENR, lun1, '/measures/MODIS_MERIS_Water_Cover_panArctic/GlobCover/25km_EASE_grid_subset_PanArctic_unq_ID', /get_lun READU, lun1, coarse_grid close, lun1 free_lun, lun1 OPENR, lun2, '/measures/MODIS_MERIS_Water_Cover_panArctic/GlobCover/25km_EASE_grid_subset_PanArctic_unq_ID_300m_subGlob', /get_lun readu, lun2, fine_grid close, lun2 free_lun, lun2 ; Initialize input grid that will hold high resolution VI data in_data_grid = bytarr(30594,32477, 1) openr, lun3, '/measures/MODIS_MERIS_Water_Cover_panArctic/GlobCover/Globcover_NEASE', /get_lun readu, lun3, in_data_grid close, lun3 free_lun, lun3 ;determine input grid data layer VI=in_data_grid[*,*,0] ;determine output grid out_grid = fltarr(368,390,1) ; changed the dimensions from 368,390,1 ;determine the unique id values from the grid and sort these values by order coarse_ids = fine_grid[UNIQ(fine_grid, SORT(fine_grid))] ;print, coarse_ids ; determine the number of returned unique coarse_ids num_ids = n_elements(coarse_ids) ;print, num_ids ; loop through each coarse_id number for j=0L, num_ids-1 do begin id = coarse_ids[j] ;count how many fine pixels occur at coarse_ids[j] id_index = where(fine_grid EQ id, count) count=count fcount=float(count) print, count if count EQ 0 then begin Fclass = -9999 ; gives this value to the output pixel endif else begin ; determine how many fine pixels of a certain class are within the coarse pixel, and have a value equal to 210. class=210 indexed_pixels=VI(id_index) count_class = where(indexed_pixels EQ class,count) count2=count fcount2=float(count2) ; print, count2 if count EQ 0 then begin Fclass = 0 endif else begin ;compute the fraction of pixels with VI equal to 210 out of total count. Fclass = (fcount2 /fcount) ;print, Fclass endelse endelse ; place the fractional values in an out-grid out_grid[id] = Fclass endfor ; write the grid containing the fractional values to a file openw, out_lun, '/measures/MODIS_MERIS_Water_Cover_panArctic/GlobCover/test_test_test' , /get_lun writeu, out_lun, out_grid close, out_lun free_lun, out_lun end
    You are not authorized to post a reply.