span8
斯潘4
我们通常希望将JSON文件转换为空间格式,如KML。然后我们可以在GoogleEarth中打开这个文件来显示。We could also choose to transform to any other format with geometry such as a Shapefile.VertexCreator是一个将坐标附加到空值的转换器,点line and arc geometry,which will be used in the following exercise.协调系统设置器变压器后面是属性创建器。At the end of 亚搏在线workflow are three KML Stylers which are covered in other tutorials.
Source JSON: rentalstandardscurrentissues.json (file) orftp://webftp.vancouver.ca/opendata/JSON/RentalStandardsCurrentIssues.json
Completed workspace:jsonread-json2kml.fmwt
The City of Vancouver offers open data in JSON format,如果您有兴趣了解更多数据,请浏览:http://data.couver.ca/datacatalogue/index.htm
Take a look at the source data in the Data Inspector or a text editor like Notepad++.Depending on whether its structure is flat or nested,我们将在读卡器中选择不同的参数。There are four options to choose from:
1)具有自动模式扫描模式的JSON
2)带有JSON查询模式扫描模式的JSON
3) GeoJSON with Auto schema scan mode
4) GeoJSON with JSON Query schema scan mode
1.Select Generate Workspace from the Start tab.
In order to select elements to use as feature types,必须打开一个JSON文件,read and attributes selected in FME Workbench.This exercise will use City of Vancouver data,specifically ‘RentalStandardsCurrentIssues.json',which is a data set from 2016 with a list of Rental Issues.A file in JSON format can be downloaded from the City of Vancouver's Open Data Catalogue (http://data.vancouver.ca/datacatalogue/index.htm).It will be read and transformed into a KML file.The data will be classified and displayed in Google Earth.
2。Specify Reader dataset.
选择JSON作为“格式”。对于数据集,导航到下载的rentalstandardscurrentripus.json或复制并粘贴ftp://webftp.vancouver.ca/opendata/JSON/RentalStandardsCurrentIssues.json到数据集部分。
3.Set Parameters for the reader.
输入读卡器的参数,set the Schema Scan Mode to JSON Query.The default JSON Query json[*] is used in this example.如果单击特性对象JSON查询旁边的省略号“…”,it is possible to see the nested structure of the file and select an item from the list to create a more specific JSON query.While Auto mode can be used for simpler JSON structures,我们将在这里使用json查询(jquery)模式,因为它更灵活。只有在jquery模式下,我们才能选择新树控件中感兴趣的特性,否则这些特性将变灰。将几何格式设置为geojson。
如果处理其他JSON数据,请考虑以下选项:With simple data sets,leave Schema Scan mode as Auto,如果数据更为嵌套,请将几何类型设置为geojson,如果深度嵌套,则将模式扫描模式更改为jquery。
指定JSON数据集和参数
JSON Query tree view
JSON读卡器参数
4。Set Writer parameters.
Please select KML as the format and choose a destination for the output data.命名kml文件rentalstandardsisues.kml
5。选择功能类型。
当“选择要素类型”对话框提示时,取消选中元数据,然后单击确定。
6.在读卡器功能类型之后添加VertexCreator。
In the VertexCreator transformer Parameters set attribute Longitude for the x value and attribute Latitude for the y value.
7.添加coordinateSystemsetter变压器
将坐标系参数设置为LL84。
8.Add the AttributeCreator transformer and create a new attribute.
在新属性下添加属性“issueratio”。在属性值字段中单击,单击箭头选择下拉列表项“打开算术编辑器”。双击FME特征属性并输入要创建的其他字符:
@Value(TOTALOUTSTANDING)/@Value(TOTALUNITS)*100
Equation for IssueRatio in the Arithmetic Editor
The AttributeCreator Parameters with ArithmeticEditor Results
9。添加kmlpropertySetter变压器
The next transformer that we will add is the KMLPropertySetter.在参数中,under Navigation Tree,please set Name to "TOTALUNITS".
10。Add the AttributeRangeFilter transformer
下面的变压器“attributerangefilter”允许我们对数据进行分类。在“源属性的参数”下,选择“issueratio”。In the Range Lookup Table enter in the fields underneath From and To the values of your range.对于此示例,填充如下:
从 | 到 |
0 | 五 |
5.01 | 10 |
10.01 | 一百 |
输出端口列将自动填充。请注意,您可以将您的工作流与本文末尾的工作流进行比较。亚搏在线
11.Add KMLStyler transformers
The next step involves the KMLStyler that will be added three times and connected to the "CurrentIssues" writer that will output a file called RentalStandardsIssues.kml in our specified directory.
12.设置kmlstyler的参数
Click the parameters of the KMLStyler connected to the lowest range port (0 ..5)设置符号。Under Icon,单击名称旁边的省略号按钮[…]查看选项,将名称设置为蓝色三角形(A1)。Set scale to 0.5.
单击第二个kmlstyler属性,将中间范围的符号设置为5.01到10。在“名称”旁边的部分中选择一个橙色三角形(b2)。set scale to 0.5.
The third KMLstyler properties' are set to a green rectangle (D2),10.01至100,缩放至0.5。Connect the three KMLStylers to the writer "CurrentIssues".保存并运行工作区。
13。Display the classified records in Google Earth
通过右键单击每个kmlstyler变压器并选择“连接检查器”,我们可以在数据检查器中显示这些点。右键单击Writer功能类型,然后选择“打开包含文件夹”以查找kml文件rentalstandardsisues.kml。Open the KML file in Google Earth.您将看到显示单位数和颜色符号的点特征。The records will appear color coded according to our symbology that we are setting in the KMLStyler.372条记录分为3个范围,105条,60和201记录在三个范围内。六个记录过滤。
Google earth view of the current rental issues in Vancouver displaying the number of units color coded according to the three ranges: Blue has 0 to 5 incidences,orange has 5.01 to 10 and green has 10.01 to 100 rental issues.
本练习演示了从JSON到空间格式(GIS)的简单数据转换。
JSON Reading Advanced
JSON Writing Overview
JSON Writing with JSONTemplater
?2019安全亚搏在线软件公司|合法的