1

I do not believe this is a copy of Download Dataset From ArcGIS REST Service or Extracting data from ArcGIS REST endpoint? due to the source and type of service.

I would like to copy the features from a government ArcGIS REST Service. It is a MapServer so I am not sure how, or if it is possible. I tried replicating a code I used to copy a FeatureServer but that did not work and instead got an ERROR 999999 which isn't very helpful for diagnosing what is wrong.

The code is as follows:

# Set environment options
arcpy.env.overwriteOutput=True

Set workspace

ws = r'c:/ws' wsGDB = os.path.join(ws, 'EnvironmentalContamination.gdb')

MO Hazardous Waste from DNR

conFields = "https://gis.dnr.mo.gov/arcgis/rest/services/e_start/e_start/MapServer/0"

Copy fc from rest service

conCopy = "MOContamination" memCon = arcpy.management.CopyFeatures(conFields, conCopy)

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
JackOfTales
  • 373
  • 2
  • 13
  • you need to look at the formats that are available to download - you can check the wizard https://gis.dnr.mo.gov/arcgis/rest/services/e_start/e_start/MapServer/export?bbox=199082.18667357054,3974416.295123932,1027758.8440268853,4540625.760876196 – Mapperz May 27 '21 at 13:18
  • 1
    This works, inside ArcGIS Pro. I added the layer to the map (via URL), then used the layer reference in CopyFeatures. The issue is probably using a MapService with CopyFeatures; it probably only supports a FeatureService – KHibma May 27 '21 at 14:42

1 Answers1

2

I believe CopyFeatures can only work directly on a FeatureService. You can make use of arcpy.FeatureSet to put a wrapper on the MapService, which CopyFeatures supports.

fs = arcpy.FeatureSet()
fs.load("https://gis.dnr.mo.gov/arcgis/rest/services/e_start/e_start/MapServer/0")
arcpy.management.CopyFeatures(fs, "Foo2")

However, this service seems pretty slow. If you run CopyFeatures too soon after doing the load, CopyFeatures will still fail as the data hasn't been brought down.

KHibma
  • 16,786
  • 1
  • 31
  • 55