斯潘8
斯潘4
尽管FME提供近500种不同的变压器,在某些情况下,用户可能希望将特定的ArcGIS地理处理工具应用于其数据。在FME的pythoncaller变压器中使用arcpy,工作区作者可以将该工具直接纳入其FME工作流程中,亚搏在线effectively extending FME's geoprocessing capabilities.
However,arcpy特征和fme特征具有非常不同的结构,and applying ArcPy tools to data using FME's feature-by-feature basis is quite a complex task.
So,不是试图将数据从一个结构转换为另一个结构,我们推荐的方法是:
在这个例子中,我们将在一组输入多边形上使用arcgis溶解工具。
注:功能性本文中提到的需要获得许可的Arcgis版本be installed on the same computer as FME.
源数据:数据压缩
Example workspace:arcpy-示例.fmw
源数据集是一组分区多边形,我们希望在通用分区类别的基础上进行分解。
Input
Output
为此,我们将使用arcpy溶解工具(documentation)
完成的工作区将整个过程包装成一个FME自定义转换器:
This creates a generic solution where,for example,用户可以更容易地选择要分解的功能组的属性。
Inside the custom transformer,必须执行许多步骤来准备用于地理处理的数据。
第一步是将特征类型(层/表名称)更改为一致的类型。In this case we use an AttributeCreator to tag each feature with a feature type value called ‘pre-dissolve':
This will be the name of the table created in the temporary geodatabase.
下一步是为此数据创建一个临时文件位置。一个名为temppathnamecreator的特殊转换器用于创建临时位置。However,because we only wish to generate a single location,我们首先用一个采样器将一个特性从其余特性中分离出来,并将这个特性发送给temppathnamecreator。
然后使用variablesetter和variableretriever将临时位置复制到所有其他功能。
NB:当工作区完成时,由temppathnamecreator创建的临时文件夹将自动清理。removing all the files you have written there.因为我们要把整个地理数据库文件夹放在那里,这很有用。
The final step required to create the temporary Geodatabase is to create a schema.To do this the sampled feature is passed through an FME Hub transformer called theSchemaSetter.
创建架构之后,所有功能都会发送到FeatureWriter,to write them to the temporary Geodatabase:
Notice that the temporary pathname is used to define the location to write to,fme_feature_type用于定义表名。还要注意,应用了动态模式定义设置,源架构(“来自架构的架构功能”)来自架构设置器转换器创建的架构。
NB:使用动态模式是我们生成可用于任何源数据的通用解决方案的另一种方法。
在开始Arcgis地质处理之前,还需要两个变压器。After creating the Geodatabase,the FeatureWriter outputs a summary feature containing the output dataset location as an attribute.因为(在Windows计算机上)它有向前和向后斜杠的组合,使用StringReplacer变压器清理路径。
最后,使用参数蚀刻器转换器来检索要分解的属性列表,extracting it from the User Parameter 'Group By'.
pythoncaller变压器执行arcpy处理。The code is as follows:
import fmeimport fmeobjectsimport arcpy def processFeature(feature): # Get dissolve FC and settings from feature attributes dataset = feature.getAttribute('_dataset') dissolveFields = feature.getAttribute('_Group_Attrs').split(",") arcpy.env.workspace = dataset # Set local variables inFeatures = "pre_dissolve" outFeatureClass = dataset + "/dissolved" # Execute Dissolve using group by attributes as Dissolve Fields arcpy.Dissolve_management(inFeatures,排水设施等级,溶解场,““多部分”“溶解管线”)
此代码从fme属性(feature.getattribute函数)中获取有关数据集的信息,然后使用该信息执行arcpy溶解工具。
Once the Python script's work is complete,and the dissolve done,要将功能恢复到FME工作区,需要一个FeatureReader Transformer。触发python脚本的摘要功能用作输入,通过属性提供源地理数据库位置。
我们在要读取的要素类型中指定了已分解的要素类,这样就不会同时读取原始要素类。After cleaning up the temporary attributes,溶解特性由变压器输出。
同样的过程可以用于任何一次完成整个要素类的arcpy要素处理。
如果ARCGIS与FME在同一台计算机上可用,它的地质处理工具可以通过使用蟒蛇来扩展FME的功能。特写和特写。
2017-10-04 13:33:05 56.8 0.0致命工厂代理未初始化2017-10-04 13:33:05 56.8 0.0致命F_(Pythonfactory):Pythonfactory未能处理功能有什么建议吗?
2017-10-04 13:54:59| 14.3| 0.0|ERROR |Python Exception提前谢谢: bad magic number in 'arcgisonlinefeatures': b'\x16\r\r\n'2017-10-04 13:54:59| 14.3| 0.0|ERROR |Could not create Python Reader `ARCGISONLINEFEATURES'2017-10-04 13:54:59| 14.5| 0.2|STATS |Stored 71487 feature(s) to FME feature store file `E:\FME_TEMP\full-inspect--1 125-1507143282390_35568.ffs'2017-10-04 13:54:59| 14.5| 0.0|INFORM|Saving spatial index into file 'E:\FME_TEMP\full-inspect--1 125-1507143282390_35568.fsi'2017-10-04 13:54:59| 14.5| 0.0|INFORM|Finished saving spatial index into file 'E:\FME_TEMP\full-inspect--1 125-1507143282390_35568.fsi'2017-10-04 13:54:59| 14.5| 0.0|ERROR |Could not create Python Reader `%0'
?2019安全亚搏在线软件公司|合法的