你好,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!
Dear 亚搏国际在线官网community,
我想创建一个霍顿序列,这意味着系统的随机分布点。I建立the appended python code.To call it: halton_sequence(十
,
3
)
Now,如何修改代码,以便在pythoncrator中使用它?I would need a list of coordinates to create the points.
Thank you for your help!
向pythonCaller和pythonCreator添加一个被拒绝的端口,其行为与sqlExecutor或featureMerge相同。这有助于避免某些Python脚本的转换失败,因为特性属性值是意外错误的。
Hi,
我希望可以在两个python转换器上添加多个输出端口。
这两个变压器中的初始代码需要对齐以匹配PEP8,e.g.
-类中函数之间的空行
-函数定义中关键字之间的空白
-pythoncaller类定义末尾的换行符
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,编码参数被忽略。
吸引力
(string)attrType
(int)吸引力编码
(string,可选)-如果attrType为fme_attr_encoded_string且未设置attrencoding,则默认为“utf-8”没有
FMEException
-如果发生错误,将引发异常,e.g.当转换失败时。我正在使用“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时,returnfme_宏值[“参数名”]作为一个对象instead of a一串,这样我们就可以值和定义of the Published/Private Parameter.
为什么会有帮助?
Every exemple of python caller I see would only modify attributes or add new attributes to each input feature.是否可以输出新功能或通过复制某些输入接收到的功能之外的更多功能?
Symptom
When running a workspace which uses any of:
FME日志中显示错误,表明找不到python,for example:
(pythonfactory):无法检测到python安装。PytonFactory无法初始化
There are at least two possible reasons for this issue:
1。在FME Workbench 2016.1中,导航器中有一个名为“python解释器”的高级工作区参数,其中包括版本3.4+作为选项。但是,只有2.7版提供了FME 2016.1。
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调用者),然后在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].
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:
pythoncaller变压器提供了一种扩展FME功能的强大方法,当没有本地变压器可用时。在python中使用地理空间数据的一组关键工具是gdal库和python绑定。然而,目前使用gdal(或ogr,或各种相关的库)不工作在Linux上的FME服务器中。这意味着蟒蛇的主要用途之一——扩展FME本身的能力——休息。
>>>从osgeo导入gdal>>打印gdal.getDriverCount()207
在蟒蛇中,I create a dictionnary.我想在下面的变压器中使用它,a PythonCaller as an attribute.
所以在创造者身上,我以“还我的听写”结尾。在呼叫者中,我把属性称为mydict。
但是当我运行这个项目时,在日志中,it tells me that :
类型错误:“nonetype”对象不可iterable
你有什么建议吗?
谢谢
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
谢谢