J'ai rencontré de nombreux utilisateurs qui ont demandé la possibilité de télécharger les services de fonctionnalités hébergés ArcGIS Online et les services de fonctionnalités/cartes ArcGIS Server. Voir l'outil ci-joint pour faire exactement cela. L'outil vous permettra également de télécharger les pièces jointes des services de fonctionnalités hébergés ArcGIS Online. J'espère que les utilisateurs trouveront cela utile et pratique.<\/P>
<\/P>
Mise à jour 10\/08\/17:<\/STRONG> L'outil téléchargera désormais les domaines de valeurs codées dans la géodatabase. De plus, consolidation des versions 2x et 3x en un seul outil. L'outil peut être exécuté depuis ArcGIS Pro ou ArcGIS Desktop.<\/P>Mise à jour 13\/11\/17: <\/STRONG>L'outil prend désormais en charge l'utilisation d'une clause where pour interroger le service.<\/P>Mise à jour 14\/03\/17:<\/STRONG> Mise à jour vers un script unique pour ArcMap\/Pro utilisant le module requests<\/P>Mise à jour 17\/01\/19:<\/STRONG> Merci à Adam Eversole<\/A> d'avoir signalé que la fonctionnalité de cet outil peut désormais être prise en charge par l'outil Feature Class to Feature Class<\/A> d'ArcGIS Pro :<\/P><\/P><\/BODY><\/HTML>
<\/P><\/BODY><\/HTML>
Cannon are you running this as a GP tool, or are you editing the script? If the former, can you send a screen shot of how you have the tool setup?
Jake Skinner, I hope this is what you were asking for. Thanks for any help!!!
Cannon change your output to a feature class instead of a shapefile. Since you enabled the attachment option this needs to be a feature class. It will create an attachments table, which is a component of only feature classes.
That did it! Thanks for the quick help. I guess I should look into this sort of topic at the SE Users Conference next month.
Thank again,
Jonathan
Hi Jake Skinner
I am getting an error while adding the toolbox. The older version works fine (2015) when I add the tbx file automatically the script added. But the recent one attached in this document needs manual adding of the py script. I have tried adding the script and When I run the tool I get the error like this below;
Error: This tool has no parameters
I am using ArcGIS 10.3 version.
I appreciate any help to sort this issue.
Thanks
Vj
vijayasekaran try re-downloading the tool. I saved the toolbox as a 10.1/10.2 version, so you should be able to open it successfully in 10.3.
When I download this on windows 10 and extract the zip file the linkage between the script and the toolbox id broken.
is there another copy that has the linkages built in?
Also i am using arcmap 10.3.
Shawn
I found the fix on the previous page...
Jake,
This is a great tool. Is it possible to adapt it so it can run as a scheduled task so that the same feature can be downloaded on a regular basis without having to run the toolbox from ArcGIS Pro.
Also i increase the number of records it returns, 1000 is not enough.
Sheree
Tweed Shire Admin yes you can run this as a scheduled task. You will need to update the Variables in the script. For example, change all the arcpy.GetParameterAsText to what you would enter in the tool. For the check box variables (i.e. hostedFeatureService) you will either specify 'true' or 'false'.
<SPAN class="comment token">#Variables</SPAN> hostedFeatureService <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> agsService <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN> baseURL <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"/query"</SPAN> whereClause <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN> agsFeatures <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">)</SPAN> agsTable <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">)</SPAN> username <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">6</SPAN><SPAN class="punctuation token">)</SPAN> password <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">7</SPAN><SPAN class="punctuation token">)</SPAN> outputFC <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">)</SPAN> getAttachments <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">)</SPAN> cwd <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Also, this tool will download all the features in the feature service. It's not limited to 1,000.
Excellent.
Thanks Jake I will give that a go.
Thanks Sheree
Hi Jake,
I have changed those variables.
When I run I get this error
I would like have the attachment folders use a different field for the name (other than GlobalID_Str) is that easily changed?
jason heyman the folder name of the attachments is used to join the attachments back to the feature class using the GlobalID_Str field. There will be a lot more coding if you wanted to change this. What is your use case to change this name? Maybe there will be another solution.
Jake - We keep an archive of our images organised by address (folder is named by address field) and it would be nice to be able to adjust this as an option when downloading instead of changing the folder names later in a batch job.
Has anyone tried to use the where clause in this tool to query for a date range? I can query via the rest api, and I can query the downloaded file geodatabase. However, no matter what syntax I use in the Where clause dialog box, I get URL erro (URL is incorrect. Or, Service is secure, please enter username and password)
Yes, our requirement was to only download the features after a saved date (which gets updated and saved in a config file each time this whole process is run so that the consecutive runs only pickup data from the last execution).
Be sure to check your date formatting and also verify your token is being added. Here's an example of what we've implemented:
<SPAN class="comment token">#"CreationDate" is the date column to query on</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">checkForUpdatedFS</SPAN><SPAN class="punctuation token">(</SPAN>taburl<SPAN class="punctuation token">,</SPAN> uname<SPAN class="punctuation token">,</SPAN> pword<SPAN class="punctuation token">,</SPAN> inputDate<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">if</SPAN> taburl <SPAN class="operator token">!=</SPAN> <SPAN class="string token">''</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN> tokenURL <SPAN class="operator token">=</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.arcgis.com%2Fsharing%2Frest%2FgenerateToken" target="_blank">https://www.arcgis.com/sharing/rest/generateToken</A><SPAN>'</SPAN></SPAN> params <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'f'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'pjson'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'username'</SPAN><SPAN class="punctuation token">:</SPAN> uname<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'password'</SPAN><SPAN class="punctuation token">:</SPAN> pword<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'referer'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.arcgis.com" target="_blank">http://www.arcgis.com</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">}</SPAN> reqp <SPAN class="operator token">=</SPAN> urllib2<SPAN class="punctuation token">.</SPAN>Request<SPAN class="punctuation token">(</SPAN>tokenURL<SPAN class="punctuation token">,</SPAN> urllib<SPAN class="punctuation token">.</SPAN>urlencode<SPAN class="punctuation token">(</SPAN>params<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> responsep <SPAN class="operator token">=</SPAN> urllib2<SPAN class="punctuation token">.</SPAN>urlopen<SPAN class="punctuation token">(</SPAN>reqp<SPAN class="punctuation token">)</SPAN> datap <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN>load<SPAN class="punctuation token">(</SPAN>responsep<SPAN class="punctuation token">)</SPAN> token <SPAN class="operator token">=</SPAN> datap<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'token'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN> token <SPAN class="operator token">=</SPAN> <SPAN class="string token">''</SPAN> params <SPAN class="operator token">=</SPAN> urllib<SPAN class="punctuation token">.</SPAN>urlencode<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">'f'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'pjson'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'where'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"CreationDate>'{}'"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>inputDate<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'outFields'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'*'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'token'</SPAN><SPAN class="punctuation token">:</SPAN> token<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'returnGeometry'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'true'</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN> req <SPAN class="operator token">=</SPAN> urllib2<SPAN class="punctuation token">.</SPAN>Request<SPAN class="punctuation token">(</SPAN>taburl <SPAN class="operator token">+</SPAN> <SPAN class="string token">"/query"</SPAN><SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">)</SPAN> gresp <SPAN class="operator token">=</SPAN> urllib2<SPAN class="punctuation token">.</SPAN>urlopen<SPAN class="punctuation token">(</SPAN>req<SPAN class="punctuation token">)</SPAN> gdata <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN>load<SPAN class="punctuation token">(</SPAN>gresp<SPAN class="punctuation token">)</SPAN> rCount <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>gdata<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'features'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN> len<SPAN class="punctuation token">(</SPAN>rCount<SPAN class="punctuation token">)</SPAN> dFormat <SPAN class="operator token">=</SPAN> <SPAN class="string token">'%Y-%m-%d %H:%M:%S'</SPAN> writeDateVal <SPAN class="operator token">=</SPAN> datetime<SPAN class="punctuation token">.</SPAN>strptime<SPAN class="punctuation token">(</SPAN>maxDateConfig<SPAN class="punctuation token">,</SPAN> dFormat<SPAN class="punctuation token">)</SPAN> writeDateVal <SPAN class="operator token">=</SPAN> writeDateVal <SPAN class="operator token">+</SPAN> timedelta<SPAN class="punctuation token">(</SPAN>seconds<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#datetime.timedelta(0, 1) #add 1 second</SPAN> writeDateValFinal <SPAN class="operator token">=</SPAN> datetime<SPAN class="punctuation token">.</SPAN>strftime<SPAN class="punctuation token">(</SPAN>writeDateVal<SPAN class="punctuation token">,</SPAN> dFormat<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#wr</SPAN> <SPAN class="comment token">#test to see if we have any surveys to process using the last submitted date value</SPAN> recChk <SPAN class="operator token">=</SPAN> checkForUpdatedFS<SPAN class="punctuation token">(</SPAN>serviceName<SPAN class="punctuation token">,</SPAN> inputUsername<SPAN class="punctuation token">,</SPAN> inputPswd <SPAN class="punctuation token">,</SPAN> maxDateConfig<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> recChk<SPAN class="operator token">></SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN> recChk <SPAN class="keyword token">print</SPAN> <SPAN class="string token">'There are {} surveys after {} to process.'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>recChk<SPAN class="punctuation token">,</SPAN> maxDateConfig<SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Scott DeNeice can you post a screen shot of how you have the tool setup? Here is what I was able to get to work:
Nice tool. It works fine for me when executed the usual way (double click on tool, fill in parameter values in form, etc). However I've been trying to call it from a Python script, and I get errors. Something about parameters that correspond to check boxes on the form.
Here's the caller snippet...
arcpy.ImportToolbox(tbx_path)
# setup parametershostedFeatureService = 'true' #True agsService = 'false' #False baseURL = "http://services1.arcgis.com/0U8EQ1FrumPeIqDb/ArcGIS/rest/services/OCFLAtlas_CompPlanCases_View/FeatureServer/0" whereClause = None agsFeatures = 'true' #True agsTable = 'false' #False username = None password = None outputFC = "\\t3600\D_drive\projects\Orange3\dev_APP\notification_dev\REST scripts from Dean\test_download\OCFLAtlas_CompPlanCases_View" getAttachments = 'false' #False cwd = None
# make the call
arcpy.DownloadService( hostedFeatureService, agsService, baseURL, whereClause, agsTable, username, password, outputFC, getAttachments, cwd )
For the Boolean input, I have tried python True/False, and I have tried string 'true'/'false'.
Here's the error when executed in Idle...
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32Type "copyright", "credits" or "license()" for more information.>>> RESTART: \\t3600\D_drive\projects\Orange3\dev_APP\notification_dev\REST scripts from Dean\Download Service toolbox tool\test_download.py ERROR: unable to download CompPlanCases due to arcpy error, Please check 'Downloading Feature Data' or 'Downloading Tabular Data'
Failed to execute (DownloadService).
Any ideas?
I am using 10.6 on Win10.
the .tbx file is in a plain windows folder, not in a toolbox.
Service works, as I can download the data without the where clause. Also, tested against the rest service, I can query in the rest service as well. I have figured a work around but it is not as clean as this would be. (What I really want is a between, VISIT_DATE >= date '1/1/2018' AND VISIT_DATE <= date '3/31/2018', for example).
I have also tried VISIT_DATE > timestamp '2018-01-01 00:00:00' to no avail.
Thanks for your help
Scott DeNeice can you share the service to a Group and then invite my AGOL account (jskinner_CountySandbox)? I can then test this out.
Unfortunately, this is a third party service that I am working with on behalf of branch office of my company. I do not even know the contact for the third party to ask.
FYI the feature class this comes from has over 600 columns (wayyyyy to big). There are, however only around 1600 features so, the process takes only a minute or two.
My work around is to download the full feature, then do a make table view where I add the where clause as a parameter. Cludgy, but it works.
I am using this tool as part of a model (in ArcPro 2.1) to download an AGOL feature to then output to a formatted (there are several different reports from this one feature) Excel spreadsheet, and the client wants to have the ability to produce annual, bi-annual or quarterly reports (possibly even monthly reports).
Thanks anyway.
I am getting the following error when trying to download my attachments -
Start Time: Friday, June 8, 2018 11:41:19 AMRunning script DownloadService...Generating TokenCopying features with ObjectIDs from 28663 to 29663Copying features with ObjectIDs from 29663 to 30663Copying features with ObjectIDs from 30663 to 31663Copying features with ObjectIDs from 31663 to 32663Copying features with ObjectIDs from 32663 to 33663Copying features with ObjectIDs from 33663 to 34663Copying features with ObjectIDs from 34663 to 35663 Error occurred: FILE: C:\Users\jheyman\Desktop\DownloadServicewithAttachments.py, LINE: 283 "fs.load(fsURL)": RecordSetObject: Cannot load a table into a FeatureSetCompleted script Download Service... Failed to execute (DownloadService).Failed at Friday, June 8, 2018 11:41:59 AM (Elapsed Time: 39.50 seconds)
jason heyman can you share the service to an AGOL Group and invite my user account (jskinner_CountySandbox)?
steve allenstein here is how I had the parameters set up:
I would recommend updating your outputFC variable, and place an r in front of the path so python reads it as a literal string:
outputFC = r"\\t3600\D_drive\projects\Orange3\dev_APP\notification_dev\REST scripts from Dean\test_download\OCFLAtlas_CompPlanCases_View"
https://community.esri.com/migrated-users/8586
Have you seen this error before? I think it's a proxy error....maybe. It prints the site if I add the following code but still errors out after, maybe I do not have the proxy code set correctly?
s = requests.Session()s.proxies = {"http":"proxy1.corp:3128","https":"proxy1.corp:3128"}r = s.get(baseURL)print(r.text)
Line 190:
# Return largest ObjectIDif whereClause == '': whereClause = '1=1'params = {'where': whereClause, 'returnIdsOnly': 'true', 'token': token, 'f': 'json'}response = requests.post(baseURL, data = params, verify = False)data = response.json()
Variables:
hostedFeatureService = 'true'agsService = 'false'baseURL = 'https://gis.energy.gov.ab.ca/arcgis/rest/services/Geoview/Mineral_Agreements_Ext_PROD/MapServer/52/query'whereClause = ''agsFeatures = 'true'agsTable = 'false'username = ''password = ''outputFC = r'C:\Users\chcarter\Documents\ArcGIS\Default.gdb\Test'getAttachments = 'false'cwd = ''
Any information would be greatly appreciated,
Chase
Sorry if someone has already answered this, but is there a way to change the script to be able to overwrite an existing output? I am trying to come up with a workflow where we download a specific hosted feature layer after edits are made, perform some analysis locally, and re-upload another feature layer.
This tool is great btw. Very helpful.
Have you tried to overwrite a layer you download and it failed? If so, can you provide the error code or image of it. Line 152 is env.overwriteOutput = 1, which should allow feature classes to be ovewritten. You could also try changing 1 to "True," but I don't think that should make a different. But it also wouldn't hurt to try.
Ok I was able to get it to run and overwrite features by running the script through ArcMap and also hardcoding the variables and running the python script outside of ArcMap. I was hoping to run it once, copy the python code snippet and run the code that way, but that is when I get the error.
ExecuteError: Failed to execute. Parameters are not valid.ERROR 000725: Output Feature Class/Table: Dataset E:\Projects\\nashville_app.gdb\grids already exists.Failed to execute (DownloadService).
Chase Carter I believe it may be a proxy issue. I just executed the tool successfully with this service, not going through any proxy. If you try another network (i.e. from you home) does it work successfully?
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.