|
POST
|
The missing parenthesis was an error on my part. The expression should have been: Right([DATE_TEXT], len([DATE_TEXT] - 1)) Just poor proofreading. I fixed the calculation expression in my original post, since you marked that post as the correct answer. That way the answer will be all correct for anyone else that sees it. Your calculation is just as good, and there are probably several other ways to remove the leading zero once you have the correct selection of records. The bottom line is that the pattern is fixed now. Using replace would have been limited to fixing one date at a time to avoid removing zeros you wanted to keep.
... View more
07-07-2015
11:48 AM
|
0
|
0
|
4735
|
|
POST
|
You need to use Right, because you are keeping all of the string on the right minus one character, which would elinminate the left most character (i.e., the leading zero). Using Left would get rid of the last character in the string (i.e., the 4 of 2014), not the first character in the string. The SQL works for Shapefiles also. If the SQL doesn't work copy and paste an actual value from the field in to a post. You should also paste the DATE_TEXT actual value into your original calculation. Replace only works if every character in the second argument string is found in first argument string. Exact spelling is required.
... View more
07-07-2015
11:22 AM
|
0
|
3
|
4735
|
|
POST
|
The expression looks correct, but it will only affect a record with the exact value of "011/12/2014". I would instead select all records that have the leading zero you don't want and then remove it using the Right() method. For a File Geodatabase feature class the SQL expression for a Select By Attribute query to select records with an extra leading zero in the month should be: DATE_TEXT Like '0__/%' Assuming that selects all records with an extra zero, use this VB Script expression to calculate the field to remove the first character in the string: Right([DATE_TEXT], len([DATE_TEXT) - 1))
... View more
07-07-2015
11:06 AM
|
0
|
6
|
4735
|
|
POST
|
Change the Spatial Reference to the RI State Plane NAD 1983 projection that your x/y coordinates are based on, since your x/y make no sense in any other projection. You would have to use lat/long coordinates if you use the GCS_WGS_1984 Spatial Reference. Also set the ID field parameter to your Name field so that each line is assigned the boat being observed.
... View more
07-07-2015
07:38 AM
|
2
|
1
|
1465
|
|
POST
|
The answer is ultimately that this is not something that can be controlled through either labeling engine and there will always be offending labels to any labeling strategy you want using automated labeling. You have to get as close to what you want and then convert to annotation if your client demands labeling to show the ends of roads and start at a specific road end. The Regular Placement Option gives you the ability to play with the most combinations of parameters. That option does expose a Label Offset option to control which line end the label starts at, but this option requires every line to be oriented exactly to fit your labeling strategy (i.,e. all north/south lines must start at the south and end at the north or vice versa). You should combine that with a reduction of units allowed for the Overrun Feature option. Even if every line in your network is perfectly oriented to fit your ideal labeling strategy the results will have odd placements in numerous areas of your map.
... View more
07-04-2015
11:25 AM
|
1
|
1
|
3616
|
|
POST
|
Although this Concave Hull Estimator tool originally created by Bruce Harold and enhanced by me uses a k-nearest neighbors approach (modified from that of A. Moreira and M. Y. Santos, Univeristy of Minho, Portugal) and not Delaunay triangulation, it creates a concave hull, which may also be useful to you.
... View more
07-03-2015
12:16 PM
|
0
|
0
|
2623
|
|
POST
|
Your code will only work with fields that are string, since numeric and date fields cannot be concatenated directly with the comma or each other. You would have to make line 15 read value = str(row[0]) + "," + str(row[1]). Additionally if you wish to sort the unique values with the sorted() function, your values will only be correctly sorted for string values and will be incorrectly sorted for numeric or date values. I would not accept an unsorted list of unique values for my own applications or uses. You should reverse your field test logic to set the fieldsExist to False if any field does not exist when dealing with a list of fields. You should be able to make your valueList a list of lists so that you do not need to do concatenation and can handle however many values come at you without any separate code. The list of lists can also be sorted correctly for each field type (although I have converted the interior list to a tuple, since lists don't work for some functions). The last couple of lines may have to be revised to run through the list of lists and add a comma separator after sorting (I did not test the code, but above the last two lines it should all work): fields = [testField1, testField2] # list can contain any number of fields
# Make sure all fields are upper case
for i in range(fields):
fields = fields.upper()
with open ("myTextFile.txt", "a") as text_file:
fcs = arcpy.ListFeatureClasses()
for fc in fcs:
fieldList = arcpy.ListFields(fc)
fieldsExists = True
for field in fieldList:
if not field.name.upper() in fields:
fieldsExists = False
valueList = []
# test all fields exist and append values to valueList
if (fieldsExists):
with arcpy.da.SearchCursor(fc, fields) as cursor:
for row in cursor:
fieldValues = []
for i in range(fields):
fieldValues.append(row)
valueList.append(tuple(fieldValues))
else:
print fc + " no valid fields"
uniqueValues = sorted(set(valueList))
text_file.write('{}'.format('\n'.join(uniqueValues)))
text_file.write('\n')
... View more
07-01-2015
10:58 AM
|
1
|
0
|
1699
|
|
POST
|
Owen: Thanks for your comments. Overall it sounds like I am on the right track. I have discovered that several geoprocessing tools ignore the spatial reference setting, such as GPX to Points (did not expect that) and Project (makes sense since you have to set the output spatial reference explicitly with the tool). In this case, since I want the user to be able to get to a Projected Coordinate System from a GCS input, supporting a new spatial reference through these two options saves them the step or Projecting their data separately.
... View more
06-29-2015
06:49 PM
|
0
|
3
|
3794
|
|
POST
|
Do not remove the del statements, correct their indentation. For some reason the indentation of the del statements changed between post 19 and post 20 in this thread, and my code had the incorrect indentation. So the del statements were falling outside of the if block and happening no matter what the selection was. I have indented the del statements one level and now everything should work exactly as you want. The cursors will be cleaned up and the code will not throw any error. The print of "There are no features selected" is what is supposed to happen if no points are selected, but now no error will occur. So the code should now completely satisfy all of your requirements as a Correct Answer. (if FCfield.name.upper() == incidentFCfield.name.upper() and FCfield.type == incidentFCfield.type and incidentFCfield.editable == True and not (FCfield.name.upper() in matchedFields): This line checks to make sure that both the FC and incidentFC have the same field in them, then it makes sure both fields are the same type, then it makes sure the field is editable so that data can be written to it, and finally it makes sure the field is not already in the matchedFields list. If all these conditions are satisfied the field is appended to the matchedFields list.
... View more
06-29-2015
10:13 AM
|
2
|
1
|
1142
|
|
POST
|
The error was due to the fact that I had added parentheses after the editable property. It was supposed to be identFCfield.editable not identFCfield.editable(). I have successfully run the code with your test data and it only copies the selected points and all of the matching fields had their data transferred when each backup point was created..
... View more
06-26-2015
04:40 PM
|
0
|
3
|
1142
|
|
POST
|
I believe that error occurred, because I just put "incidentFCfield.editable() and " and did not put "incidentFCfield.editable() == True and..." Try the revised code from my post again. The name property is not the problem and this is not a list issue, it is a field object property and expression issue.
... View more
06-26-2015
03:05 PM
|
1
|
5
|
2857
|
|
POST
|
Fixed. That was a simple copy paste error that carried over from the list of field objects and incorrectly applied to the list of field name strings. Although I do want to make my post have the code correct, you should also not just report the error, but attempt to figure out what an error like that is telling you and attempt to fix it yourself. Once this new code works you will need to mark it as the answer for others.
... View more
06-26-2015
11:14 AM
|
0
|
7
|
2857
|
|
POST
|
Python doesn't care about double or single quotes, except that they are paired when they enclose a string The slashes are just for readability and according to some posts I read were supposed to act as line continuations. So I have just removed them and put the line break version as a comment so it can be read..
... View more
06-26-2015
10:58 AM
|
0
|
9
|
2857
|
|
POST
|
Yes, lists are the key to what you want to do. that is why the arcpy.ListFields function returns a list of field objects (not just field names). With two of these lists from different databases you can create a looping structure that is nearly identical to the code I provided to relate the two lists and perform updates. The list of field objects can easily be converted to the list of field names used by the cursors. So here is some code that should work for relating two field lists for two different data sources using the ListFields function. Since the field lists for both the update cursor and insert cursor match you can use the same row object for the updateRow and InsertRow methods: import arcpy
from datetime import datetime as d
startTime = d.now()
#set to folder where features are located
arcpy.env.workspace = r"C:\Users\OWNER\Desktop\Test" #on windows use \ instead of /
arcpy.env.overwriteOutput = True
#---------------------------
#define variables for cursor
#---------------------------
FC = "test"
incidentsFC = "CCAP"
FCfields = arcpy.ListFields(FC)
incidentsFCfields = arcpy.ListFields(incidentsFC)
# Create a field list of fields you want to manipulate and not just copy
# All of these fields must be in the incidentsFC
manualFields = ["FacltyType", "StructType", "Verified", "Status", "StructCat", "APA_CODE", "ACCOUNT", 'SiteStreet', 'SHAPE@X', 'SHAPE@Y']
matchedFields = []
for manualField in manualFields:
matchedFields.append(manualField.upper())
for FCfield in FCfields:
for incidentFCfield in incidentsFCfields:
# if FCfield.name.upper() == incidentFCfield.name.upper() and \
# FCfield.type == incidentFCfield.type and \
# incidentFCfield.editable() and \
# not FCfield.name.upper() in matchedFields:
if FCfield.name.upper() == incidentFCfield.name.upper() and FCfield.type == incidentFCfield.type and incidentFCfield.editable == True and not (FCfield.name.upper() in matchedFields):
matchedFields.append(FCfield.name)
break
parcelsCount = int(arcpy.GetCount_management(FC).getOutput(0))
dsc = arcpy.Describe(FC)
rowInserter = arcpy.da.InsertCursor(incidentsFC, matchedFields)
selection_set = dsc.FIDSet
if len(selection_set) == 0:
print "There are no features selected"
elif parcelsCount >= 1:
with arcpy.da.UpdateCursor(FC, matchedFields) as rows:
for row in rows:
row[0] = ("Single Family Home")
row[1] = ("Primary, Private")
row[2] = ("Yes, GRM, TA")
row[3] = ("Active")
row[4] = ("Residential")
row[5] = ("1110")
rows.updateRow(row)
rowInserter.insertRow(row)
del row
del rows
del rowInserter
arcpy.RefreshActiveView()
try:
print '(Elapsed time: ' + str(d.now() - startTime)[:-3] + ')'
except Exception, e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print "Line %i" % tb.tb_lineno
print e.message
... View more
06-26-2015
09:58 AM
|
2
|
11
|
6124
|
|
POST
|
Personal and File GDBs will never be designed to satisfy the strict requirements of a DBA. Microsoft and Esri created them to be their low cost, easy to use databases that are marketed to attract Excel users to convert their data to a database. Ease of use will always trump precision and control for this market. Also, both have an interest in making Personal/File GDB's unsatisfactory alternatives to users of their very high cost lines of Enterprise database solutions. Precision and control are key to maintaining a distinction in these product lines. Microsoft and Esri are both expert at keeping functionality out of their low cost product line to protect their high end markets. We are fortunate that the masses have as much functionality as we do. So don't hold your breath for this functionality to be added to these low end databases.
... View more
06-26-2015
09:08 AM
|
1
|
1
|
2637
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-24-2026 11:37 PM | |
| 1 | 03-24-2026 08:01 PM | |
| 7 | 02-23-2026 08:34 AM | |
| 1 | 03-31-2025 03:25 PM | |
| 1 | 03-28-2025 06:54 PM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|