X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 23 Jan 2017 04:15 AM by  anon
Layer stacking with ENVI API
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
23 Jan 2017 04:15 AM
    Hello, i am trying to use the ENVILayerStackRaster function. In particular, i need to execute the layer stacking with the option "Exclusive: range encompasses file overlap" but i do not find any function option to do this. The routine ENVI_LAYER_STACKING_DOIT has the /EXCLUSIVE option but it is obsolete and has been replaced by ENVILayerStackRaster. Thank you for any feedback.

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    23 Jan 2017 08:16 AM
    With the new API routines, it is up to the user to determine the extents of their images. Although ENVI_LAYER_STACKING_DOIT is from ENVI Classic, it still works in the latest version and there currently are no plans to remove this routine. I would suggest you use the classic routine at this time.

    Deleted User



    New Member


    Posts:
    New Member


    --
    23 Jan 2017 10:00 AM
    Thank you. I decide top use Envi Classic. Here my code: pro idl_layerstacking COMPILE_OPT IDL2 envi e = ENVI(/HEADLESS) ; file to be use as base: base_filename = 'myfilename.dat' envi_open_file, base_filename, R_FID=base_id, /INVISIBLE, /NO_REALIZE ENVI_FILE_QUERY, base_id, DIMS=base_dims base = e.OpenRaster(base_filename) ;print, base.NCOLUMNS ;print, base.NROWS ;print, base.SPATIALREF out_proj = ENVI_GET_PROJECTION(FID = base_id) ;print, out_proj ; file to be stacked: new_filename = 'mynewfilename.dat' envi_open_file, new_filename, R_FID=new_id, /INVISIBLE, /NO_REALIZE ENVI_FILE_QUERY, new_id, DIMS=new_dims outputfile = 'mystackedfile' ; without extention ENVI_DOIT, 'ENVI_LAYERSTACKING_DOIT', DIMS = [base_dims, new_dims], FID = [base_id, new_id], POS = [0,0,1,2,3,4,5,6,7], ;first 0 is for the first band of the basefile, the other 0,1,2,3,4,5,6,7 refers to the 8th bands of the file to be stacked. /EXCLUSIVE, INTERP = 0, OUT_DT = 4, OUT_NAME = outputfile, OUT_PROJ = out_proj, OUT_PS = [base.NCOLUMNS, base.NROWS], R_FID = r_fid I obtain this error message: Error: "Conflicting data structures:structure tag,DIMS." The result may be invalid. I have some doubts about the correctness of the expressions of: DIMS[dimfile1, dimfile2] FID[fidfile1, fidfile2] POS[bandpositionfile1, bandpositionfile2] OUT_PS = [base.NCOLUMNS, base.NROWS] Can you provide support about the proper use of the ENVI_LAYER_STACKING_DOIT function in the event of multiple files? I thank you in advance

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    30 Jan 2017 08:36 AM
    I would try following the code in this help article: http://www.harrisgeospatial.com/Suppo...

    Deleted User



    New Member


    Posts:
    New Member


    --
    30 Jan 2017 08:58 AM
    Thank you. I solved with the following code: msi_file = Filepath(inputms, ROOT_DIR=root_path, SUBDIR=[subdir]) base = e.OpenRaster(msi_file) tostack_filename = Filepath(input_tostack, ROOT_DIR=tostack_root, SUBDIR=[subdir]) tostack = e.OpenRaster(tostack_filename) base_band0 = ENVISubsetRaster(base, BANDS=0) spatialRef = base_band0.SPATIALREF nCols = base_band0.NCOLUMNS nRows = base_band0.NROWS coordSys = ENVICoordSys(COORD_SYS_CODE=32633) pixelSize = spatialRef.PIXEL_SIZE tiePointMap = spatialRef.TIE_POINT_MAP tiePointPixel = spatialRef.TIE_POINT_PIXEL Grid = ENVIGridDefinition(coordSys,PIXEL_SIZE=pixelSize,TIE_POINT_MAP=tiePointMap,TIE_POINT_PIXEL=tiePointPixel,NCOLUMNS=nCols,NROWS=nRows) layerStack = ENVILayerStackRaster([base_band0, tostack],GRID_DEFINITION=Grid) File = Filepath(stack_filename, Root_Dir = root_path, SUBDIR=[subdir]) layerStack.Export, File, "ENVI"
    You are not authorized to post a reply.