第8页
span4
使用FME有很多方法来操作和管理属性。This article will cover one of the ways.We will take a CSV file of cell signal data,基于属性值的组合,产生代表信号质量的点特征。
1.Read in the DataPoints CSV file
在画布上添加一个csv阅读器,reading in CellSignals.csv.在参数中,将经度和纬度的数据类型设置为X坐标和Y坐标,respectively.将坐标系设置为LL84,然后单击“确定”。
2.第二步。Test for Null,缺少值或为空
读取csv文件后,我们需要做的第一件事是过滤掉空值/缺少值/空值。将NullAttributeMapper Transformer添加到工作区。The空属性映射器Transformer用于评估所选属性是否为空,值缺失或为空,map those attribute values to a new value of 'missing' and route the newly mapped missing values to the inspector for further evaluation.在NullAttributeMapper参数中,设置映射到所有属性,单击“如果属性值为”,select all three values and click ok.然后为了让地图设置为失踪,this will change all null,缺少或空值到缺少,这将有助于以后的过滤。
Using the NullAttributeMapper,如果属性值为,然后映射到失踪
三。删除缺少的值
既然我们已经映射了所有的空值,missing,or empty values to read as missing,我们可以很容易地过滤掉它们。添加Tester变换到画布上。测试变压器用于评估一个特性的一个或多个测试。We will use the Tester to test to see if Latitude,经度,Power,质量,and num_measures contain missing values.在测试仪参数中,将左值设置为Latitude,set the Operator to Is Missing,then enable Negate,repeat this for longitude,Power,质量,以及num_度量,您可以使用“复制”按钮,只需更改属性即可。Finally,将通过标准设置为所有测试(和)。
Test out all missing attributes for Power,质量,num_measures,经纬度
4.Remove Duplicates
We have a lot of records and sometimes duplicates happen,luckily we can use the复制过滤器to easily remove duplicate latitude/longitude pairs.添加一个复制过滤器,并将其连接到测试仪上通过的输出端口。打开参数,并为关键属性选择纬度和经度。
5.Format date
下一步,我们需要重新格式化日期字段记录,因为它包含小时和分钟,我们只对日期感兴趣。为此,我们将使用datetimeconverter变压器,which is used to take an input date/time formatted in a specific way and output it in another way.为了DateTimeConverterto work correctly,您需要知道输入日期的格式,所以最好提前检查数据。
记录的格式为2011年4月12日1:04,which means the day can contain one or two values,月份包含一个或两个值,the year is the full year,the hour contains one or two values in 24-hour format,分钟包含两个值。输入格式如下:
%E/%n/%y%k:%m
我们希望这一天有两个价值观,有两个值的月份,今年要满了,全部用反斜杠隔开,which would look like 04/12/2011,对于输出格式,它是:
%m/%d/%Y
To find out which query you need,在datetimeconverter参数中有一个快速参考菜单。
在DateTimeConverter中,将输入格式设置为%e/%n/%y%k:%m,将输出格式设置为%m/%d/%y
6.Pattern match using Regular Expression
The ‘Code' attribute coming from the CSV file has a specific pattern.The first three characters are letters and the remaining characters are numbers (ABC3098330997).A simple regular expression can be used to extract them and create our codeTag and codeValue attributes respectively.
Using theStringSearcher我们将只从代码属性值中分离字母字符来创建代码标记属性。Add a StringSearcher transformer to the canvas,and connect it to the Output port on the DateTimeConverter.在参数中,搜索范围:代码,最后将正则表达式设置为[a-z][a-z][a-z]将匹配结果属性设置为codetag。
使用正则表达式,search for three alphabetic characters in Code
第七章。提取代码的其余部分
现在我们已经使用字符串搜索和正则表达式创建了代码标签,我们可以使用相同的正则表达式来提取代码的其余部分。Using the换弦器变压器,we will replace the alphabetic characters with nothing to isolate a codeValue attribute.Add a StringReplacer to the canvas,将其连接到StringSearcher上匹配的输出端口。在参数中,将属性设置为代码,and then set the Mode to Replace Regular Expression.For Text To Replace,使用步骤5中使用的相同正则表达式,[A-Z][A-Z][A-Z].将替换文本保留为空白,然后单击“确定”。
使用相同的正则表达式,remove the first 3 alphabetic characters to just keep the numeric values
8.Rename Code to CodeValue
我们使用StringSearcher更改了代码的值,但StringSearcher不允许属性重命名,所以我们需要使用AttributeRenamertransformer.在画布中添加一个属性名称,在参数中,for Input Value select Code,and for Output Value,将其重命名为codeValue。
9.筛选属性以缩小结果范围
我们只对代码标签为abc或abd的电台感兴趣,所以我们需要过滤掉它们。To do this we can use an属性筛选器将值路由到特定输出端口的转换器。This process can also be achieved with other transformers like the tester.向画布中添加一个attribute filter,并选择codetag作为要筛选的属性。添加abc和abd作为可能的属性值,然后使用向上箭头将这两个移动到上面列表的顶部
*Note: Steps 9-11 can be achieved using only the AttributeCreator and a Tester,选择以下方法来突出各种变压器的使用。要查看压缩方法,打开csvattributes.fmw工作区并查找压缩方法书签。
10.筛选属性以缩小结果范围
现在我们要按每个站点的功率级别组织和过滤数据,为此,我们将使用AttributeRangeFiltertransformer.使用attributerangefilter,我们可以使用power属性根据范围创建组,然后单独或作为一个组处理这些组。将attributerangefilter添加到画布,连接到attributefilter上的ABC和ABD输出端口。在参数中,对于“源”属性,选择“电源”,然后,对于范围查找,输入以下内容:
测试仪1 | 测试仪\2 | 测试仪\3 | Quality | > | -40 |
Quality | <= | -60 |
11.创建一个指示信号质量的属性
既然我们已经过滤掉了需要的功率等级,and then tested for the quality of the signal,我们需要在属性中识别它们。在每个测试变压器之后,添加一个AttributeCreator变压器,which we can use to create the attributes.对于连接到第一个测试仪的attributeCreator,创建一个名为qualityofsignal的属性,并给它一个最佳值。对于连接到第二个检测仪的下一个属性创建器,create the same attribute,但这一次给它一个合理的价值。For the final AttributeCreator,使用相同的属性名,但给它一个最坏的值。
12.从属性创建几何体
现在数据被清除了,我们可以使用纬度和经度属性在地图上可视化每个单元格信号。我们可以使用变极器创建点。将VertexCreator添加到画布并将其连接到AttributeCreator。在参数中,将X值设置为经度,Y值设置为纬度,将模式保留为添加点。
13.根据信号质量给点上色
Now that the points are created,我们希望通过使用不同的颜色来可视化信号属性的质量,这可以通过使用属性值管理器,which looks up attributes and assigns values based on other attributes.我们将使用此转换器使用信号质量属性中的三个值,并使用fme_颜色值为其指定颜色。在源属性的参数中选择QualityOfSignal,then for Destination Attribute enter fme_color.Then for Value Map enter the following:
Source Feature | 目标值 |
最佳 | 0,0,.15 |
Reasonable | 0,0.5,1 |
Worst | 0,1,1 |
使用attributeValueMapper根据点的值为点上色
14.写入映射信息选项卡
添加mapinfo选项卡(mitab)编写器并将属性定义设置为自动。Then connect it to the Output port on the AttributeValueMapper and then run the translation.Inspecting the output you should see that the points are colored by QualityOfSignal.
Output of the CellSignals colored by the QualityOfSignal.
Data Attribution
此处使用的数据源于温哥华市,不列颠哥伦比亚省。它包含根据开放政府许可证(温哥华)获得许可的信息。
© 2019 亚搏在线Safe Software Inc |Legal