|
POST
|
I tested your code with desktop 10.5 and could not generate an error with either a table or a feature (w/o geometry). What version are you running? Is it possible the error is associated with another line in your script?
... View more
06-09-2018
06:18 PM
|
1
|
4
|
2994
|
|
POST
|
You might try something like: import arcpy
arcpy.env.workspace = r'C:\Path\To\File.gdb'
for fds in arcpy.ListDatasets('','Feature'):
print "{}".format(fds)
features = 0
for fc in arcpy.ListFeatureClasses('','',fds):
count = int(arcpy.GetCount_management(fc).getOutput(0))
if count:
features += 1
print "\t{}: {} records".format(fc, count)
else:
print "\t{} records, deleting: {}".format(count, fc)
# arcpy.Delete_management(fc) # uncomment to delete fc
print "{} has {} remaining features".format(fds, features)
... View more
06-07-2018
09:11 PM
|
2
|
4
|
4036
|
|
POST
|
Translation: I have a trial period for arcgis pro but it does not work, I can not download it
... View more
05-31-2018
01:36 PM
|
1
|
0
|
1088
|
|
POST
|
I have noticed a similar issue with 10.5 desktop. I performed a test using a range domain on fields of type Long Integer and Date. Editing a file geodatabase inside ArcMap, I could set the fields to a value outside the range.
... View more
05-30-2018
05:31 PM
|
0
|
0
|
2850
|
|
POST
|
If you were collecting in off-line mode, you may try to recover the geodatabase from the device. See: How To: Access offline edits from Collector for ArcGIS directly from an Android or iOS device
... View more
05-24-2018
10:33 AM
|
0
|
0
|
776
|
|
POST
|
The types section is near the bottom of the JSON file, and it will look something like this: "types" : [
{
"id" : "N",
"name" : "No",
"domains" :
{
"Status" : {"type" : "inherited"},
"AnotherDomain" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "No",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"AnotherDomain" : null,
"NoDomain" : null,
"Status" : "N"
}
}
}
]
},
{
"id" : "Y",
"name" : "Yes",
"domains" :
{
"Status" : {"type" : "inherited"},
"AnotherDomain" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "Yes",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"AnotherDomain" : null,
"NoDomain" : null,
"Status" : "Y"
}
}
}
]
},
{
"id" : "NA",
"name" : "Inaccessible",
"domains" :
{
"Status" : {"type" : "inherited"},
"AnotherDomain" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "Inaccessible",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"AnotherDomain" : null,
"NoDomain" : null,
"Status" : "NA"
}
}
}
]
},
{
"id" : "DNE",
"name" : "Does not exist",
"domains" :
{
"Status" : {"type" : "inherited"},
"AnotherDomain" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "Does not exist",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"AnotherDomain" : null,
"NoDomain" : null,
"Status" : "DNE"
}
}
}
]
}
],
The id is the coded value for your domain. The name is the description of the code. Fields that use domains (for example the field "AnotherDomain") will be listed in the domains section; type: inherited means they should keep the value they have when the symbol is changed. All editable fields should appear in the attributes section; a null value indicates the field's value should not change when the symbol is changed. In this example, the "Status" field is using the "Status" domain, and its value will be changed to the coded value that matches its ID. The "NoDomain" field represents the fields without domains. If a field in the attributes list has a value other than null, its value will change when the symbol "Status" field is changed; this may be a desired action. You can copy the section from the JSON file, add your new coded values to it (probably by duplicating the yes-no section and changing to the two new options). Then remove the comma after the last square bracket, enclose the section in curly braces { }, check it with jsonlint.com for valid json format, and then you can update that section using the REST API. It should be a similar process that you have used for updating the field. NOTE: I recommend experimenting with a back-up copy until you are confident with the process.
... View more
05-23-2018
11:05 AM
|
2
|
1
|
1682
|
|
POST
|
Is the field with the newly updated domain associated with the layer's symbology? If so, you may also need to make an adjustment in the types section of the JSON file.
... View more
05-23-2018
09:34 AM
|
0
|
3
|
1682
|
|
POST
|
I must admit that I have not worked with SDE feature classes. I'm not sure if building indexes for the columns used by the tool will improve the speed. The tool works to build a parcel UID by starting with a district code, adding a village code, quarter code, block code, etc. It might be possible to build a table with only the unique combinations of the first four parts of the parcel code that contains much fewer rows than the feature class. Perhaps this would allow your user to start building a correct query that could then be used to make the final query. I notice that the parcel UID might point to the sheet and plan numbers, and that the plan number would point to the parcels that are involved. It might be possible to reorder the fields queried and perhaps eliminate one. These are just some initial thoughts. Hope it helps.
... View more
05-22-2018
09:22 PM
|
0
|
0
|
1505
|
|
POST
|
From your code, it looks like you are working with a file geodatabase. I would (as Mitch Holley is suggesting) confirm that the field "created_date" exists in the geodatabase and is a date type. I was able to generate an ERROR 000358 by misspelling the date's field name or by using a non-date field in SQL where clause.
... View more
05-22-2018
09:32 AM
|
0
|
1
|
2564
|
|
POST
|
Specifying DATE works with ArcMap's file geodatabases and some other SQL versions. Some versions don't like/use DATE. If you get an error message, post the text of the message as that will help in getting to a solution. It may also help to know what type of geodatabase you are using. Hope this helps.
... View more
05-17-2018
03:56 PM
|
0
|
3
|
2564
|
|
POST
|
Delete lines 9, 10, 12 and 13 from your script. I had posted code pasted from the IDE; I should have cleaned it a bit. Your code should look something like this (but I did not test it): import arcpy
import datetime as DT
fc = r"C:\Temp\BuildingPermit.gdb\ParcelData"
arcpy.MakeFeatureLayer_management(fc, "PT_FC")
from_date = DT.date.today() - DT.timedelta(days=180)
SQL = "created_date >= DATE '{}'".format(from_date.strftime('%Y-%m-%d %H:%M:%S'))
arcpy.SelectLayerByAttribute_management("PT_FC","NEW_SELECTION", SQL)
arcpy.FeatureClassToFeatureClass_conversion("PT_FC", "C:\Temp", "BP_TestA")
... View more
05-17-2018
03:46 PM
|
2
|
4
|
2564
|
|
POST
|
I've used something like: >>> import datetime as DT
>>> from_date = DT.date.today() - DT.timedelta(days=180)
>>> from_date
datetime.date(2017, 11, 18)
>>> SQL = "created_date >= '{}'".format(from_date.strftime('%Y-%m-%d %H:%M:%S'))
>>> SQL
"created_date >= '2017-11-18 00:00:00'"
# sometimes you need to indicate type is DATE
# SQL = "created_date >= DATE '{}'".format(from_date.strftime('%Y-%m-%d %H:%M:%S'))
... View more
05-17-2018
02:19 PM
|
1
|
6
|
2564
|
|
POST
|
I've worked with the sample data that you have provided and have a script tool that might give you an idea for your project. It is based on code in this thread: Conditional Drop Down Lists - Tool Validator. If a feature is selected that has the required fields, it will allow the user to drill down to a parcel. Currently the script just selects the parcel, but code can be added to zoom to it. Most of the work is done in the updateParameters module of the ToolValidator class: class ToolValidator(object):
def __init__(self):
import arcpy
self.params = arcpy.GetParameterInfo()
def initializeParameters(self):
# (initializeParameters code here)
return
def updateParameters(self):
if self.params[0].value: # feature has been selected
useFields = [u'DIST_CODE', u'VIL_CODE', u'QRTR_CODE', u'BLCK_CODE', u'SHEET', u'PLAN', u'PARCEL_NBR'] # name of fields used by tool - in order
desc = arcpy.Describe(self.params[0].value) # information about the input feature
fieldNames = { f.name: f.type for f in desc.fields } # dictionary used to keep field names and types together
if set(useFields).issubset(fieldNames.keys()): # all fields were found by tool
fc, c_1 = str(self.params[0].value), useFields[0] # DIST_CODE
self.params[1].filter.list = [str(val) for val in sorted(set(row.getValue(c_1) for row in arcpy.SearchCursor(fc,fields=c_1)))]
if self.params[1].value not in self.params[1].filter.list:
self.params[1].value = self.params[1].filter.list[0]
fc, c_2 = str(self.params[0].value), useFields[1] # VIL_CODE
if fieldNames[useFields[0]] == u'String':
wc2 = "{} = '{}'".format(useFields[0], str(self.params[1].value)) # field is string
else:
wc2 = "{} = {}".format(useFields[0], str(self.params[1].value)) # field assumed to be a number field
self.params[2].filter.list = [str(val) for val in sorted(set(row.getValue(c_2) for row in arcpy.SearchCursor(fc,fields=c_2,where_clause=wc2)))]
if self.params[2].value not in self.params[2].filter.list:
self.params[2].value = self.params[2].filter.list[0]
fc, c_3 = str(self.params[0].value), useFields[2] # QRTR_CODE
if fieldNames[useFields[1]] == u'String':
wc3 = "{} AND {} = '{}'".format(wc2, useFields[1], str(self.params[2].value)) # field is string
else:
wc3 = "{} AND {} = {}".format(wc2, useFields[1], str(self.params[2].value)) # field assumed to be a number field
self.params[3].filter.list = [str(val) for val in sorted(set(row.getValue(c_3) for row in arcpy.SearchCursor(fc,fields=c_3,where_clause=wc3)))]
if self.params[3].value not in self.params[3].filter.list:
self.params[3].value = self.params[3].filter.list[0]
fc, c_4 = str(self.params[0].value), useFields[3] # BLCK_CODE
if fieldNames[useFields[2]] == u'String':
wc4 = "{} AND {} = '{}'".format(wc3, useFields[2], str(self.params[3].value)) # field is string
else:
wc4 = "{} AND {} = {}".format(wc3, useFields[2], str(self.params[3].value)) # field assumed to be a number field
self.params[4].filter.list = [str(val) for val in sorted(set(row.getValue(c_4) for row in arcpy.SearchCursor(fc,fields=c_4,where_clause=wc4)))]
if self.params[4].value not in self.params[4].filter.list:
self.params[4].value = self.params[4].filter.list[0]
fc, c_5 = str(self.params[0].value), useFields[4] # SHEET
if fieldNames[useFields[3]] == u'String':
wc5 = "{} AND {} = '{}'".format(wc4, useFields[3], str(self.params[4].value)) # field is string
else:
wc5 = "{} AND {} = {}".format(wc4, useFields[3], str(self.params[4].value)) # field assumed to be a number field
self.params[5].filter.list = [str(val) for val in sorted(set(row.getValue(c_5) for row in arcpy.SearchCursor(fc,fields=c_5,where_clause=wc5)))]
if self.params[5].value not in self.params[5].filter.list:
self.params[5].value = self.params[5].filter.list[0]
fc, c_6 = str(self.params[0].value), useFields[5] # PLAN
if fieldNames[useFields[4]] == u'String':
wc6 = "{} AND {} = '{}'".format(wc5, useFields[4], str(self.params[5].value)) # field is string
else:
wc6 = "{} AND {} = {}".format(wc5, useFields[4], str(self.params[5].value)) # field assumed to be a number field
self.params[6].filter.list = [str(val) for val in sorted(set(row.getValue(c_6) for row in arcpy.SearchCursor(fc,fields=c_6,where_clause=wc6)))]
if self.params[6].value not in self.params[6].filter.list:
self.params[6].value = self.params[6].filter.list[0]
fc, c_7 = str(self.params[0].value), useFields[6] # PARCEL_NBR
if fieldNames[useFields[5]] == u'String':
wc7 = "{} AND {} = '{}'".format(wc6, useFields[5], str(self.params[6].value)) # field is string
else:
wc7 = "{} AND {} = {}".format(wc6, useFields[5], str(self.params[6].value)) # field assumed to be a number field
print wc7 # # Debug # #
self.params[7].filter.list = [str(val) for val in sorted(set(row.getValue(c_7) for row in arcpy.SearchCursor(fc,fields=c_7,where_clause=wc7)))]
if self.params[7].value not in self.params[7].filter.list:
self.params[7].value = self.params[7].filter.list[0]
# output completed whereClause
if fieldNames[useFields[6]] == u'String':
self.params[8].value = "{} AND {} = '{}'".format(wc7, useFields[6], str(self.params[7].value)) # where normally assumes string values for fields
else:
self.params[8].value = "{} AND {} = {}".format(wc7, useFields[6], str(self.params[7].value)) # Setting assumed to be a number field
else: # at least one of the field names does not exist in feature; using the parameter to hold an error message
if useFields[0] not in fieldNames.keys(): # DIST_CODE
self.params[1].value = "ERROR: Field '{}' not in selected feature class".format(useFields[0])
if useFields[1] not in fieldNames.keys(): # VIL_CODE
self.params[2].value = "ERROR: Field '{}' not in selected feature class".format(useFields[1])
if useFields[2] not in fieldNames.keys(): # QRTR_CODE
self.params[3].value = "ERROR: Field '{}' not in selected feature class".format(useFields[2])
if useFields[3] not in fieldNames.keys(): # BLCK_CODE
self.params[4].value = "ERROR: Field '{}' not in selected feature class".format(useFields[3])
if useFields[4] not in fieldNames.keys(): # SHEET
self.params[5].value = "ERROR: Field '{}' not in selected feature class".format(useFields[4])
if useFields[5] not in fieldNames.keys(): # PLAN
self.params[6].value = "ERROR: Field '{}' not in selected feature class".format(useFields[5])
if useFields[6] not in fieldNames.keys(): # PARCEL_NBR
self.params[7].value = "ERROR: Field '{}' not in selected feature class".format(useFields[6])
return
def updateMessages(self):
self.params[0].clearMessage() # clear all error messages
self.params[1].clearMessage()
self.params[2].clearMessage()
self.params[3].clearMessage()
self.params[4].clearMessage()
self.params[5].clearMessage()
self.params[6].clearMessage()
self.params[7].clearMessage()
if self.params[0].value is not None: # set error message if field not in feature so user can correct problem
useFields = [u'DIST_CODE', u'VIL_CODE', u'QRTR_CODE', u'BLCK_CODE', u'SHEET', u'PLAN', u'PARCEL_NBR'] # name of fields used by tool - in order
if self.params[7].value is not None:
if self.params[7].value.startswith("ERROR:"):
# self.params[7].value = None # clear error message in parameter value, if desired
self.params[0].setErrorMessage("Input FC '{}' does not contain field '{}'".format(self.params[0].value, useFields[6]))
self.params[7].setErrorMessage("Field '{}' is not in Input FC '{}'".format(useFields[6], self.params[0].value))
if self.params[6].value is not None:
if self.params[6].value.startswith("ERROR:"):
# self.params[6].value = None # clear error message in parameter value, if desired
self.params[0].setErrorMessage("Input FC '{}' does not contain field '{}'".format(self.params[0].value, useFields[5]))
self.params[6].setErrorMessage("Field '{}' is not in Input FC '{}'".format(useFields[5], self.params[0].value))
if self.params[5].value is not None:
if self.params[5].value.startswith("ERROR:"):
# self.params[5].value = None # clear error message in parameter value, if desired
self.params[0].setErrorMessage("Input FC '{}' does not contain field '{}'".format(self.params[0].value, useFields[4]))
self.params[5].setErrorMessage("Field '{}' is not in Input FC '{}'".format(useFields[4], self.params[0].value))
if self.params[4].value is not None:
if self.params[4].value.startswith("ERROR:"):
# self.params[4].value = None # clear error message in parameter value, if desired
self.params[0].setErrorMessage("Input FC '{}' does not contain field '{}'".format(self.params[0].value, useFields[3]))
self.params[4].setErrorMessage("Field '{}' is not in Input FC '{}'".format(useFields[3], self.params[0].value))
if self.params[3].value is not None:
if self.params[3].value.startswith("ERROR:"):
# self.params[3].value = None # clear error message in parameter value, if desired
self.params[0].setErrorMessage("Input FC '{}' does not contain field '{}'".format(self.params[0].value, useFields[2]))
self.params[3].setErrorMessage("Field '{}' is not in Input FC '{}'".format(useFields[2], self.params[0].value))
if self.params[2].value is not None:
if self.params[2].value.startswith("ERROR:"):
# self.params[2].value = None # clear error message in parameter value, if desired
self.params[0].setErrorMessage("Input FC '{}' does not contain field '{}'".format(self.params[0].value, useFields[1]))
self.params[2].setErrorMessage("Field '{}' is not in Input FC '{}'".format(useFields[1], self.params[0].value))
if self.params[1].value is not None:
if self.params[1].value.startswith("ERROR:"):
# self.params[1].value = None # clear error message in parameter value, if desired
self.params[0].setErrorMessage("Input FC '{}' does not contain field '{}'".format(self.params[0].value, useFields[0]))
self.params[1].setErrorMessage("Field '{}' is not in Input FC '{}'".format(useFields[0], self.params[0].value))
return
The script I used for testing: import arcpy
# to drill down to parcel number, use fields: DIST_CODE, VIL_CODE, QRTR_CODE, BLCK_CODE, SHEET, PLAN, PARCEL_NBR
# District, Town/Village, Quarter, Block, Sheet, Plan, and Parcel Number
inFC = arcpy.GetParameterAsText(0) # input feature class (Input, Data Type 'Feature Layer')
dist_code = arcpy.GetParameterAsText(1) # selected value of DIST_CODE field (Input, Data Type 'String')
vil_code = arcpy.GetParameterAsText(2) # selected value of VIL_CODE field (Input, Data Type 'String')
qrtr_code = arcpy.GetParameterAsText(3) # selected value of QRTR_CODE field (Input, Data Type 'String')
blck_code = arcpy.GetParameterAsText(4) # selected value of BLCK_CODE field (Input, Data Type 'String')
sheet_val = arcpy.GetParameterAsText(5) # selected value of SHEET field (Input, Data Type 'String')
plan_val = arcpy.GetParameterAsText(6) # selected value of PLAN field (Input, Data Type 'String')
parcel_nbr = arcpy.GetParameterAsText(7) # selected value of PARCEL_NBR field (Input, Data Type 'String')
whereClause = arcpy.GetParameterAsText(8) # set by ToolValidator updateParameters (Output, Derived, Data Type 'String')
arcpy.AddMessage("Where clause used: {}".format(whereClause))
arcpy.SelectLayerByAttribute_management(inFC, "NEW_SELECTION", where_clause=whereClause)
n = arcpy.GetCount_management(inFC)
arcpy.AddMessage("Number of records selected: {}".format(n)) And a couple of screen shots. I've attached the code and toolbox. You may need to edit the location of the script in the toolbox. I've also included a debug version of the ToolValidator code should you wish examine it. I'm not sure how a join would affect the tool as the field names sometimes get appended with the table name.
... View more
05-10-2018
09:51 PM
|
2
|
3
|
1505
|
|
POST
|
Another thread was asking a similar question for Pro: Connecting MS Access to ArcGIS Pro but there was no solution provided. Perhaps the pyodbc module will provide the connection you require. See: How to connect MS Access to Python using pyodbc, Connection modules for Microsoft SQL databases and Step 1: Configure development environment for pyodbc Python development As an alternative (using Desktop/Catalog not Pro), I have created a new personal geodatabase (which uses the .mdb Access extension). In Access, I can then copy tables from newer .accdb databases into the .mdb version, usually without loss of data. Then the table can be accessed in the personal geodatabase using the usual arcpy tools that are used to process file geodatabases. It is also possible to copy features/tables from a file geodatabase into the personal geodatabase using Catalog. Then using Access, the table can be copied from the .mdb version to the newer .accdb version.
... View more
05-10-2018
12:05 PM
|
1
|
0
|
6363
|
|
POST
|
I've been studying the information you attached. I haven't done a lot with model builder; the other post I mentioned was working with a script tool. The script tool could be used in a model, but would also perform a specific function on its own. You mention the code posted on 21 April. That was an example of debugging the ToolValidator section of a script tool. Since this section is inside a script tool, it is difficult to see what is happening in the module. The first 16 lines set up the ToolValidator class and provide it with some test values. The last few lines set up a validator and run the updateParameters and updateMessages blocks. Once the code runs as expected, then just the middle section is pasted into the script tools validation section. You ask if the tool will work with an SDE feature class that will have a joined table. I haven't worked with an SDE feature class, but I would think it probably would. Perhaps Jake Skinner would have a better idea. Regarding your remaining question, in the other post we were modifying the script tool to do multiple fields, in this case 3. We just need to add an additional 4 fields for your project.
... View more
05-09-2018
11:20 PM
|
0
|
0
|
1505
|
| 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 |
02-12-2026
07:13 PM
|