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>
With the latest version of Pro, 2.0.1, fails with
Running script DownloadService<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> Generating Token Copying features <SPAN class="keyword token">with</SPAN> ObjectIDs <SPAN class="keyword token">from</SPAN> <SPAN class="number token">0</SPAN> to <SPAN class="number token">345</SPAN> Failed script DownloadService<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> Traceback <SPAN class="punctuation token">(</SPAN>most recent call last<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> File <SPAN class="string token">"C:\PY_SCRIPTS\ARCHIVE\Download Service.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">16</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<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><SPAN class="punctuation 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><SPAN class="punctuation 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="punctuation token">)</SPAN> File <SPAN class="string token">"C:\PY_SCRIPTS\ARCHIVE\DownloadServicewithAttachments_3x.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">537</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> downloadservice3x addDomainsHosted<SPAN class="punctuation token">(</SPAN>outputFC<SPAN class="punctuation token">)</SPAN> File <SPAN class="string token">"C:\PY_SCRIPTS\ARCHIVE\DownloadServicewithAttachments_3x.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">51</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> addDomainsHosted data <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN>loads<SPAN class="punctuation token">(</SPAN>json_acceptable_string<SPAN class="punctuation token">)</SPAN> File <SPAN class="string token">"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\json\__init__.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">319</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> loads <SPAN class="keyword token">return</SPAN> _default_decoder<SPAN class="punctuation token">.</SPAN>decode<SPAN class="punctuation token">(</SPAN>s<SPAN class="punctuation token">)</SPAN> File <SPAN class="string token">"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\json\decoder.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">339</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> decode obj<SPAN class="punctuation token">,</SPAN> end <SPAN class="operator token">=</SPAN> self<SPAN class="punctuation token">.</SPAN>raw_decode<SPAN class="punctuation token">(</SPAN>s<SPAN class="punctuation token">,</SPAN> idx<SPAN class="operator token">=</SPAN>_w<SPAN class="punctuation token">(</SPAN>s<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>end<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> File <SPAN class="string token">"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\json\decoder.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">355</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> raw_decode obj<SPAN class="punctuation token">,</SPAN> end <SPAN class="operator token">=</SPAN> self<SPAN class="punctuation token">.</SPAN>scan_once<SPAN class="punctuation token">(</SPAN>s<SPAN class="punctuation token">,</SPAN> idx<SPAN class="punctuation token">)</SPAN> json<SPAN class="punctuation token">.</SPAN>decoder<SPAN class="punctuation token">.</SPAN>JSONDecodeError<SPAN class="punctuation token">:</SPAN> Expecting <SPAN class="string token">','</SPAN> delimiter<SPAN class="punctuation token">:</SPAN> line <SPAN class="number token">1056</SPAN> column <SPAN class="number token">71</SPAN> <SPAN class="punctuation token">(</SPAN>char <SPAN class="number token">31056</SPAN><SPAN class="punctuation token">)</SPAN> Failed to execute <SPAN class="punctuation token">(</SPAN>DownloadService<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN> Failed at Wednesday<SPAN class="punctuation token">,</SPAN> December <SPAN class="number token">27</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2017</SPAN> <SPAN class="number token">9</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">44</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">19</SPAN> AM <SPAN class="punctuation token">(</SPAN>Elapsed Time<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">26.00</SPAN> seconds<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>
Works fine in Arc 10.5.1
tpcolson try another service to see if you receive the same error. I was able to get this to work successfully:
I was able to get this to work for all of my hosted feature services. Thank you for everyone's help! This is a great tool!
Steven
Same error on multiple different computers, tried over two dozen hosted feature services. Fyi I have installed the https://developers.arcgis.com/python/guide/install-and-set-up/#Step:-2-Install-the-arcgis-package....is that somehow breaking the rest of the python functionality that came with Pro?
Running script DownloadService...
Generating Token
Copying features with ObjectIDs from 0 to 26098
Failed script DownloadService...
Traceback (most recent call last): File "C:\PY_SCRIPTS\ARCHIVE\Download Service.py", line 16, in <module> arcpy.GetParameterAsText(8), arcpy.GetParameterAsText(9), arcpy.GetParameterAsText(10)) File "C:\PY_SCRIPTS\ARCHIVE\DownloadServicewithAttachments_3x.py", line 537, in downloadservice3x addDomainsHosted(outputFC) File "C:\PY_SCRIPTS\ARCHIVE\DownloadServicewithAttachments_3x.py", line 51, in addDomainsHosted data = json.loads(json_acceptable_string) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\json\__init__.py", line 319, in loads return _default_decoder.decode(s) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\json\decoder.py", line 355, in raw_decode obj, end = self.scan_once(s, idx)json.decoder.JSONDecodeError: Expecting ',' delimiter: line 892 column 71 (char 24998)
Failed to execute (DownloadService).
More detail, from Pro, when I select "Copy Python Command", note the first few letters (extra dots)....
arcpy..DownloadService(True, False,
Hi Dave
How did you fix your issue?
/Sanne
Hi jskinner-esristaff, love the tool. While it was working perfectly for me for the past few months I've come across an undefined error. I've attached some screenshots below.
1) The tool always seems to open to a highlighted issue but does not provide any information when hovering over it with the cursor.
2) When trying to execute the tool with the parameters set an error is displayed, but again, no information is given.
Any insight into what might be the problem would be great.
Thanks!
-Aaron
AaronFrancis try re-downloading the tool and see if the same error occurs. One other thing is to try this on a different server.
Also, it appears you are trying to download an ArcGIS Server service. Try checking this option rather than the Hosted Feature Service option.
Thanks for getting back to me Jake. I actually did initially try both of those potential solutions but didn't have luck. It doesn't seem to matter whether I'm attempting to access a Hosted Feature Service or an ArcGIS Server Service, when I initially open the tool I receive a blank error symbol, and receive a blank error message whenever trying to execute the tool, regardless of what my parameters are.
I did find this article indicating that blank error messages might be due to the ArcToolbox.dat file, but in this case they're talking about the system tools whereas my problem is associated with a custom tool.
AaronFrancis what version of ArcGIS Desktop are you using? The toolbox was created with 10.5 This could be the issue. Are you able to upgrade to 10.5 or 10.6?
I'm currently using 10.5. Do you think upgrading to 10.6 could possibly resolve the situation if there is an issue with my 10.5 configuration?
This tool should work with no issues at 10.5, but it wouldn't hurt to upgrade to 10.6.
Hi Jake, I finally had time to upgrade to ArcGIS 10.6 and I guess that's what fixed it. It was definitely something with the configuration of my ArcToolbox, but upgrading to 10.6 brought everything back the standard configuration, not sure what I had done to mess it up but this tool was not the only one that wasn't working properly.
Thanks for the quick replies!
- Aaron
Jake,
Is there way to download attachment, but keep it in FGDB, not totally download attachment in a folder?
yuimyt the attachments will be stored in the File Geodatabase within the ATTACH table. There is a field of type BLOB that stores the attachments. The attachments are first written to disk before they are loaded into the table. After the tool completes, you can delete the folder you specified to store the attachments.
Hi Jake,
Your tool works fine for me when I use Where Clause with text fields. However when I use Where Clause with date field: EditDate=Current_Date, it gives me error message: URL is incorrect. Or, Service is secure, please enter username and password. Any idea how I could fix this ?
My layer is a feature service layer from AGOL. EditDate and Editor are 2 fields that automatically added when you turn on "Keep track of who created and last updated features".
Thank you so much for your help.
helen chu check to make sure the query is working in the REST services directory. For example, you will most likely need something like:
EditDate > date '2018-02-11'
You are right. My query (EditDate = Current_Date) did not work in rest service directory "Unable to perform query. Please check your parameters".
If I put EditDate ='02-14-2018' it works. What I want is today date not a fixed date. I've tried from now, date to current_date. None works. Any idea? Thanks.
Here are the supported SQL functions:
Supported SQL functions in ArcGIS Server—ArcGIS Server Administration (Windows) | ArcGIS Enterprise
Try CURRENT_DATE. It may be case sensitive.
Thanks Jake. It's CURRENT_TIMESTAMP. My brilliant co-worker figured it out!
Is there any reason why converting the queryURL that references a hosted feature service on AGOL would populate the FeatureSet() with GlobalID values as {00000000-0000-0000-0000-000000000000}?
Sorry to cross post but I'm not making any progress from my post in python section https://community.esri.com/thread/209848-arcpyfeatureset-from-feature-service
Very nice tool, thank you!
I'm trying to maintain the original ObjectID or GlobalID from the hosted feature service, but it seems to create new ones.
Hosted to SDE or FGDB: Different GloablID and different ObjectID
Hosted to Shapefile: No GlobalID and different ObjectID.
Before I get into it, is this the expected behavior?
dgoldb2@luc.edu yes this is expected. The tool will make a copy of the data. Anytime this occurs new OBJECTIDs and GlobalIDs are generated. One thing you can do to maintain the GlobalIDs is to enable attachments on the feature service. When you run the tool, check the option to download attachments as well. This should create a new field in the output feature class called GlobalID_str. This will be the original GlobalIDs.
Just to post my findings: the issue I was having with GlobalID/ParentGlobalID values as {00000000-0000-0000-0000-000000000000} when implementing .load() on the FeatureSet with the service url was reproduced by ESRI support. This appears to be a problem with ArcGIS Desktop 10.3.1 (32/64 bit) and 10.4 (64 bit).
My workaround was to load a json object and parse that to generate the desired output. Luckily, my requirement was to simply output individual csv files for the contents of the service layers/tables, so it was a matter of implementing the csv.DictWriter() to perform that task.
One other issue that came up was with date columns would be written to the csv outputs as epoch format, so I needed to run a conversion on any date column prior to writing the csv.
Im having similar issues, using CURRENT_DATE. Im trying to pull the data that has been edited in the last 24hrs. I have tried using CURRENT_TIMESTAMP, yet it still doesn't solve the issue. Its very strange, as the script worked for a period of time, now gives me the error shown below.
Below is the setup i am trying to get consistently working. Whats even stranger that if i change the WHERE clause to EditDate >= CURRENT_DATE - 10, it pulls the data correctly. Any help or guidance would be much appreciated. Im using ArcGIS Desktop 10.5.
Ashley Rymer go to My Organization tab in ArcGIS Online > Edit Settings > Security tab. I found that 'Allow only standard SQL queries' needs to be checked for the supported SQL functions to work.
I have checked our organisation tab and 'Allow only standard SQL queries' is checked. It just seems strange why CURRENT_DATE - 1 doesn't work, yet CURRENT_DATE - 10, works fine.
Go to the REST URL of the service and try entering the query there. Does it work when entering it there?
I just tried that query and it seems to work fine. Showing the results below. When i run using the script, it seems to run for a period of time then, give me the error i posted earlier.
ashley.rymer_EEGGIS feel free to share the service to an ArcGIS Online Group and invite my user account (jskinner_CountySandbox). I can take a look at it and see if there are any issues.
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.