Skip to main content
Solved

How to populate attribute with last element from a list?


nicholas
Contributor
Forum|alt.badge.img+11

Hello all,

I have 1721 point features, which I am combining into a single line using LineBuilder.

Each node has a datetime stamp, and I want to populate the line with the attributes "start_date" and "end_date" drawn from the "date" attribute of the first and last point feature.

In the LineBuilder I have ticked the parameter Generate List, so I have a list with 1721 elements.

I can use the Attribute manager to create a new attribute "start_date" with a value of;

@Value(points{0}.date)

However, I fail to do the equivalent for the last element in the list.

@Value(points{-1}.date) is not accepted by the Text editor or the List Element Selection: points{}.date

I thought I might solve it by using ListElementCounter, which does create a new attribute with a value of 1721, but again the List Element Selection: does not accept an attribute value as an input.

 

Best answer by nicholas

Thanks @deanhowell2009, I checked out that post, and chose the ListIndexer, which does allow a value of -1 for the list index.

Note: my list is points{} with a single attribute "date" and 1721 elements.

List Attribute: points{}

List Index to Copy: -1

Copied Attribute Prefix: end_

The end result was a new attribute of "end_date" populated with the value from the last element in the list. This is exactly the result I am looking for :-)

I also did a second ListIndexer to grab the start_date

View original
Did this help you find an answer to your question?

2 replies

deanhowell
Influencer
Forum|alt.badge.img+23
  • Influencer
  • August 26, 2019

nicholas
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • Best Answer
  • August 26, 2019

Thanks @deanhowell2009, I checked out that post, and chose the ListIndexer, which does allow a value of -1 for the list index.

Note: my list is points{} with a single attribute "date" and 1721 elements.

List Attribute: points{}

List Index to Copy: -1

Copied Attribute Prefix: end_

The end result was a new attribute of "end_date" populated with the value from the last element in the list. This is exactly the result I am looking for :-)

I also did a second ListIndexer to grab the start_date


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings