主题中的问题:“pythoncreator” https://knowledge.亚搏在线safe.com/questions/topics/single/20082.html网站 “蟒蛇创造者”主题的最新问题 通过使用python api索引行/列来进行单元化光栅操作 https://knowledge.亚搏在线safe.com/questions/86561/cellwise-graster-manipulation-by-indexing-rowcol-us.html

你好,I need to use FME to do some custom cellwise manipulation of different rasters.


我对FME很陌生,but so far my plan is to import rasters using a GeoTIFF reader and then doing custom manipulations in a PythonCreator transformer.理想情况下,我希望能够执行相当于操作一个numpy数组的操作,但我很明显地意识到,这些行动确实有所不同。


到目前为止,我已经收集到您可以使用getBand()访问RasterData中的不同频段,however I am uncertain in regards to how you go about accessing the data itself and further,how you can change individual values and so on.我也读过瓦片,and seen examples such as " prevData = prevRaster.getBand(0).getTile(0,0,tile).getData() " (by高桥)但我对如何更改光栅中的单个数据点不太确定。


一个方面的问题,在Pythoncreator中,排除代码故障的最佳/首选方法是什么?


Any help would be greatly appriciated!



python 光栅 巨嘴鸟 python scripting Python创建者 Thu,2019年2月7日15:08:51格林威治标准时间 拉古诺
用python创建一个halton序列 https://knowledge.亚搏在线safe.com/questions/81538/create-a-halton-sequence-with-python.html

Dear 亚搏国际在线官网community,

我想创建一个霍顿序列,这意味着系统的随机分布点。I建立the appended python code.To call it: halton_sequence(,3Now,如何修改代码,以便在pythoncrator中使用它?I would need a list of coordinates to create the points.

Thank you for your help!


Python创建者 sample 结婚,31 Oct 2018 16:56:16 GMT 文森特斯切尔
将拒绝的端口添加到pythoncaller https://knowledge.亚搏在线safe.com/idea/66759/add-rejected-port-to-the-pythoncaller-1.html

向pythonCaller和pythonCreator添加一个被拒绝的端口,其行为与sqlExecutor或featureMerge相同。这有助于避免某些Python脚本的转换失败,因为特性属性值是意外错误的。

巨嘴鸟 Python创建者 Sat,2018年3月24日格林尼治标准时间21:19:15 艾迪泽
Multiple Output Ports on PythonCreator and PythonCaller https://knowledge.亚搏在线safe.com/idea/59444/multiple-output-ports-on-pythoncreator-and-pythonc.html

Hi,

我希望可以在两个python转换器上添加多个输出端口。

巨嘴鸟 Python创建者 output output port Thu,07 Dec 2017 09:43:11 GMT 扒窃的
PytonCreator和PytonCaller PEP8修复程序 https://knowledge.亚搏在线safe.com/idea/57676/pythoncreator-and-pythoncaller-pep8-fixes.html

这两个变压器中的初始代码需要对齐以匹配PEP8,e.g.

-类中函数之间的空行

-函数定义中关键字之间的空白

-pythoncaller类定义末尾的换行符

巨嘴鸟 Python创建者 FRI,2017年11月10日09:13:06格林尼治标准时间 crayxt
python api:fmefeature类的新setattributeType()方法 https://knowledge.亚搏在线safe.com/idea/50224/python-api-new-setattributeType-method-for-fmefeat.html

fmeFeature类上已存在getAttributeType()方法,但能设置(=convert!)它,if this is feasible.This is useful if we want to enforce/maintain a certain character encoding (as discussed在这里)或者如果我们想把一个整数转换成一个布尔值,实数等的数字字符串。等。

方法可能如下所示:

setAttributeType(吸引力attrType,[吸引力编码]

Sets/converts an attribute into another type.属性类型必须是FME_ATTR_UNDEFINED,FME_ATTR_BOOLEAN,FME-TraceTIN 8,FMIL,FME_ATTR_INT16,FM16,FME_ATTR_INT32,FM2接口32,FMEA TraceReal32,FME_ATTR_REAL64,FMEA TraceReal80,FME-TraceToupe字符串,fme_attr_编码的_字符串,FMEA Trace64,FME_ATTR_UINT64.
For FME_ATTR_ENCODED_STRING only,用户可以指定字符编码(例如“ISO-8895-1”。Otherwise,编码参数被忽略。

Parameters:
  • 吸引力(string)
  • attrType(int)
  • 吸引力编码(string,可选)-如果attrType为fme_attr_encoded_string且未设置attrencoding,则默认为“utf-8”
Returns: 没有
Raises:
  • FMEException-如果发生错误,将引发异常,e.g.当转换失败时。
python 巨嘴鸟 FME对象 python scripting Python创建者 Thu,2017年8月10日12:16:09格林尼治标准时间 砂光机
geojson编写器错误中的pythonCreator功能类型 https://knowledge.亚搏在线safe.com/questions/49563/pythoncreator-feature-type-in-geojson-writer-error.html

我正在使用“pythonCreator”和“pythonCaller”转换器创建一系列SQL select语句。The latter are used in a 'SQL Executor' transformer to read many features from an oracle db.最终,these features have to be written to .json files.

Because I initially used the PythonCreator,所有功能都将“FME”功能“类型”设置为“pythoncreator”。在fme desktop 2017.0中使用geojson writer时(构建17259,64位)这将导致错误消息:“未知功能类型”pythoncreator“传递给JSON编写器”。其他作者(SDF,形状,擅长,etc.) work fine.

如果我使用属性管理器将“fme-feature-type”属性设置为其他值,作者工作得很好。

有人能解释为什么作者对一个名为pythoncreator的FME特性类型有问题吗?

我在有关geojson作者的文档中找不到答案;so that is why I am asking it on this platform.

python 杰森 feature types 吉森 Python创建者 Thu,2017年8月3日08:55:51格林尼治标准时间 jneujens
Return FME_MacroValues as parameter value AND definition https://knowledge.亚搏在线safe.com/idea/48019/return-fme-macrovalues-as-parameter-value-and-defi.html

想法

使用python时,returnfme_宏值[“参数名”]作为一个对象instead of a一串,这样我们就可以值和定义of the Published/Private Parameter.

为什么会有帮助?

  • 它允许我们查看参数是否私人的,公众和/或Optional.
  • 我们可以看到默认值是。It can be handy to have this value in case the Python code needs to resort to another solution if the value that the user entered produces the wrong result.
  • 我们可以从Prompt)所以我们可以创建好的日志消息,这是另一种用户反馈,比如说,告诉参数值是错误的。
  • We could read theConfiguration对于一个选择例如,参数,in the same order in which the choices are specified in the Definition dialog.然后,we could check if the parameter value is equal to a configuration list itemby index,so that we no longer need to hardcode all the choice values in the PythonCaller if we want to run a different function for each choice for instance.如果我们在参数定义对话框中更改一个选择值,这就降低了破坏代码的风险。只有当我们改变选择的顺序时,它才会破裂(或产生意想不到的结果)。但我可以忍受。
  • 如果我们有一个物体,there might also be an additional property inside that tells us what native Python type the parameter value can be converted to.Or better yet,只需以python类型返回参数值…

python 巨嘴鸟 parameters FME对象 python scripting Python创建者 FRI,2017年7月14日格林尼治标准时间21:58:08 砂光机
在Python调用程序中创建新功能 https://knowledge.亚搏在线safe.com/questions/40316/create-new-features-within-a-python-caller.html

Every exemple of python caller I see would only modify attributes or add new attributes to each input feature.是否可以输出新功能或通过复制某些输入接收到的功能之外的更多功能?

巨嘴鸟 python scripting Python创建者 星期二,2017年2月21日13:25:38格林尼治标准时间 弗查梅尔
错误:无法检测到python安装 https://knowledge.亚搏在线safe.com/articles/39024/error-a-python-installation-could-not-be-detected.html

Symptom

When running a workspace which uses any of:

  • 基于python的格式
  • 蟒蛇或蟒蛇变压器
  • Startup or Shutdown Python Script

FME日志中显示错误,表明找不到python,for example:

(pythonfactory):无法检测到python安装。PytonFactory无法初始化

Resolution

There are at least two possible reasons for this issue:

1。在FME Workbench 2016.1中,导航器中有一个名为“python解释器”的高级工作区参数,其中包括版本3.4+作为选项。但是,只有2.7版提供了FME 2016.1。

  • 将此选项更改为2.7版

  • Or set FME to use your own installed python 3.4+ interpreter following these指令.

2。If FME has been configured to use a different python interpreter than the one installed by FME,确认此python解释器仍然可用。在FME Workbench中,转到菜单工具>FME选项>翻译,并查看首选python解释器。确认给定的路径仍然有效。

python 巨嘴鸟 Python创建者 结婚,2017年1月25日12:10:08格林尼治标准时间 肯纳特保险亚搏在线柜
将来自python的日期作为已发布参数传递 https://knowledge.亚搏在线safe.com/questions/36190/passing-a-date-from-python-as-a-published-paramete.html

我正在尝试创建一个工作区,在运行时将当前日期拉入python(作为启动脚本或python调用者),然后在fme中将该日期作为已发布参数传递出去。我在python中有以下内容:

导入日期时间
today=datetime.datetime.now()。
#打印str(今天)
今天打印.strftime(“%y%m%d”)

这告诉我(今天)的日期是20161103

我想把它作为一个已发布的或私有的参数[开始日期]传递出去,以便在稍后的过程中在转换器中读取。

I will also need to be able to calculate a date two weeks away and pass that as [End_Date].

python 巨嘴鸟 启动脚本 Python创建者 Thu,2016年11月3日18:24:15格林尼治标准时间 JIMQ66
提供访问pythoncaller中命名连接的权限 https://knowledge.亚搏在线safe.com/idea/32677/provide-access-to-named-connections-in-pythoncalle.html(https://knowledge.safe.com/idea/32677/provide-access-to-named-connections-in

It would be great if the PythonCaller could get access to FME named connections,即使以模糊的方式,用于连接到网站和数据库。

For example,making a web connection available in the PythonCaller as a requests.auth object for use by the "requests" module for HTTP requests:

  • http://docs.python-requests.org/en/master/user/authentication/

巨嘴鸟 Python创建者 星期二,23 Aug 2016 20:52:56 GMT 尼克朗
在Linux上增强FME服务器,以便pythoncaller脚本可以使用gdal/ogr和相关库 https://knowledge.亚搏在线safe.com/idea/32340/enhance-fme-server-on-linux-so-pythoncaller-script.html

pythoncaller变压器提供了一种扩展FME功能的强大方法,当没有本地变压器可用时。在python中使用地理空间数据的一组关键工具是gdal库和python绑定。然而,目前使用gdal(或ogr,或各种相关的库)不工作在Linux上的FME服务器中。这意味着蟒蛇的主要用途之一——扩展FME本身的能力——休息。

问题

我的方案是使用基于Python的方法计算光栅 zonal statisticsvia an FME 亚搏在线workflow.The FME processing creates or supplies the zone geometries and then the Python code loads the raster files directly from disk via the GDAL library,calculates the zonal statistics,and outputs them on FME features.这样就可以快速计算出大量(数万)光栅文件的分区统计数据,使用FME帮助管理结果。This works very well in FME Desktop,但在Linux上的服务器中,由于Python中的gdal库无法加载光栅文件,所以失败了。
The issue can be demonstrated very simply.Running the following code in a Python interpreter on Windows,或者在Linux机器上的系统解释器上,将返回一个数字,指示gdal可以读取多少格式:
>>>从osgeo导入gdal>>打印gdal.getDriverCount()207
数字将根据具体安装的内容而有所不同。然而,在Linux上发布到FME服务器的工作台上的pythoncaller或pythoncreator中运行此代码,outputs a value of 0,indicating that GDAL cannot read any data formats.
I think this fails because FME has its own built-in copy of some parts of GDAL and this isn't meant to be used other than for FME itself,所以它可能是在没有内置的东西的情况下编译的。However instead of removing the unnecessary symbols from the FME-supplied library,他们在那里,但残废了。因为python在FME过程中运行,当试图加载gdal库时,python代码也会显示gdal库的fme副本,not the system one,因此无法读取任何gdal数据。

可能的解决方案

我认为至少有两种方法可以解决这个问题:

  1. Customising the FME-internal version of GDAL a bit more so that the functions (symbols) it provides don't conflict with the original GDAL ones.所以当python gdal库试图调用本地gdal函数时,它安装了正确的系统,而FME内部的东西是这样的,不会被用户的代码“意外”调用。我认为作为一个用户,我不应该让我的python代码意外地调用那些应该是fme代码内部的东西。(Note,the same issue I'm describing here used to also happen with the SQLite library,它在服务器上的python代码中也不起作用,但是,在服务器的最新版本中已经修复了这个问题,因为服务器不再具有该库的特定于FME的版本。所以这里有可能发生变化!)
  2. 增加在pythoncaller或pythoncreator中运行的python环境的分离。I don't know how or if this could be done.但是,由于在Linux上,FME使用系统python解释器,然后我认为期望在命令行中工作的python代码是合理的,也可以通过故障模式与影响分析(FME)进行工作。

python 光栅 巨嘴鸟 Linux Python创建者 星期二,2016年8月16日16:50:00格林尼治标准时间 哈里13
在两个变形金刚之间传输python dictionary https://knowledge.亚搏在线safe.com/questions/30419/transfer-python-dictionary-between-2-transformers.html

在蟒蛇中,I create a dictionnary.我想在下面的变压器中使用它,a PythonCaller as an attribute.

所以在创造者身上,我以“还我的听写”结尾。在呼叫者中,我把属性称为mydict。

但是当我运行这个项目时,在日志中,it tells me that :

类型错误:“nonetype”对象不可iterable

你有什么建议吗?

谢谢

python 杰森 巨嘴鸟 Python创建者 结婚,29 Jun 2016 08:16:38 GMT slerendu
python启动或参数问题,声明多个变量 https://knowledge.亚搏在线safe.com/questions/20640/python-startup-or-parameter-issue-declaring-multi.html

Hi

我想运行1个python发布的参数,或者运行一个可以设置为访问变量的启动脚本。

这些是文件名,但我需要两个文件名的原因是为了确保它们都存在。

下面是测试时带有一些硬编码值的python:

import-osinfolder=r'c:/temp/2015_11_26'flow_data=[]speed_data=[]setlist=[]扫描所有文件/子目录etcor根目录,迪尔斯,os.walk中的文件(infolder):使用XML的原因是他们需要XML…不知道文件中[f对于f对于f对于f如果f.endswith(“.xml”)中的文件:如果文件中的“speed”,则打印文件:打印文件speed u file=os.path.join(根,files.split(''u')[0])speed_data.append(speed_file)elif'flow'in files:flow_file=os.path.join(根目录,files.split(''u')[0])Flow_data.append(Flow_file)else:打印“不正确的文件”,f将匹配项放入列表中,以检查它们是否存在于setmatch in set(流数据)&set(速度数据):set list.append(setmatch)for itemlist in set list[:1]:speed _data _xml=os.path.join(根,itemlist+'_2015-10-01_to_2015-10-31_aveSpeedData.xml')流\u data_xml=os.path.join(根,项目列表+'_2015-10-01_to_2015-10-31_flowdata.xml')

现在,我想让speed-data-xml和flow-data-xml作为单独的参数,作为两个源调用?两个.jpg(16.7 kb)

so i would have another python parameter ie:

import pyfmespeed_filename = speed_data_xmlreturn speed_filename

谢谢

Python创建者 FRI,2015年11月27日16:17:54格林威治标准时间 阿布恩