Skip to main content

Hi,

 

I have a toolbox in ArcPro that is creating a csv with list of all layers present in webappliction. Is there a way that I can run that script from FME and get the same result? I cannot access the content of the webmap in FME as I am using SingleSignOn to log in into EsriEnterprise. 

 

It depends, but in general, with a tool in ArcGIS Pro, you are able to get the Python code and you can put this in a PythonCaller and run it with FME.

When clicking on the small arrow next to Run, you will be able to choose Copy Python Command.

 

Copy paste this in the PythonCaller, for example:

 

import fme

import fmeobjects

import arcpy

class FeatureProcessor(object):

    def __init__(self):

        pass

        

    def has_support_for(self, support_type: int):

        return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM

  

    def input(self, feature: fmeobjects.FMEFeature):

        arcpy.management.DefineProjection(r"C:\Data\test.gdb\test",'PROJCSD"RD_New",GEOGCSs"GCS_Amersfoort",DATUMO"D_Amersfoort",SPHEROIDT"Bessel_1841",6377397.155,299.1528128]],PRIMEM9"Greenwich",0.0],UNITR"Degree",0.0174532925199433]],PROJECTION7"Double_Stereographic"],PARAMETERe"False_Easting",155000.0],PARAMETERa"False_Northing",463000.0],PARAMETERr"Central_Meridian",5.38763888888889],PARAMETER5"Scale_Factor",0.9999079],PARAMETERa"Latitude_Of_Origin",52.15616055555555],UNITi"Meter",1.0]]')

        self.pyoutput(feature)

    def close(self):

        pass

    def process_group(self):

        pass

 

Make sure Python Compatibility is set to Esri ArcGIS Python 3.7+ (Navigation panel, Workspace Parameters, Scripting) and run it.


Hi nielsgerrits,

 

Unfortunately, this solution will not work. I have to ask FME to run ArcPro Toolbox inside ArcPro. 

 

In general, I am struggling to get the list of all layers included in webmap. I was trying to run the script from

but I get an error 

2024-04-12 14:23:00| 8.3| 0.0|ERROR |Python Exception <AttributeError>: 'tuple' object has no attribute 'content'2024-04-12 14:23:00| 8.3| 0.0|ERROR |Traceback (most recent call last):2024-04-12 14:23:00| | |ERROR | File "<string>", line 22, in input2024-04-12 14:23:00| | |ERROR |AttributeError: 'tuple' object has no attribute 'content'2024-04-12 14:23:00| 8.3| 0.0|ERROR |Error encountered while calling method `input'2024-04-12 14:23:00| 8.3| 0.0|FATAL |PythonCaller_7 (PythonFactory): PythonFactory failed to process feature

I would appreciate some help as I am running in circle. In general I do not have to use the Python, I am happy to use ArcGISOnlineConnector but I was not able to expose the list of the layers in the webmap.


Hi,

 

In general, I have a script that allows me to get the list of layers from webmap. However, it does not seem to work as the code contains

gis = (home").

 

I was trying to use @nielsgerrits script from 

 but I got an error

2024-04-12 14:23:00| 8.3| 0.0|ERROR |Python Exception <AttributeError>: 'tuple' object has no attribute 'content'2024-04-12 14:23:00| 8.3| 0.0|ERROR |Traceback (most recent call last):2024-04-12 14:23:00| | |ERROR | File "<string>", line 22, in input2024-04-12 14:23:00| | |ERROR |AttributeError: 'tuple' object has no attribute 'content'2024-04-12 14:23:00| 8.3| 0.0|ERROR |Error encountered while calling method `input'2024-04-12 14:23:00| 8.3| 0.0|FATAL |PythonCaller_7 (PythonFactory): PythonFactory failed to process feature

I am happy to use any FME transformer that will give me the list I want


Hi @marta.podsiad looks like you might be hitting an error due to a programming typo. If you are using the PythonCaller code shared in this thread then you might be running into an error where you import arcgis.gis.GIS but forget to actually use it in gis = ...  and accidentally define a bare tuple instead of passing arguments to GIS. so a few lines later an error is raised because the code is trying to do gis.content.get(...) when gis is just a tuple. 

I used double # to indicate new comments. I’m not particularly an expert, but I hope this helps. 

import fme
import fmeobjects
## this is where you import GIS
from arcgis.gis import GIS
from arcgis.mapping import WebMap

class FeatureProcessor(object):

def __init__(self):
pass

def has_support_for(self, support_type: int):
return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM

def input(self, feature: fmeobjects.FMEFeature):

# Connect to your ArcGIS Online organization or Portal for ArcGIS
## you should also use GIS in this argument
gis = ("https://maps-eu.ramboll.com/portal", "USERNAME", "PASSWORD")

# Get the web map item by its ID
web_map_id = "ITEMID"

## gis is currently an empty tuple because of the above not using GIS
web_map_item = gis.content.get(web_map_id)
web_map = WebMap(web_map_item)

# Create an empty list to store layer names
layer_names = ]

# Append each layer name to the list
for layer in web_map.layers:
layer_names.append(layer.title)

# Create a feature with the list of layer names
feature_out = fmeobjects.FMEFeature()
feature_out.setAttribute("layer_names", layer_names)
self.pyoutput(feature_out)

def close(self):
pass

def process_group(self):
pass

 


Reply