AnsweredAssumed Answered

Make Arcpy use Esri Feature Service

Question asked by hermangroeneveld on May 31, 2019
Latest reply on Jun 7, 2019 by hermangroeneveld

I'm a ArcGIS for Desktop user who is a noob to Python and would like to be pointed in the right direction. How can I use/acces feature services like the one below (directly) through arcpy?

 

What I'm trying to do looks very simple:

1. I have a ZIP-code as input, say '2623HB'

2. Using this Zip-code Web Feature Layer ("Postcodevlakkekken PC 6", provided by Esri Nederland), I want to select the correct polygon by using the SelectLayerByAttributes-function.

3. Export this polygon to a shapefile or maybe even use it as intermediate data.

 

Step 2 gives me problems. In the Modelbuilder I made a very simple scheme, using SelectlayerByAttributes and it works (attached picture). But when I export the model to python , the very same script raises an error, saying:

"ERROR 000732: Layer Name or Table View: Dataset Postcodevlakken PC 6\PC6 does not exist or is not supported"

 

how can i acces a feature service with an url like:

https://services.arcgis.com/nSZVuSZjHpEZZbRo/arcgis/rest/services/Postcodevlakken_PC6/FeatureServer 

 

here is the python code:

 

# ---------------------------------------------------------------------------
# selbyattr2.py
# Created on: 2019-05-31 09:24:45.00000
#   (generated by ArcGIS/ModelBuilder)
# Description:
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy


# Local variables:
PC6 = "Postcodevlakken PC 6\\PC6"
PC6__4_ = PC6

# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(PC6, "NEW_SELECTION", "\"PC6\" = '2623HB'")

Attachments

Outcomes