X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 10 Sep 2014 08:30 AM by  anon
ENVIRaster
 5 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
10 Sep 2014 08:30 AM
    I am new to object orientated programming and am trying to do batch processing using ENVI 5.0 functions in IDL 8.2.3. My intention is to spatial & spectrally subset a lot of geotiffs. At the moment I am subsetting into .sav files but would like to create a new set of geotiffs. I think that I should be creating new ENVI rasters. However when I try to use ENVIRaster() I get an error message. % ENVIRASTER::INIT: Incorrect number of arguments. even when using the exampe provided online! (see below) oddly ENVIRaster() is coloured in blue and not cyan in my IDLDE Please help! Sam EXAMPLE CODE (concise version of http://www.exelisvis.com/docs/enviRaster.html) e = ENVI(/headless) file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR,SUBDIRECTORY = ['data']) raster = e.OpenRaster(file) newFile = e.GetTemporaryFilename() origData = raster.GetData(BANDS=0) ; the problem occurs here newRaster = ENVIRaster(origData, URI=newFile, NBANDS=1) % ENVIRASTER::INIT: Incorrect number of arguments.

    Deleted User



    New Member


    Posts:
    New Member


    --
    10 Sep 2014 09:33 AM
    I also tried subsetting using the Export method to ENVIRaster but get the following error message: % Attempt to call undefined method: 'ENVIRASTER::EXPORT'.

    Deleted User



    New Member


    Posts:59
    New Member


    --
    10 Sep 2014 01:46 PM
    Hello Sam, I believe the reason you're getting the error is that the creation of a new ENVI raster object (i.e., the line below) changed from version 5.0 to 5.1. The online example reflects ENVI 5.1. newRaster = ENVIRaster(origData, URI=newFile, NBANDS=1) However, I don't think you need this line or even the GetData method. You can just use the Subset method on the source raster to define your spectral and spatial subset. I created small program for you (below) which *should* work with ENVI 5.0...I don't have a copy of this version to test it with. The following example creates a spectral subset of the first band and a spatial subset of the first 200 pixels in the upper-left corner of the source images, then exports the results to GeoTIFF files in your system's temporary directory. Please try this. You'll need to change the File_Search line to point to your own directory and filenames. PRO SubsetExportToGeoTIFF COMPILE_OPT IDL2 e = ENVI(/headless) files = File_Search('C:\MyData', 'Images*.tif') For i=0, N_Elements(files)-1 DO BEGIN raster = e.OpenRaster(files[i]) newFile = e.GetTemporaryFilename() SubRaster = raster.Subset(BANDS=[0], SUB_RECT=[0,0,200,200]) SubRaster.Export, newFile, 'TIFF' Endfor END

    Deleted User



    New Member


    Posts:
    New Member


    --
    11 Sep 2014 08:50 AM
    Hi Jwolfe, thanks for the reply. ; following up to this line SubRaster = raster.Subset(BANDS=[0], SUB_RECT=[0,0,200,200]) ; works successfully and creates an ENVI Raster! help,subraster SUBRASTER ENVIRASTER ; but I cannot seem to use it properly SubRaster.Export, newFile, 'TIFF' % Attempt to call undefined method: 'ENVIRASTER::EXPORT'. _________________________________________________________ I might have to wait for ENVI 5.1. for this to work properly :/ In the meantime I am studying the GeoTIFF specification http://www.remotesensing....f/spec/contents.html So that I can read, subset, update georeference information, and write through IDL. ; read img=READ_TIFF(filepath, GEOTIFF=GeoKeys) ; subset subset = img[x_lo:x_hi,y_lo:y_hi] ; update georeference information ; todo [study the contents of geokeys structure (section 2.7 of GeoTIFF specification), I will post final results for Landsat 8.] ; write WRITE_TIFF, outpath, subset, GEOTIFF=updated_GeoKeys

    Deleted User



    New Member


    Posts:59
    New Member


    --
    11 Sep 2014 10:25 AM
    It looks like we changed the Export method from 5.0 to 5.1 as well. It used to be a method off the ENVI object, and now it's a method off the ENVIRaster object. Since you are using version 5.0, please replace this line: SubRaster.Export, newFile, 'TIFF' with this: e.ExportRaster, SubRaster, newFile, 'TIFF' The resulting files will still have .dat extensions, but they are actually GeoTIFFs.

    Deleted User



    New Member


    Posts:
    New Member


    --
    12 Sep 2014 08:31 AM
    This created a new subset geotiff with my version of ENVI but the subset is larger than the SUB_RECT pixel coordinates that I specified in this line. subRaster = raster.Subset(BANDS=[0], SUB_RECT=[x1,x2,y1,y2]) I cannot figure out why! I even tested that the pixel coordinates were correct by subsetting with (read/write)_tiff and updating the geokeys (i.e. changing the 'ModelTiePointTag' in the case of Landsat 8 data).. which incidently is a working solution, so that's good. Thanks for your help!
    You are not authorized to post a reply.