Question

How to merge features with the feature merger using conditional statements

  • 11 February 2014
  • 7 replies
  • 62 views

Hi all,

 

 

I am trying to merge two different datastreams into one using attribute ranges.

 

 

I have one stream that has a Attribute count (lets call it  A), it has values of 1,2,3,4,etc.

 

 

I have another stream (lets call it B) that has a Minimum Value and a Maximum value as well as some other attributes. I am trying to merge the two stream together where the first streams value (A) is between the Maximum and minimum value range of the second stream.

 

 

In other words if A = 5 and B's value range is min = 2 and max = 6 (and also contains other attributes like TYPE, CLass,etc.) i want  to merge A with B and keep the attributes other than the range attributes. IF A falls between the range of B  i want to get the attributes associated to that range.

 

 

I need yo be able to do this dynamically as it is a large dataset and manually entering in the ranges into any of the attribute range mappers is not an option.

 

 

Any thoughts? Thanks in advance for your help. 

7 replies

Userlevel 2
Badge +17
Hi,

 

 

I think the InlineQuerier can be used effectively.

 

This is an example of the SQL statement performing "range-based merging". Assuming table A has "Value", table B has "MinValue" and "MaxValue". And those attributes should be defined as numeric fields in the Table setting of the InlineQuerier.

 

-----

 

select A.*, B.*

 

from A cross join B

 

where A.Value between B.MinValue and B.MaxValue

 

-----

 

Although there may be variations depending on the actual condition and requirement, the point is to use "cross join" and "where" clause.

 

 

Takashi
Userlevel 4
Badge +13
In addition to the excellent answer of Takashi.

 

It is possible to import values into the AttributeValueMapper.
Hi Takashi and Itay,

 

 

Problem Solved ! Thanks for the help both of you, the I had tried and Inline querier already but i must have had an error in my statement. Your example SQL statement worked liked a charm with a minor adjustment (I had to list out all of the attributes i wanted from A and B the A.* did not work).

 

 

Itay the value mapper would have worked if i knew the ranges before hand but the attribute value ranges were generated mid translation. Is there a way to Import those?

 

 

Evan
Userlevel 2
Badge +17
Hi Evan,

 

 

Good to hear the problem has been solved.

 

 

About the AttributeValueMapper: If you defined attribute value mapping rule as an external table, it can be imported into the AttributeValueMapper when creating the workspace. But the mapping rule will be static after importing, it will not change at run-time. So I don't think it's suitable to your case.

 

 

FYI: Another method (not using SQL statement)

 

1) Merge unconditionally all attributes of every B to each A feature using a FeatureMerger.

 

Specify the same constant (e.g. "1") to "Join On" of both Requestor and Supplier; set "Yes" to "Process Duplicate Suppliers"; specify "Supplier List Name".

 

2) Explode the list of Matched features using a ListExploder.

 

3) Filter the features by determining if Value is in the range of MinValue and MaxValue using a Tester.

 

 

The InlineQuerier consumes resource to create a temporary SQLite database internally, and the SQL statement might be hard to do maintenance, but querying could be fast.

 

The FeatureMerger + ListExploder method is intelligible and it might be easy to do maintenance, but it may consume much memory to create list attributes and explode features.

 

Both of them have merits and demerits.

 

 

Takashi
Badge

Hi Takashi,

I have a question, maybe similer aim.

I have got one table that I would like to select the records that which has maximum number ones.

I mean that, below table selected same "object_id" but their count's value is different each other.

I want to select the only maximum one. For object_id: 17753261 has to be "4"

For object_id:21402932 has to be "32"

I hope that I could tell my aim.

Thanks

Badge +22

Hi @esaka,

 

 

If you sort your features so that the count is either ascending or descending, you can then use a sampler grouped on object_id with the first or last 1 feature (depending on your sort).

Badge

Hi @esaka,

 

 

If you sort your features so that the count is either ascending or descending, you can then use a sampler grouped on object_id with the first or last 1 feature (depending on your sort).

Hi Takashi/ jdh

 

 

Thankyou. I resolved.

 

 

Reply