Export data from Map Service

11796
14
10-23-2014 03:35 AM
HaniDraidi
Occasional Contributor II

Hi,

Is there a tool (in ArcMap) to extract data from a map or feature service I am accessing?

Clip_715.jpg

Thank you,

Hani

0 Kudos
14 Replies
AlexPerez
New Contributor III

Not specifically no.  If you can filter your search so that you want fewer records than the server's record limit, you can query the map service.  Open up the map service in a browser.  Navigate to the service you want and there should be a QUERY link at the bottom.  Fill out the form and request the results in json (if you want everything you can always try WHERE 1=1).  Copy paste them into a text file and you can use a JSON to features tool that will build the polygons with attributes for you.  It can be time consuming but it is possible.

0 Kudos
ModyBuchbinder
Esri Regular Contributor

For image service if the download capability is checked (not default) you can use right click, Data, Download selected rasters.

You must select some rasters before the option is enabled.

0 Kudos
JakeSkinner
Esri Esteemed Contributor
NickHarvey
Occasional Contributor II

Thanks for posting this tool Jake - REALLY HELPFUL.  I was trying to use ArcMap to export 120k+ features from an AGS feature service that one of our partnering agencies had set up....I kept getting a "client timeout/server not responding error".  I noticed that when I selected a small number of features the AGS feature service export would complete successfully.  I know that on our own AGS feature services that the max number of records returned by server is set at 1000 (default presumably).  And from looking at the code you have provided, this tool appears to dice up the download/extract in chunks of 1000 records by ObjectID.  Am I connecting the dots correctly here?  - That the 1000 record limit is expected per this client/server process and being accounted for in your code?  Or, let me know otherwise....

Thanks again!

-Nick

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Yes, that is correct. The script appends 1000 features at a time.

0 Kudos
JoshWhite
Regular Contributor III

Jake Skinner,

I was going to try using your tools.  It is a secure service so I entered my credentials.  The script acts as if it cannot generate a token.  One thing I notice is that when I type in my password and move on to the next box the number of characters change in the password box, I'm hoping it is not defaulting to another password that I cannot see.

Executing: DownloadService false true http://<serviceurl>/countymap/rest/services/Clip_Ship/CL_ParcelData/FeatureServer/8 true false JWhite ***** "Database Connections\Connection to GIS-SERVER.sde\acgis.DBO.Address\acgis.DBO.AddressPoints" false #
Start Time: Thu Sep 24 09:33:31 2015
Running script DownloadService...
Generating Token
 
URL is incorrect.  Or, Service is secure, please enter username and password.
Failed script DownloadService...
Traceback (most recent call last):
  File "C:\Users\Josh White\AppData\Roaming\ESRI\Desktop10.3\ArcToolbox\My Toolboxes\Download Service with Attachments.py", line 53, in <module>
    iteration = int(data['objectIds'][-1])
KeyError: 'objectIds'


Failed to execute (DownloadService).
Josh White, AICP
Principal Planner

City of Arkansas City
0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hey Josh,

I believe I fixed the issue, and updated the tool:

http://countysandbox.maps.arcgis.com/home/item.html?id=2b1f198be4ea44288418fd39f1d0aff0

Re-download the tool and let me know if you run into the same issue.

Thanks.

0 Kudos
JoshWhite
Regular Contributor III

It comes back with a bit different error this time:

Traceback (most recent call last):

  File "C:\Users\Josh White\AppData\Roaming\ESRI\Desktop10.3\ArcToolbox\My Toolboxes\Download Service with Attachments.py", line 46, in <module>

    params = {'where': '1=1', 'returnIdsOnly': 'true', 'token': token, 'f': 'json'}

NameError: name 'token' is not defined


Failed to execute (DownloadService).

I have another question, is the intent to do one layer at a time?  If that is the case, I would need the ID number for the layer, is that correct?  I've tried it both ways and the error is the same for both methods so it is catching on something else first.  It appears it is still "catching" because of the secure service.  I'm afraid I don't know enough python to know what I am looking at.

Josh White, AICP
Principal Planner

City of Arkansas City
0 Kudos
JakeSkinner
Esri Esteemed Contributor

Yes, the tool is designed to download a feature layer, so you will need to specify the index of the layer you wish to download.

Try running the tool with the following service URL below.  I just tested it, and it worked successfully.  Be sure that you download the most recent version of the tool.

http://54.209.148.150:6080/arcgis/rest/services/Voting_Districts/MapServer/0

username:  viewer1

password:  viewer1

0 Kudos