|
POST
|
You could use the field calculator and something like: def FieldCount(fld1,fld2, ...):
fields = [fld1, fld2, ...] # field values to list
return sum(f > 0 for f in fields)
FieldCount( !F01!, !F02!, ... ) Or this for the function: def FieldCount(fld1,fld2, ...):
return sum(v > 0 for k, v in locals().iteritems()) Also look at Joshua Bixby's answer in this thread.
... View more
01-27-2017
04:03 PM
|
2
|
1
|
3789
|
|
POST
|
I think line 35 is actually line 23 in the original code (as both lines 1 and 18 are multiple lines): arcpy.env.workspace = filepath
... View more
01-25-2017
02:03 PM
|
0
|
2
|
2135
|
|
POST
|
Perhaps something like: include sys
if int(result.getOutput(0)) > 0:
pass
else:
print "Goodbye!"
sys.exit(1) or just: include sys
if int(result.getOutput(0)) < 1:
print "Goodbye!"
sys.exit(1)
... View more
01-23-2017
03:21 PM
|
1
|
0
|
1379
|
|
POST
|
If I am understanding what you are trying to accomplish, I would suggest something like: import arcpy
# set up the input table
nodeFeatures = r'OSP Mapping Layers\Node Locations'
inTable = nodeFeatures
# GetParametersAsText will set latField and longField to the
# names of the field to be calculated
x = arcpy.GetParameterAsText(0)
if x == "Original":
latField = "OriginalLatitude"
longField = "OriginalLongitude"
elif x == "Adjusted":
latField = "AdjustedLatitude"
longField = "AdjustedLongitude"
else:
# assume x == "Both" (or add error code as needed)
latField = "BothLatitude"
longField = "BothLongitude"
# the calculation expression
expression = "!Shape.Centroid.Y!"
# CalculateField_management (in_table, field, expression, {expression_type}, {code_block})
# help page: http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/calculate-field.htm
arcpy.CalculateField_management(inTable, latField, expression, "PYTHON_9.3")
expression = "!Shape.Centroid.X!"
arcpy.CalculateField_management(inTable, longField, expression, "PYTHON_9.3")
Please note that I have simplified the code to show the major parts. I may have omitted code that you are using for other purposes.
... View more
01-20-2017
10:00 AM
|
1
|
0
|
2253
|
|
POST
|
I think line 48 in the 2.1 version of the script in the zip file (lines 48-52 in the code block of your original post) should read: x = arcpy.GetParameterAsText(0) Also lines 53-67 of the zip file (lines 57-71 in your original post) has indentation problems. This section does not appear to be a properly defined function, and the if else syntax appears incorrect.
... View more
01-19-2017
03:27 PM
|
1
|
0
|
2253
|
|
POST
|
Are you using a domain for your feature type/symbology? If you are using ArcMap, there is a tool to Sort Coded Value Domain that may be of help. The tool can sort by code or description. If you are using a service on ArcGIS Online, you can use the REST API to update the types in the feature's JSON file. This thread has a brief discussion on this process.
... View more
01-18-2017
04:53 PM
|
0
|
1
|
793
|
|
POST
|
Additional code examples for project as in this thread.
... View more
01-17-2017
11:47 AM
|
1
|
0
|
1248
|
|
POST
|
Since the error is happening at line 19, it suggests that there is a problem connecting to your server to obtain a token. There are a couple of help pages Generate Token and Generate Token (2) that may be of assistance. My code shows a simple connection to ArcGIS Online. You will need to change the fsURL in line 12 to point to your feature service. If you are using your own ArcGIS server the token and referrer urls in lines 15 and 18 will need to be changed; possibly you will need to use the client parameter. The following code snippet illustrates how you could connect to your own server instead of a feature hosted on AGO. tokenURL = 'http://' + server + '/arcgis/admin/generateToken'
params = {'username': username, 'password': password, 'client': 'requestip', 'f': 'pjson', 'expiration': 1440}
req = urllib2.Request(tokenURL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
token = data['token']
... View more
01-13-2017
10:25 AM
|
1
|
0
|
3426
|
|
POST
|
Using the ArcREST modules on github, your code would be: # create a time filter object
tf = TimeFilter(start_time=123, time_zone="UTC", end_time=456)
# or start and end times
tf = TimeFilter(123, end_time=456)
# or just a start time
tf = TimeFilter(123)
data = (fl.query(where="1=1", timeFilter=tf) )
# or
data = (fl.query(where="1=1", timeFilter=TimeFilter(start_time=123, end_time=456)) ) It does not appear that "time_zone" is implemented in the TimeFilter class. You may need to adjust the time stamp (Unix millisecond format) to the database's time zone if it is UTC or something other than your local time.
... View more
12-22-2016
10:41 PM
|
0
|
0
|
2050
|
|
POST
|
Perhaps the "time" or "timeFilter" is for working with the archive class. Working directly with the archive class mentions "If you are interested in seeing a specific feature at a specific time, refer to its object ID and enter the appropriate date and time."
... View more
12-22-2016
04:04 PM
|
0
|
0
|
2050
|
|
POST
|
I have looked at the code, and I believe the "timeFilter" equates to the "time" option found on the ArcREST API Query Feature Service page. It gives 3 examples with a little explanation: time=1199145600000
time=1199145600000, 1230768000000
time=null, 1230768000000 When I experimented with this, the query always returned all rows. My records have a CreateDate and an EditDate field, so I am not sure what the "timeFilter" or "time" option is doing. I did use this line of code in the github code to successfully retrieve records after a specific date/time: print (fl.query(where="EditDate > DATE '2016-05-29 18:30:00'",out_fields='*',returnGeometry=False) )
... View more
12-21-2016
09:33 PM
|
0
|
0
|
2050
|
|
POST
|
I haven't played around much with the ArcREST modules on github. Most of my interface with the REST API has been via ArcGIS Online (documentation here: ArcGIS REST API). Where I used timeFilter in my code sample, you could query the EditDate or CreateDate fields if editor tracking is enabled, and then you probably would not need the timeFilter reference. Probably something like: data = (fl.query(where="1=1 AND EditDate >= DATE '2016-12-19 00:00:00'") ) I will look at the github code in the next few days to see how "timeFilter" is being used.
... View more
12-21-2016
05:25 PM
|
0
|
0
|
2050
|
|
POST
|
I had made the assumption the date/time field name you were querying against was called "timeFilter". Use whatever name this field is called. You do not need to list it in the outFields if you are not interested in seeing or using it, likewise, you can sort (or not) on it or another field.
... View more
12-21-2016
04:21 PM
|
0
|
3
|
2050
|
|
POST
|
Here's a Python snippet to demonstrate: # your url, something like:
URL = "https://services.arcgis.com/<abc123>/arcgis/rest/services/<myFeatureLayer>/FeatureServer/0/query"
query_dict = {
"where" : "1=1 AND timeFilter BETWEEN DATE '2016-12-19 00:00:00' AND DATE '2016-12-21 00:00:00'",
"outFields" : "OBJECTID, timeFilter, Field1, Field2, FieldN",
"orderByFields" : "timeFilter",
"returnGeometry" : "true",
"f": "json", "token": token['token'] }
# results in json format
jsonResponse = urllib.urlopen(URL, urllib.urlencode(query_dict))
features = json.loads(jsonResponse.read(),
object_pairs_hook=collections.OrderedDict)[u'features']
... View more
12-21-2016
03:16 PM
|
0
|
5
|
2050
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2016 02:23 PM | |
| 1 | 09-09-2017 08:27 PM | |
| 2 | 08-20-2020 06:15 PM | |
| 1 | 10-21-2021 09:15 PM | |
| 1 | 07-19-2018 12:33 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-15-2025
02:54 PM
|