PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 05 Jan 2018 01:15 PM by  Jim Uba
How to select and operate on a subset of array elements?
 0 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Jim Uba



New Member


Posts:76
New Member


--
05 Jan 2018 01:15 PM
    IDL USER QUESTION::

    "I have an IDL problem that I haven’t been able to solve and was hoping you might be able to point me in the right direction. I have a raster that I’ve read into an array and I want to perform an operation only where there aren’t the no data values of -32767. I thought I could use the if statements but they don’t work on arrays obviously. Is there an array expression equivalent that will allow me to do this?"

    ANSWER:

    Here is example code that illustrates how target value elements in an array can be detected and manipulated without looping:

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; create short int array data
    data = fix( randomu(seed, 10, 10, /long) )
    help, data

    ; select array index locations to assign bad value
    ibad = fix( randomu(seed, 20) * 100 )
    help, ibad

    badval = -32767
    data[ibad] = badval ; assign elements bad data
    print, data

    ; get array index locations with good data
    igood = where( data NE badval )

    ; if one or more array element indexes are returned
    ; (not a scalar -1) then manipulate those array elements
    if igood[0] NE -1 then $
    data[igood] = 0 ; manipulate good data
    print
    print, data
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    For additional information about using arrays in IDL see also:

    https://www.harrisgeospatial.com/do...rrays.html
    https://www.harrisgeospatial.com/do...WHERE.html

    You are not authorized to post a reply.


    MOST RECENT

    Quickly Assess Your UAV Data Quality In The Field | Live Webinar

    3/8/2018

    Live Webinar | April 17 One question a UAV pilot will inevitably ask in the field is “did I collect... more »

    What is PrecisionPass?

    3/7/2018

    Got 90 seconds? Austin Coates is here to give you the quick rundown on our latest product, PrecisionPass. more »

    SIGN UP & STAY INFORMED

    Sign up to receive the latest news, events, technologies and special offers.

    SIGN ME UP