POST
|
Hallo, I'm an ArcGIS Desktop 10.7 user and struggling with WFS conversion in ArcPy. When using an extent in combination with WFSToFeatureClass, it raises an error. The documentation tells me the WFS To Feature Class conversion should work with the extent of a feature class, display or whatever: By default all features from the WFS source are added to the feature class. The extent environment setting can be used to limit the features to just those that intersect a user-defined extent... This example works (without the use of Extent) but returns a complete set of features: import arcpy
WFS_Service = "https://geodata.nationaalgeoregister.nl/cbspostcode4/wfs?&request=GetCapabilities&service=wfs"
WFS_FeatureType = "postcode42017"
Out_Location = r"C:\GIS data\FGDB_datatest.gdb"
Out_Name = "tmp2"
arcpy.WFSToFeatureClass_conversion(WFS_Service, WFS_FeatureType, Out_Location, Out_Name) This example doesn't work: import arcpy
fc_ext = r"C:\GIS data\FGDB_datatest.gdb\DS_datatest\test_01"
desc = arcpy.Describe(fc_ext)
arcpy.env.extent = desc.extent
WFS_Service = "https://geodata.nationaalgeoregister.nl/cbspostcode4/wfs?&request=GetCapabilities&service=wfs"
WFS_FeatureType = "postcode42017"
Out_Location = r"C:\GIS data\FGDB_datatest.gdb"
Out_Name = "tmp3"
arcpy.WFSToFeatureClass_conversion(WFS_Service, WFS_FeatureType, Out_Location, Out_Name) The code above raises an error saying: ERROR 999999: Error executing function BTW: the used extent works with a simple featureclass with points and Select_analysis. How can I make the extent setting get to work for me???
... View more
06-20-2019
03:43 AM
|
0
|
0
|
534
|
POST
|
I tested your code with the postcode42017, which indeed works like a charm. But I'm not able to use the environment Extent setting. The documentation tells me the WFS To Feature Class conversion should work with the extent of a feature class, display or whatever: By default all features from the WFS source are added to the feature class. The extent environment setting can be used to limit the features to just those that intersect a user-defined extent... So I copied your code, added lines 3,4 en 5. (Those lines worked well on a regelar featureclass in combimnation with Select_analysis) import arcpy
fc_ext = r"C:\Users\Herman\OneDrive\Algemeen\ArcGIS\GIS data\FGDB_datatest.gdb\DS_datatest\test_01"
desc = arcpy.Describe(fc_ext)
arcpy.env.extent = desc.extent
WFS_Service = "https://geodata.nationaalgeoregister.nl/cbspostcode4/wfs?&request=GetCapabilities&service=wfs"
WFS_FeatureType = "postcode42017"
Out_Location = r"C:\Users\Herman\OneDrive\Algemeen\ArcGIS\GIS data\FGDB_datatest.gdb"
Out_Name = "tmp2"
# Execute the WFSToFeatureClass tool
arcpy.WFSToFeatureClass_conversion(WFS_Service, WFS_FeatureType, Out_Location, Out_Name) The code above raises an error saying: ERROR 999999: Error executing function How can I make the extent setting get to work for me???
... View more
06-19-2019
06:32 AM
|
0
|
0
|
1916
|
POST
|
Egge-Jan, sorry for mistaken you worked for ESRI, I don't know why I had that idea. Maybe because your detailed answer. Anyhow, thanks again for your reply. I copied your code and it works like a charm. However, some other datasets provided by PDOK I can't get to work, like this one: https://geodata.nationaalgeoregister.nl/ecotopen/wfs?request=GetCapabilities&service=wfs https://geodata.nationaalgeoregister.nl/cbspostcode4/wfs?&request=GetCapabilities&service=wfs It raises an error saying 'ERROR 000366: Invalid geometry type'. Any idea why this one doesn't seem to work?
... View more
06-17-2019
03:05 AM
|
0
|
0
|
1916
|
POST
|
Thanks for your reaction Egge-Jan! I'm totally aware of the ontent Esri Nederland offers and I recently received the same part of code by a colleague of yours. In that way my question was a bit unlucky, I guess: in this case Esri Nederland serves the same content as a non ESRI-WFS. But I was testing WFS in generally, tested the BAG WFS and I thought the problem which occured was a common issue. But if I understand correct, this is a issue due to mismatch in outputFormat? So in this case I won't be able to get the WFS in ArcGIS by any other offered outputformat (gml, json, application/json, gml+xml, etc.)?
... View more
06-16-2019
11:41 AM
|
0
|
1
|
1916
|
POST
|
Hello, I'm still struggling with WFS by using ArcPy. Beneath I have a link to some GIS data. When I click the link, the links shows me the coorect result in the browser, but if I use this link in Arcpy it stumbles on the fs.load(url) and raises an error saying: RuntimeError: RecordSetObject: Cannot open table for Load I can't find what's wrong. is it the url? Is it the outputformat? The request? Or is it something else? Here is the link: http://geodata.nationaalgeoregister.nl/bag/wfs?service=wfs&version=2.0.0&request=GetFeature&typeName=bag:verblijfsobject&count=5&outputFormat=json Here is the code in Python I use: import arcpy
url = 'http://geodata.nationaalgeoregister.nl/bag/wfs?service=wfs&version=2.0.0&request=GetFeature&typeName=bag:verblijfsobject&count=5&outputFormat=json'
fs = arcpy.FeatureSet()
fs.load(url)
fs.save(r'D:\GIS data\FGDB_datatest.gdb\test_001') Please, any help is welcome!
... View more
06-16-2019
06:10 AM
|
0
|
8
|
2530
|
POST
|
I've got the answer. Esri Nederland helped me out! they provided me this code and advised to read about the Rest API. import arcpy
# Query URL opbouwen op basis van bepaalde postcode
ppc = '2623HB'
url = 'https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Postcodevlakken_PC6/FeatureServer/0/query?where=PC6+%3D+%27{}%27&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=*&returnGeometry=true&returnCentroid=false&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token='.format(ppc)
# Omzetten van query naar feature class
fs = arcpy.FeatureSet()
fs.load(url)
fs.save(r'<Pad naar Geodatabase>\PPC6_{}'.format(ppc))
print ("Klaar")
... View more
06-07-2019
05:48 AM
|
1
|
0
|
3383
|
POST
|
Uhmmm, maybe a bit silly, but I'm not quiet sure where to look for a little envelope thingy. I'm working in Pycharm/IDLE and ArcGIS for Desktop. Can you help me with a screenshot?
... View more
06-05-2019
06:43 AM
|
0
|
0
|
3383
|
POST
|
Thanks for your answer, Neil! Indeed, I added the required layer from the TOC and I understand that python can't find the layer among my local storage, thanks for pointing out. But in what way (without adding from the TOC or storing Web content locally) can I point to the PC6-feature service?
... View more
05-31-2019
04:31 AM
|
0
|
3
|
3383
|
POST
|
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'")
... View more
05-31-2019
02:41 AM
|
0
|
5
|
4235
|
Title | Kudos | Posted |
---|---|---|
1 | 06-07-2019 05:48 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|