|
BLOG
|
Enhancement request: We have a rather onerous table/object-naming convention for our SQL SOP. I've been trying, unsuccessfully, to edit the py to "bake" in a user-specified table(s) name, and not the {user supplied name}_{name of survey}. Any chance you could indicate where, in the py, one could accomplish that?
... View more
02-16-2017
03:43 AM
|
0
|
0
|
29411
|
|
BLOG
|
That did the trick, thanks! Regarding the relationships for my application, this is not an issue as I'm pulling this into SQL and using the data outside of Esri software.
... View more
02-16-2017
03:38 AM
|
0
|
0
|
29411
|
|
POST
|
The following, albeit a bit bulky, will read from a list of hosted feature services and create a csv for each with date and service calls per date. You can change the date range by changing the epoch date stamps. import csv
import urllib
import urllib2
import json
import datetime
# need to get a token
tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'
params = {'f': 'pjson', 'username': 'username', 'password': 'password', 'referer': 'https://www.arcgis.com'}
req = urllib2.Request(tokenURL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
token = data['token']
# read list of AGOL service names
readCSV = list(csv.reader(open('service.csv')))
names = []
for row in readCSV:
name = row[0]
#generate url list of up to 7 api calls
#Esri truncates usage stats into blocks of approx. 52 days
#Making a single url call for entire year will fail
#replace org with your org name and org_id with your org id
url1 = 'https://org.maps.arcgis.com/sharing/rest/portals/org_id/usage?f=json&startTime=1451624400000&endTime=1456808400000&period=1d&vars=num&groupby=name&etype=svcusg&name='+(name)+'&stype=features&token='+token
url2 = 'https://org.maps.arcgis.com/sharing/rest/portals/org_id/usage?f=json&startTime=1456808400000&endTime=1461988800000&period=1d&vars=num&groupby=name&etype=svcusg&name='+(name)+'&stype=features&token='+token
url3 = 'https://org.maps.arcgis.com/sharing/rest/portals/org_id/usage?f=json&startTime=1461988800000&endTime=1467172800000&period=1d&vars=num&groupby=name&etype=svcusg&name='+(name)+'&stype=features&token='+token
url4 = 'https://org.maps.arcgis.com/sharing/rest/portals/org_id/usage?f=json&startTime=1467172800000&endTime=1472356800000&period=1d&vars=num&groupby=name&etype=svcusg&name='+(name)+'&stype=features&token='+token
url5 = 'https://org.maps.arcgis.com/sharing/rest/portals/org_id/usage?f=json&startTime=1472356800000&endTime=1477540800000&period=1d&vars=num&groupby=name&etype=svcusg&name='+(name)+'&stype=features&token='+token
url6 = 'https://org.maps.arcgis.com/sharing/rest/portals/org_id/usage?f=json&startTime=1477540800000&endTime=1482728400000&period=1d&vars=num&groupby=name&etype=svcusg&name='+(name)+'&stype=features&token='+token
url7 = 'https://org.maps.arcgis.com/sharing/rest/portals/org_id/usage?f=json&startTime=1482728400000&endTime=1483160400000&period=1d&vars=num&groupby=name&etype=svcusg&name='+(name)+'&stype=features&token='+token
#Make 7 url calls for year. Will fail if 7 calls and feature was posted mid-year
#so try blocks will keep trying less url calls
try:
print 'Reading the usage statistics for '+(name)+' for 2016....'
filename = (name)+'.csv'
data = json.loads(urllib.urlopen(url1).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url2).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url3).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url4).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url5).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url6).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url7).read())['data'][0]['num']
print 'Writing '+(filename)+'....'
with open(filename, 'wb') as output:
csv_writer = csv.writer(output)
csv_writer.writerow(['date',(name)])
for date, count in data:
csv_writer.writerow([datetime.datetime.fromtimestamp(int(date)/1e3), count])
except Exception:
try:
print 'Reading the usage statistics for '+(name)+' for the last 313 days of 2016....'
filename = (name)+'.csv'
data = json.loads(urllib.urlopen(url2).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url3).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url4).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url5).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url6).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url7).read())['data'][0]['num']
print 'Writing '+(filename)+'....'
with open(filename, 'wb') as output:
csv_writer = csv.writer(output)
csv_writer.writerow(['date',(name)])
for date, count in data:
csv_writer.writerow([datetime.datetime.fromtimestamp(int(date)/1e3), count])
except Exception:
try:
print 'Reading the usage statistics for '+(name)+' for the last 261 days of 2016....'
filename = (name)+'.csv'
data = json.loads(urllib.urlopen(url3).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url4).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url5).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url6).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url7).read())['data'][0]['num']
print 'Writing '+(filename)+'....'
with open(filename, 'wb') as output:
csv_writer = csv.writer(output)
csv_writer.writerow(['date',(name)])
for date, count in data:
csv_writer.writerow([datetime.datetime.fromtimestamp(int(date)/1e3), count])
except Exception:
try:
print 'Reading the usage statistics for '+(name)+' for the last 209 days of 216....'
filename = (name)+'.csv'
data = json.loads(urllib.urlopen(url4).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url5).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url6).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url7).read())['data'][0]['num']
print 'Writing '+(filename)+'....'
with open(filename, 'wb') as output:
csv_writer = csv.writer(output)
csv_writer.writerow(['date',(name)])
for date, count in data:
csv_writer.writerow([datetime.datetime.fromtimestamp(int(date)/1e3), count])
except Exception:
try:
print 'Reading the usage statistics for '+(name)+' for the last 157 days of 2016....'
filename = (name)+'.csv'
data = json.loads(urllib.urlopen(url5).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url6).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url7).read())['data'][0]['num']
print 'Writing '+(filename)+'....'
with open(filename, 'wb') as output:
csv_writer = csv.writer(output)
csv_writer.writerow(['date',(name)])
for date, count in data:
csv_writer.writerow([datetime.datetime.fromtimestamp(int(date)/1e3), count])
except Exception:
try:
print 'Reading the usage statistics for '+(name)+' for the last 105 days of 2016....'
filename = (name)+'.csv'
data = json.loads(urllib.urlopen(url6).read())['data'][0]['num']
data = data + json.loads(urllib.urlopen(url7).read())['data'][0]['num']
print 'Writing '+(filename)+'....'
with open(filename, 'wb') as output:
csv_writer = csv.writer(output)
csv_writer.writerow(['date',(name)])
for date, count in data:
csv_writer.writerow([datetime.datetime.fromtimestamp(int(date)/1e3), count])
except Exception:
try:
print 'Reading the usage statistics for '+(name)+' for the last 53 days of 2016....'
filename = (name)+'.csv'
data = json.loads(urllib.urlopen(url7).read())['data'][0]['num']
print 'Writing '+(filename)+'....'
with open(filename, 'wb') as output:
csv_writer = csv.writer(output)
csv_writer.writerow(['date',(name)])
for date, count in data:
csv_writer.writerow([datetime.datetime.fromtimestamp(int(date)/1e3), count])
except:
print 'No usage statistics available too short time range'
pass
... View more
02-12-2017
02:03 PM
|
2
|
0
|
2878
|
|
POST
|
I am convinced that this and this will do as you ask, but would require some python tinkering that is beyond my skill level. I too, am looking for the same thing. I have hundreds of hosted feature services, and we need a more automated/technical way of getting those into a spreadsheet so we can globally look at service usage and make management decisions on how or when we update data. Having to click the usage button on 400 different item description pages then screen-shooting the graph does not meet that need. Surprised with such a well-documented REST API, that Esri has not included this basic requirement.
... View more
02-10-2017
08:43 AM
|
1
|
0
|
2878
|
|
POST
|
Add Data Widget fails to add GPX file. Add Data widget—Web AppBuilder for ArcGIS | ArcGIS indicates that in WAB 2.3, one should be able to "Drag" or "Add" a GPX file to a web map using the widget. That does not occur, instead, an error message "Generate Feature Error: Data upload to hosted server failed". This is on an instance hosted internally, deployed using WAB for Developers. I am able to add zipped shapefiles (any projection) as well as csv files. I have tried many GPX files, which work fine in DNRGARMIN and Basecamp, so the problem is not with the GPX file. Happens with multiple versions of Chrome, Firefox, and IE.
... View more
02-10-2017
04:29 AM
|
0
|
17
|
8669
|
|
BLOG
|
When using a survey that has repeat questions, which, in turn, results in survey answers being stored in database relationships, invoking SyncSurvey.py returns the following error: C:\PY_SCRIPTS\SURV_SYNC>python syncSurvey.py SASQUATCH.gdb GRSM_HWA_MON_SRV_TEST https://services1.arcgis.com/orgid/ArcGIS/rest/services/service_someguid/FeatureServer US/Eastern https://www.arcgis.com
-Getting Replica
{"replicaName":"","replicaID":"","submissionTime":1486556009510,"lastUpdatedTime":1486556013337,"status":"ExportingData","resultUrl":""}
-Check 1: ExportingData
{"replicaName":"","replicaID":"","submissionTime":1486556009510,"lastUpdatedTime":1486556016447,"status":"Completed","resultUrl":"https://services1.arcgis.com/orgid/ArcGIS/rest/services/service_someguid/FeatureServer/replicafiles/4faa340f83ea42829aa9ed0696ebc7b9.zi
p"}
-Check 2: Completed
-Temporary Directory: c:\users\user\appdata\local\temp\1\tmplwcpbq
f1122fc78a194a749233fb8d573e8689.gdb
-Filtering records to new set
-CreationDate > date '2017-02-08 12:13:20'
featureclass
-Adding Syncronization Time
-Creating Tables
-Creating Domains
-
-
-
-
-
-
-
-
-
-Creating Feature Classes & Tables
-Created GRSM_HWA_MON_SRV_TEST_GRSM_HWA_Mon
-Created GRSM_HWA_MON_SRV_TEST_IndividualTree
-Created GRSM_HWA_MON_SRV_TEST_BiocontrolSpeciesData
-Creating Relationships
======================
FAIL: Making Tables
exception:
Failed to execute. Parameters are not valid.
ERROR 000800: The value is not a member of globalid.
Failed to execute (CreateRelationshipClass).
['Failed to execute. Parameters are not valid.\nERROR 000800: The value is not a member of globalid.\nFailed to execute (CreateRelationshipClass).\n']
<class 'arcgisscripting.ExecuteError'>
562
----------------------
arcpy messages:
Failed to execute. Parameters are not valid.
ERROR 000800: The value is not a member of globalid.
Failed to execute (CreateRelationshipClass).
======================
C:\PY_SCRIPTS\SURV_SYNC>
C:\PY_SCRIPTS\SURV_SYNC>
C:\PY_SCRIPTS\SURV_SYNC>
... View more
02-08-2017
04:26 AM
|
0
|
0
|
29411
|
|
POST
|
I have noticed the same thing. If I share with any group other than anyone, the item details page shows it as not shared, which is incredibly frustrating, but I don't have the strength or time to submit a case on this.
... View more
02-02-2017
01:19 PM
|
0
|
1
|
1456
|
|
POST
|
I've managed to get to a supervisor on the tech support team, my only recommendation is to do the same, and often.
... View more
02-02-2017
10:28 AM
|
0
|
1
|
2854
|
|
POST
|
For the many of you that have a "challenging" wi-fi environment and have previously depended upon Arc Pad's stability in provisioning data on and off a mobile device via USB cable, be sure to vote on this idea! Sync Collector for ArcGIS via USB
... View more
01-23-2017
05:23 AM
|
0
|
0
|
1008
|
|
BLOG
|
I stopped tinkering with the PY and as you say...it works...when an org user is logged on. But...back to the tinkering...this may be more of an enhancement/not possible request...where I'm really trying to go with this it to automate it so I can run it nightly under task scheduler. I'm not sure it's possible to attach an Active Directory auth certificate, say, from a service account, in place of your named user part of the login? I'm finding all sorts of neat uses for your script.
... View more
01-18-2017
10:42 AM
|
0
|
0
|
29411
|
|
BLOG
|
This might fall into the range of enhancement request, but despite my tinkering with the PY code (removing asking for the id and pw), running this in Arc Cat/Map while logged in using an enterprise account....doesn't work with numerous PY exceptions. As many organizations are moving toward that authentication model.....
... View more
01-18-2017
06:46 AM
|
0
|
0
|
29411
|
|
POST
|
Yeah, I'm just getting that from Garmin support. They have no plans to push Monterra-Android updates, which is currently locked at 4.0.4. Very disappointed Garmin customer.....
... View more
01-17-2017
12:53 PM
|
0
|
3
|
2854
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-17-2022 12:19 PM | |
| 1 | 03-14-2019 06:24 AM | |
| 1 | 07-12-2018 09:29 AM | |
| 1 | 06-27-2019 12:08 PM | |
| 2 | 09-23-2019 11:03 AM |
| Online Status |
Offline
|
| Date Last Visited |
04-26-2026
07:12 AM
|