X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 25 Aug 2010 02:51 PM by  anon
Extract data based on Spatial Overlay
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
25 Aug 2010 02:51 PM
    Hi, I have two files, one with 25 km pixels, the other with 300 m pixels. What I need to do is: 1) for every one of the 25 km pixels in the first image, identify and count all the 300 m pixels from the second image that lie geographically within each 25 km pixel ; 2) identify and count all of the 300 m pixels (from within each specific 25 km pixel) that have a specific band value; once these steps have been accomplished, I'll then determine the fraction of the above 300 m pixels with the specified band value to total number of pixels (~83) determined from step 1. I've been brainstorming about possible ways to do this. Could someone point me in the right direction, please?

    Deleted User



    New Member


    Posts:
    New Member


    --
    26 Aug 2010 08:04 AM
    The code is closer to working correctly. I am wondering if my input grids are flawed, as I am only getting three id matches between coarse and fine input files. Currently, I'm working with a subset of the 25km file (my coarse grid input) and just doing a basic ENVI resample to 300m (my fine grid input). It is my understanding (perhaps flawed) that this should preserve the pixel id values of the original input file. Any comments on this? pro fractional_pixel_extraction ; input: 1)file with fine spatial resolution data (300 m in this example) ; 2)grid file of coarse resolution (25 km in this example) ; 3)grid file with fine resolution (created 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 = bytarr(28,25) fine_grid = bytarr(2340,2089) OPENR, lun1, 'W:\MODIS_MERIS_Water_Cover_panArctic\GlobCover\Fractional_Test\NISE_SSMISF17_25km_roi', /get_lun READU, lun1, coarse_grid close, lun1 free_lun, lun1 OPENR, lun2, 'W:\MODIS_MERIS_Water_Cover_panArctic\GlobCover\Fractional_Test\NISE_SSMISF17_25km_roi_300m', /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(2341,2090, 1) openr, lun3, 'W:\MODIS_MERIS_Water_Cover_panArctic\GlobCover\Fractional_Test\Globland_NEASE_roi', /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_F210 = fltarr(28,25,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=0, 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) ;;;again, something is wrong here. The pixel count is far too high here. count=count fcount=float(count) ; print, count1 if count EQ 0 then begin F210 = -9999 ; gives this value to the output pixel endif else begin ; determine how many fine pixels are within the coarse pixel, and have a value equal to 210. indexed_pixels=VI(id_index) count_F210 = where(indexed_pixels EQ 210,count) count2=count fcount2=float(count2) ; print, count2 if count EQ 0 then begin F210 = -9999 endif else begin ;compute the fraction of pixels with VI equal to 210 out of total count. F210 = (fcount2 /fcount) ; this is still a problem. I'm not adding the corrent inputs??? print, F210 endelse endelse ; place the fractional values in an out-grid out_grid_F210[id] = F210 ;note that the values in the output file differ slightly from those printed endfor ; write the grid containing the fractional values to a file openw, out_lun, 'W:\MODIS_MERIS_Water_Cover_panArctic\GlobCover\Fractional_Test\test2' , /get_lun writeu, out_lun, out_grid_F210 close, out_lun free_lun, out_lun end
    You are not authorized to post a reply.