Solved

FMEUniversalReader.open() dataset and parameters arguments: what information needed and how to format it for ArcGIS Online Feature Service reader type?

  • 21 March 2023
  • 1 reply
  • 2 views

Badge +1

I have a Group in my company ArcGIS Online (AGOL) that holds multiple, shared, hosted feature layers, each based on a feature service and having multiple layers both spatial and non-spatial.  As such, each hosted feature layer is a Feature Layer Collection in Esri-speak.  Many of the non-spatial layers in a hosted feature layer are attachment tables, so others are relationship tables.  I need to read the schemas (as schema features) of every layer in every hosted feature layer into one big stream.  Alternatively, I could read all the features and shove them through a SchemaScanner.  In either case, I need FME entities, and I need to be able to loop through all the hosted feature layers.  Because FME FeatureReaders for AGOL Feature Services can process only one feature service at a time, I can't process all the hosted feature layers in the same workspace run.  I can think of a way to use multiple worksapces and WorkspaceRunner s to do the required looping, but that is kludgy and complex and not to the liking of my superiors, or myself for that matter.  So, I am trying to accomplish the task in a single workspace by using a PythonCaller, the ArcGIS API for Python, and the fmeobjects FMEUniversalReader.  That way, I can access and loop through all the hosted feature layers with python and API code and use an FMEUniversalReader in each loop to grab the schema features.  Herein lies the problem:  I do not know the format of the dataset and parameters arguments for the FMEUniversalReader.open() method.  I have:

#  ... a bunch of python and API looping code, then
ur = fmeobjects.FMEUniversalReader('ARCGISONLINEFEATURES', False, 
                                                              ['SCHEMA_FORMAT_ATTRIBUTES', 'YES'])
ur.open(dataset, parameters)

The instantiation (line 2) works fine, but  the open() call is a black box for me.  I really don't know what to enter for dataset and parameters in this AGOL case.  The documentation is sorely incomplete, and I can find no examples, either.  My guess is that dataset will involve a layer URL of some sort and that paramters will contain at least an AGOL login username and password, but I honestly don't know.  If anyone can tell/show me what that   ur.open()  line is supposed to look like--including what parameters are required and their syntax/format--I would very much appreciate it.  I think this is the solution I need, but I have to get the FMEUniversalReader working for AGOL.  Thank you all for your help.

icon

Best answer by daveatsafe 24 March 2023, 00:14

View original

1 reply

Userlevel 2
Badge +17

Hi @tcrossman​,

You can use the FMEDialog object to return the reader parameters for the the AGOL reader, to see which you need to supply to the UniversalReader. Use a PythonCaller with the following code:

import fme
import fmeobjects
 
def getParameters(feature):
    dialog = fmeobjects.FMEDialog()
    results = dialog.sourcePrompt('ARCGISONLINEFEATURES','')
    print(results)

Running the workspace will open a reader dialog for AGOL. Set up the reader for one of your AGOL Feature Services, then click OK. Look in the log for the results, which will look something like:

('ARCGISONLINEFEATURES', '<Unused>', ['RUNTIME_MACROS', 'FORMAT_GUID,YES,NC,dcampanas<space>Esri<space>ArcGIS<space>Online,FEATURESERVICE,SafeEOL/qa_testing_title(f08c638d0d3947fcaeedde14f1f97bff),TABLELIST,"Line_layer ""Point layer"" Polygon.layer.testing_titles",RESOLVE_DOMAINS,No,AGOL_ADV_PARM_GROUP,FME_DISCLOSURE_OPEN,FEATURES_PER_REQUEST,1000,EXPOSE_ATTRS_GROUP,,ARCGISONLINEFEATURES_EXPOSE_FORMAT_ATTRS,,USE_SEARCH_ENVELOPE,NO,SEARCH_ENVELOPE_MINX,0,SEARCH_ENVELOPE_MINY,0,SEARCH_ENVELOPE_MAXX,0,SEARCH_ENVELOPE_MAXY,0,SEARCH_ENVELOPE_COORDINATE_SYSTEM,,CLIP_TO_ENVELOPE,NO,QUERY_FEATURE_TYPES_FOR_MERGE_FILTERS,Yes,CREATE_FEATURE_TABLES_FROM_DATA,Yes,_MERGE_SCHEMAS,YES', 'META_MACROS', 'SourceFORMAT_GUID,YES,SourceNC,dcampanas<space>Esri<space>ArcGIS<space>Online,SourceFEATURESERVICE,MyTest/qa_testing_title(f08c638d0d3947fcaeedde14f1f97bff),SourceRESOLVE_DOMAINS,No,SourceAGOL_ADV_PARM_GROUP,FME_DISCLOSURE_OPEN,SourceFEATURES_PER_REQUEST,1000,SourceEXPOSE_ATTRS_GROUP,,SourceARCGISONLINEFEATURES_EXPOSE_FORMAT_ATTRS,,SourceUSE_SEARCH_ENVELOPE,NO,SourceSEARCH_ENVELOPE_MINX,0,SourceSEARCH_ENVELOPE_MINY,0,SourceSEARCH_ENVELOPE_MAXX,0,SourceSEARCH_ENVELOPE_MAXY,0,SourceSEARCH_ENVELOPE_COORDINATE_SYSTEM,,SourceCLIP_TO_ENVELOPE,NO,SourceQUERY_FEATURE_TYPES_FOR_MERGE_FILTERS,Yes,SourceCREATE_FEATURE_TABLES_FROM_DATA,Yes', 'METAFILE', 'ARCGISONLINEFEATURES', 'COORDSYS', '', 'IDLIST', 'Line_layer,"Point layer",Polygon.layer.testing_titles'])

The list after 'RUNTIME_MACROS' are the parameters that can be sent to the open call, in the format [name, value, name, value....]. Not all parameters are needed - in this case, I think just NC (web connection), FEATURESERVICE and TABLELIST - but it would be safest to set all of them, at least to the default values above.

 

 

Reply