span8
第4排
A number of FME transformers are specifically designed to work with list attributes.These can be used to create,manipulate,转换,and analyze lists.
Some of the most important and highly used list transformers are:
We'll explore each of these list-specific transformers in a little more detail below!还提供了一些变压器列表FME Hub
Download and open these workspace templates in FME workbench to see some examples of list transformers in action.
请参阅表,查看六个变压器中的哪一个出现在每个工作区模板中:
工作区模板:列表分解器.fmwt
这个ListExploderis a frequently used list transformer.In fact,it is 32nd in popularity out of our total gallery of 487 transformers!其中一个原因是ListExploder它之所以流行,是因为它能够将列表扁平化为具有非列表属性的独特特性:它本质上是将列表分解为其组成元素,creating one feature for each list element.Using the urban tree point data from the使用变压器创建列表tutorial as an example,生成的架构运行在ListExploder如下所示:
Notice how each list attribute in the list_trees{}
becomes a standalone attribute in each feature output by theListExploder.Also notice the new_element_index
attribute,which indicates each feature's list element index of origin: this is evidence that each element in the source list (ie_tree{0},_tree{1},_tree{2}
) has been output as an individual feature.
Let's turn to theListExploderworkspace for a more thorough example.This workspace shows how to read a set of polygon features,extract the coordinate pairs for each vertex into a list attribute,and then use theListExploder将这些分解成单独的特征,准备作为文本文件中坐标对的行写入。
The workspace reads a spatial dataset - in this case park data from a MapInfo TAB file.The data is tidied up,坐标是从每个多边形中提取出来的,并作为一条由分号分隔的长值行存储在单个属性中。
斯坦利公园的这个很有趣:
既然我们有了所有的坐标,我们可以将这个长属性值转换为列表属性。
Here are the coordinates for Stanley Park again,but in list format:
请记住,我们的最终目标是输出如下所示的文本文件:
Stanley Park491042.12,5460549.07490995.16,5460561.47490991.53,5460562.19...
We essentially want each line in the text file to be a feature in FME,but we currently have all the coordinates for a park contained within a list attribute in one feature.This is a perfect scenario for theListExploder,请as it will flatten that list of coordinates into individual features,one for each list element.If you run the workspace,notice that the feature count changes from74
to4301
在经历ListExploder.
We can dive deeper into theListExploder参数来查看引擎盖下发生了什么。Under the "Attribute Accumulation" header in theListExploderparameters,可以确定要保留哪些属性,以及在分解特征上使用什么累积模式。The main question to ask here is,"Do I want to keepall属性,或者,我想优先考虑保留原始数据集或分解列表中的属性吗?”
Many combinations exist within the "Attribute Accumulation parameters",我们建议咨询ListExplodertransformer documentation对于所有可能性的详细描述,but keep reading for a boiled-down explanation!
简而言之,there are three accumulation modes:
在上述任何累积模式中,if original attributes and list attributes duplicate each other,它们是根据Conflict Resolution
参数,which itself can prioritize original or list attributes.It's a lot of parameters to wrap your head around,but just remember that there are two sets of attributes at play - those coming from the original feature,and those contained within the list attribute that is exploding.关键是保留或删除这些属性的子集。
Within the workspace,parallel to the list manipulation,a header feature for each park is created and sorted into the list of coordinates so that the park name will appear at the start of each list in the output text file.
Take a look at the final output to get a sense of how far we've come after reading in the source data:
FME stored all this geometry information behind the scenes when we read in the parks data.我们将它提取到一个单独的属性中,该属性包含一个长的值列表。Then we manipulated the data into an actual list attribute with element indexes.Because FME recognizes the structure of a list attribute,我们能够将每个元素转换成一个不同的特性,这样文本文件中的每一行都代表一个坐标对。
Similar to aListExploder,aListIndexermaps list attributes to a new feature.However,instead of exploding all list attributes,它只在给定的元素索引(例如0,1,2..
).For example,aListIndexer应用于ListExploderexample above will give the entire list of coordinates plus a new attribute with a single pair of coordinates from the given index defined in the transformer parameters.In this case,指定的索引是0
and the new attribute is prefixed "1st" because it is the first coordinate of the list:
工作区模板:使用lists.fmwt
这个ListElementCounter is a cousin of theCountertransformer,which adds a numeric attribute to a feature,使用每个新的传入功能增加值。The counter in theListElementCountercounts the number of elements in an incoming list rather than the number of features in an incoming feature type.We can use this transformer in tandem with theStatisticsCalculator 在我们的列表上运行报告。
For example,in the workspace provided,这个ListElementCounter计算中的元素_parks{}
列表。Since the number of elements represents the number of points that fell within a particular polygon,the output can answer questions such as公园里发现的树最少多少?What is the most?How many parks have trees?
Here we can see that China Creek Park North has a list element count of 2,as there are two records contained within our_parks{}
list:
工作区模板:使用lists.fmwt和listhistogrammer.fmwtt
这个ListHistogrammer 构建列表中找到的值的柱状图,并在新的列表属性中返回这些值。The new list will be sorted so that the value with the most occurrences will be first.将此转换器与中的数据一起使用Working With Lists工作区,我们可以很容易地找到树木最多的公园,也可以知道每个公园中代表了多少物种。As a bonus,you can specify your own histogram list name,making it possible to have multiple histograms on a single feature.
Here we're counting the occurrence of each tree species within a single park using theListHistogrammer以下内容:
In theListHistogrammer工作区,the user needs to count how many features there are of each type (zone
) in a set of zoning data.This can be achieved by creating an artificial aggregate and list of the source data,and subsequently running it through theListHistogrammer.
The workspace actually goes one step further: it uses a custom transformer to convert the histogram into a set of attributes and values.它还显示了AttributeExposer从分区数据中导入值,以便新生成的属性都可以被公开和检查。
工作区模板:使用lists.fmwt
这个ListConcatenatorcan be used to take a list and string together the elements in the list into a comma-separated single attribute value.这对于将列表信息的部分提取到单个属性中很有用。
In our example we can add a comma-separated list ofTreeID
values to the information about each park.
In fact it doesn't even just have to be a comma separated list - you can specify the Separator character to be any character you want.甚至可以使用换行符等特殊字符。
Workspace template:列表生成器.fmwt
On occasion you may need to create a list manually - theListBuilderTransformer通过将一组功能的属性组合到一个列表结构中来实现这一点。这个ListBuildercan be thought of as the inverse of theListExploder,请or as a way of aggregating features and their attributes into a single feature containing all the data in a list attribute.
In theListExploder工作区,我们希望查看此结构中文本文件中的数据:
[ParkName][vertex.coordinatepair0][vertex.coordinatepair1]...[ParkName]...
This is great visually,great for record-keeping,and a flexible format for use in other systems.However,if we wanted to keep a similar logical structure,每个公园名称都有一个坐标列表,但保留了列表数据格式的强大功能,we could use aListBuilder而不是ListExploderto manipulate our coordinates.
In this example,这个ListBuilder聚合所有元素_coordinateList{}
attribute created by theAttributeSplitteras well as the公园名称
.因为group by参数设置为group by公园名称
,请one feature is output per park containing a nested list of all the coordinates for that park!
ListBuilderparameters:
输出在结构上与我们的可视文本输出非常相似,但以列表格式。Note the nested structure and that the公园名称
is now part of the_协调员
列表。我们只是将多个属性组合成一个列表,然后从列表中创建一个列表!So many lists.
注:该ListBuilder是否删除几何图形,因此有必要使用VertexCreator或类似的变压器,如果需要几何结构。
The data used here originates from open data made available by theCity of Vancouver,请British Columbia.It contains information licensed under the Open Government License - Vancouver.
Computing a Histogram on a List
Build Records from Name - Value Lists
Dynamically create "where clause" based on feature attributes
Template: Convert KML name/value pairs from a list to new attributes
Eliminate unused attributes from a source schema
Regular expressions that work in one parameter,fail in another
ArcSDE Case Sensitivity | Attributes Not Written Correctly to ArcSDE
?2019安全亚搏在线软件公司|Legal