2

I am trying to access a feature layer within my Portal using the layers path. I have been accessing the data within Visual Studio Code using the feature layers ID like this:

feature_service_layer = gis.content.get('964b4b7b112347e9ff76609bfc75432').layers[0]

I'd like to make a Geoprocessing tool out of the code. The tool would accept the parameter under the format of the URL which would be something along the lines of: 'https://maps.portaladdress.com/arcgis/rest/services/Hosted/Feature_layer/FeatureServer/0'

I have tried to add the URL to the code but it is unsuccessful. Here is what it looked like (I also tried the .Search method):


feature_service_layer = gis.content.get(https://maps.portaladdress.com/arcgis/rest/services/Hosted/Feature_layer/FeatureServer/0)

feature_service_layer = gis.content.search(https://maps.portaladdress.com/arcgis/rest/services/Hosted/Feature_layer/FeatureServer/0)

If I can't use these methods how am I supposed to take a feature layer in as a parameter and access its data?

2
  • @user2856 where will it create that feature layer? My default geodatabase within the pro project? Commented Sep 28, 2023 at 14:39
  • Layers aren't featureclasses. It'll just make a layer in memory that points at the url. Look at the examples in the documentation for arcpy.management.MakeFeatureLayer Commented Sep 28, 2023 at 21:04

1 Answer 1

3
from arcgis.gis import GIS
from arcgis.features import FeatureLayer

agol = GIS("home")

url = "https://maps.portaladdress.com/arcgis/rest/services/Hosted/Feature_layer/FeatureServer/0"
fl = FeatureLayer(url, gis=agol)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.