X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08 May 2015 09:32 AM by  anon
Issues with ENVIRaster
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
08 May 2015 09:32 AM
    Hi, I am using Envi 5.2/IDL8.4 and try to get used to ENVIRaster functionalities instead of the old reading and writing routines but struggle with some points. 1. When I try to use ENVISubsetRaster to get a subset with its spatial references (see code below), it shows spatialref as undefined in the variables list. According to the help article, this should work. It also works when I use "spatialref = in_sub.spatialref". Is it directly implemented in ENVISubetRaster or not? Also, the function "ENVISubsetRaster" is not coloured in my compiler but it seems to do the job, except for the spatialref thing. in_raster= e.OpenRaster(in_files[i]) ; open the raster in_sub= ENVISubsetRaster(in_raster, sub_rect=[10,10,199,199], spatialref=spatialref) 2. When I read in several input files (same extent etc) and want to read out spatialref and metadata for the output, in the way I do in the code below, it looses the information in the defined variables. Why is that? for i=0, nr_in_files-1 do begin in_raster= e.OpenRaster(in_files[i]) ; open the raster in_sub= ENVISubsetRaster(in_raster, sub_rect=[10,10,199,199]) ; get the subset incluseve spatial reference of it in_data= in_sub.GetData() ; read into an array if i eq 0 then begin nb= in_raster.nbands ns= in_raster.ncolumns nl= in_raster.nrows metadata = in_raster.metadata spatialref = in_sub.spatialref stack = replicate(0.0, nr_in_files, n_elements(in_data[*,0]), n_elements(in_data[0,*])) endif in_raster.close stack[i,*,*]=in_data endfor Cheers, Kim

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    08 May 2015 11:28 AM
    The spatial reference, if it exists in the original file, is already passed on to the subset raster. You do not need to assign spatialref when calling the Subset Raster routine. For example: ENVI> raster = 'C:\Program Files\Exelis\ENVI52\data\qb_boulder_msi' ENVI> in_raster= e.OpenRaster(raster) ENVI> in_sub= ENVISubsetRaster(in_raster, sub_rect=[10,10,199,199]) ENVI> print, in_sub.spatialref ENVISTANDARDRASTERSPATIALREF COORD_SYS_CODE = 0 COORD_SYS_STR = 'PROJCS["UTM_Zone_13N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-105.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]' PIXEL_SIZE = 2.8000000, 2.8000000 ROTATION = 0.00000000 TIE_POINT_MAP = 480295.20, 4428950.4 TIE_POINT_PIXEL = 0.00000000, 0.00000000 ENVI>

    Deleted User



    New Member


    Posts:
    New Member


    --
    09 Jun 2015 07:53 AM
    Hello again! Sorry for not answering for a while... What about my second point? When I open a new raster with OpenRaster or when I close the raster files in the loop (in_raster.close) it also deletes the information in the variables "metadata" and "spatialref" so that they are a NullObject. Why are they still linked to the original rasters and how can I store these information in a variable for a later output? The only workaround for me was that I had to remove the IF-statement, so that every raster is enquired again for these information AND I had to remove the in_raster.close command so that all raster files would be open at the same time. But this is surely not the right way to save memory... I hope you understand the issues that I tried to explain... Cheers, Kim PS: one additional question: Since I am currently trying to process (temporal filter) a time series of single images (daily images for one year), I end up with a big pile of data that has to be opened, read and closed to generate filtered daily images. I wondered what is the benefit of the new "ENVIRasterSeries" and if it might speed up my task?!

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    16 Jun 2015 01:59 PM
    I did not find that the information was deleted. It is still stored as an object. ENVI> raster = 'C:\Program Files\Exelis\ENVI52\data\qb_boulder_msi' ENVI> in_raster= e.OpenRaster(raster) ENVI> metadata=in_raster.metadata ENVI> print, metadata ENVIRASTERMETADATA BAND NAMES = 'Band 1', 'Band 2', 'Band 3', 'Band 4' DESCRIPTION = 'Demo QuickBird 2 data courtesy DigitalGlobe', 'Inc. Not for commercial use.' SENSOR TYPE = 'QuickBird' WAVELENGTH = 485.00000, 560.00000, 660.00000, 830.00000 WAVELENGTH UNITS = 'Nanometers' ENVI> in_raster.close ENVI> help, metadata METADATA OBJREF = You can save the metadata by storing it in a hash data type: ENVI> tags = metadata.tags ENVI> print, tags SENSOR TYPE DESCRIPTION BAND NAMES WAVELENGTH UNITS WAVELENGTH ENVI> h = HASH() ENVI> foreach tag, tags do $ ENVI> h[tag] = metadata[tag] ENVI> help, h H HASH ENVI> value=h['WAVELENGTH'] ENVI> help, value VALUE DOUBLE = Array[4] ENVI> print, value 485.00000 560.00000 660.00000 830.00000 Or you can just access the wavelengths from the tags: ENVI> wl=metadata['wavelength'] ENVI> print, wl 485.00000 560.00000 660.00000 830.00000

    Deleted User



    New Member


    Posts:
    New Member


    --
    22 Jun 2015 02:11 AM
    I also tried it now with the Boulder example file but with the same result: after closing the raster with raster.close the metadata becomes a Null object in the variable list and when you try to print it thereafter you just get this variable "" and not the tags etc anymore. Actually it looks like it does the same in your test... because when you check with 'help, metadata' in the end it gives you 'METADATA Objref = ...' but I think it should give you 'METADATA ENVIRASTERMETADATA ' if it would still be open?!
    You are not authorized to post a reply.