|
POST
|
All layers and tables are from the same Feature Service. The URL is working if I paste it in the browser just load will not take it. Thanks!
... View more
04-20-2018
01:22 PM
|
0
|
2
|
3857
|
|
POST
|
Well I spoke too soon. This is working for Feature Classes but it is giving an error on all tables. This line gapLayer.load(q_response.url) gives this error Traceback (most recent call last): line 226, in <module> gapLayer.load(q_response.url) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\arcobjects\arcobjects.py", line 175, in load return convertArcObjectToPythonObject(self._arc_object.Load(*gp_fixargs(args))) RuntimeError: RecordSetObject: Cannot open table for Load I tied changing gapLayer = arcpy.FeatureSet() to gapLayer = arcpy.RecordSet() but I get the same error. (I was guessing it was due to not being a FC). I also tried taking out the returnGeometry=true part but still the same error. The JSON all looks good just the load function is not happy. Any ideas? Thanks
... View more
04-20-2018
12:52 PM
|
0
|
4
|
3857
|
|
POST
|
We have a guy here that wrote all the SAML stuff. I worked with him on this one and he ended up updating his code to get it to work - but we did get it to work. He has it on GitHub if you want to check it out. https://github.com/DOI-BLM/requests-arcgis-auth Simple code was import os
from uuid import uuid4
import requests
import arcpy
import requests
from requests_arcgis_auth import ArcGISPortalSAMLAuth
# Setup Parameters & Authentication
url = r'https://yourorg.maps.arcgis.com/sharing/rest' # change me
client_id = r'jkahfkashdf' # change me
item_id_to_query = r'sampleitemid' # change me
s = requests.session()
s.auth = ArcGISPortalSAMLAuth(client_id)
# Make a request to the item & obtain the feature service endpoint
response = s.post(url+"/content/items/{}?f=json".format(item_id_to_query))
fs_endpoint = response.json().get('url')
print ("Item ID {} feature service is hosted at {}".format(item_id_to_query,fs_endpoint))
# Query the end-point.
# Keep in mind, this only works because the service is 'federated' with the portal.
# This would not work for ANY service (including public/anonymous) as it will attach the token, and this token is only good for the specific portal we are working with
q_response = s.get(fs_endpoint + "/0/query?f=json&where=1=1&outFields=*&returnGeometry=true")
features = q_response.json().get('features')
print ("Found {} records on layer 0 of the fs endpoint".format(len(features)))
# Load to a 'feature set'
# Keep in mind, this works because the 'token' is present in the HTTP GET URL.
# May not be supported if it needs to be a POST or the parameters end up in the body of the request
fs = arcpy.FeatureSet()
fs.load(q_response.url)
with arcpy.da.SearchCursor(fs,"*") as cursor:
for row in cursor:
print(row) I am not tested my full script yet that has several SearchCursors but I am hopeful. Will report back. Thanks again!
... View more
04-20-2018
07:24 AM
|
0
|
5
|
3857
|
|
POST
|
Awsome! I wrote it up then hit the next issue though - logging in. I have some code the grabs our SAML logins to do something with AGO but I am not sure how to blend the two. I will let you know how it goes unless you have any ideas. Thanks a lot
... View more
04-19-2018
02:56 PM
|
0
|
7
|
3857
|
|
POST
|
Search Cursor would not work though right? I was hoping to have one code stack that works for gdb, sde, or a HFS URL. Thanks
... View more
04-19-2018
09:22 AM
|
0
|
9
|
3857
|
|
POST
|
In the past I have had some luck giving a AGOL HFS directly to a built in geoprocessing tool or script. I usually created a layer file and fed that in. BUT layer files refuse to save the tables - and most of what I want to use in tables. In fact tables are always hard to get in ArcMap. Try it - (Add a HFS with tables to ArcMap - save as layer file - open layer file - no tables! Or go to Add Data button - AGOL HFS - no tables! Or File - ArcOnline - Add - no tables! Finally in Catalog go down to My Hosted Services - add the HFS - and actual tables! But then save this out as a lyr file and tables are gone.). What I would like to do is change my input source in Python from this sourceDB = r"\\adgroup\blah\blah\data.gdb" to something like sourceDB = "direct link to HFS in AGOL" Most of the script is Search Cursors so it would need to work with that. This may be over hoping. Any ideas on this? Backup plan is to use the python api to export/download a GDB (I already have this code) then unzip and feed to script. But it would be nice to just go direct. Another option may be ArcPro using v3? Thanks for any ideas.
... View more
04-17-2018
01:28 PM
|
0
|
11
|
4934
|
|
POST
|
Since there is a URL to the HFS in the call does the call work offline? Going from Collector to Survey123 does work offline - but from Survey123 to Collector I am not sure if it just uses the URL to figure out the right layer or if it is going out to the net for something? Thanks
... View more
04-17-2018
07:39 AM
|
0
|
1
|
1863
|
|
POST
|
I tested and using just SHAPE@ works just fine. That means this code should work for any type of FC. Thanks
... View more
04-16-2018
10:08 AM
|
0
|
0
|
4108
|
|
POST
|
I did this exact thing (Plots to forms) but I did it with Relationship Classes. Worked out great. See my post on the very last page of this topic for more info https://community.esri.com/groups/survey123/blog/2016/07/30/understanding-survey123s-custom-url-scheme?messageTarget=all&start=150&mode=comments Hope it helps.
... View more
04-13-2018
08:57 AM
|
0
|
1
|
2998
|
|
POST
|
I just want to copy the geometry from A to B. Not change it in any way. thanks
... View more
04-12-2018
03:10 PM
|
0
|
1
|
4108
|
|
POST
|
Thanks a lot Joshua - great code. It took a minute because of a different issue. If you look close at my post I had the old Insert and missed the new .da part! Duh. That fixed a lot. I did change your code slightly to ask the outgoing FC its projection and then use that. This way it will work even if the SR is different that the hardcoded wkid. Works but if this is an issue let me know. sr = arcpy.Describe(terraFC).spatialReference fields = ["SHAPE@XY"] whereClause = "PlotKey = '" + plot + "'" # only want completed plots from above with arcpy.da.SearchCursor(plotLayer, fields, whereClause, spatial_reference=sr) as cursor: for row in cursor: dataValues.append(row[0]) for eachData in allDataValues: with arcpy.da.InsertCursor(terraFC, insertFields) as inCursor: inCursor.insertRow(eachData) I also wonder if you did fields = ["SHAPE@"] if it would work for any geometry type? It all works! Thanks again to everyone.
... View more
04-12-2018
02:44 PM
|
0
|
0
|
4108
|
|
POST
|
I am trying to copy a Point from a SearchCursor to a InsertCursor but I can never get the geometry to work. In past projects I ended up giving up on it and just did a Append then insert to get around it but I want to figure it out (unless this is a good way?). First note that the Search FC and the Insert FC are different projections. It may be that arc will not handle this for me. This is like what I am trying (mini version) but it gives a AttributeError: __exit__ FROM fields = [ 'SHAPE@'] with arcpy.da.SearchCursor(plotLayer, fields) as cursor: for row in cursor: saveShape = row[0] TO insertFields = [ 'SHAPE@'] with arcpy.InsertCursor(terraFC, insertFields) as inCursor: inCursor.insertRow(saveShape) I have also tried SHAPE@XY and still no. It seems like I have found code like this that works for Polygons but not points. Almost all examples of Point always use a x,y. Thanks a lot for any help
... View more
04-11-2018
01:31 PM
|
0
|
7
|
5012
|
|
POST
|
I can email but not sure I can post due to company policy. My email is in my profile. My question is really not having a compound statement in one filter it is that I want to use more than one column in 2 different choice filters. Thanks a lot!
... View more
04-06-2018
03:20 PM
|
0
|
1
|
3643
|
|
POST
|
Are you sure you can use two different columns in the lookup? I was testing this all day yesterday and for sure mine will only use one column. In fact the column must be one set name. My detailed post is here https://community.esri.com/message/762088-can-externalchoices-use-more-than-one-lookup-column-and-query-speed Thanks
... View more
04-06-2018
07:20 AM
|
0
|
6
|
6180
|
|
POST
|
I have been testing out external_choices most of the day and it seems that lookups are only on one column. For example if my choice filter 1 has Column1=${field1} then ALL my choice filters must use Column1. If I try Column2= it refuses to work. Now what is weird is that it MUST be called Column1 forever. So lets say I change ALL my choice filters to Column2 - no dice. If I go into the external_choices sheet and rename Column2 to Column1 it all works! Weird. Is external_choices somehow tied to a specific column name at the beginning and cannot be changed? Regular choices seems to be able to use other columns but not external_choices. I have also found that the length of the query makes a big speed difference. A simple Column1=${field1} is about 2 seconds. A Column1=${field1} or Column1=${field2} is about 4 seconds - and this continues adding on 2 seconds for each or I add. My solution to this was to use different Columns as talked about above but it does not work. The real issue with all of this is I am doing 8 external_choices lookups and they are all hitting a list of 1,300 items. It was taking 19 seconds to add a repeat with 4 or statements. It goes down to 4 seconds if there is just a simple query with no or. If I move then to choices it takes 30+ seconds and the forms loads slow. I should also note I am using a bit of a trick with external_choices. I have a calculate that is just text with my lookup value. So field1 calcs to "Y" then I use Column1=${field1} where Column1 is Y or N. I did see a post on here on ways to speed up the external_choices but I cannot find it now. Any hints to help my speed is greatly appreciated. Thanks
... View more
04-05-2018
03:07 PM
|
0
|
10
|
4655
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-10-2026 08:18 AM | |
| 1 | 2 weeks ago | |
| 1 | 3 weeks ago | |
| 1 | 4 weeks ago | |
| 1 | 05-28-2026 01:41 PM |
| Online Status |
Offline
|
| Date Last Visited |
4 hours ago
|