Select to view content in your preferred language

How to access map service layer in Python toolbox?

3498
2
06-02-2014 12:40 AM
RamiGhaly1
New Contributor
Hello,

I have a URL of a map service layer. How I can access this layer URL from python toolbox. (i.e create featureset from the layer URL).
Is it possible ?

Thanks and Regards.
Tags (2)
0 Kudos
2 Replies
AdamCox1
Deactivated User
Hi Rami, I believe this previous question is very close to yours and you should be able to find the answer here: http://forums.arcgis.com/threads/8414-ArcGIS-10-user-python-arcpy-to-add-a-WMS-Service?p=391096#post...
0 Kudos
RamiGhali2
Deactivated User

I got this snippet from a friend.

I didn't try it.

*********************************************************************************************************************************************

import arcpy

# Modify the following variables:

# URL to your service, where clause, fields and token if applicable

baseURL= "http://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer/1/query"

where = '1=1'

fields ='apn, address, pool_permit'

token = ''

#The above variables construct the query

query = "?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, fields, token)

# See http://services1.arcgis.com/help/index.html?fsQuery.html for more info on FS-Query

fsURL = baseURL + query

fs = arcpy.FeatureSet()

  1. fs.load(fsURL)

arcpy.CopyFeatures_management(fs, r"c:\local\data.gdb\permits")

**********************************************************************************************************************************************

Regards,

Rami

0 Kudos