|
POST
|
Even more pythonic! Except I don't know how to format as code on the new forums here... with open(r'H:\Documents\blah\'output.txt', 'w') as fout: values = np.genfromtxt(r'H:\Documents\blah\input.txt',dtype='str') fout writelines("ID='" + str(val) + "' OR " for val in values) Also, for your output, rather than a bunch of OR clauses, you could make a python list and test using IN: ID IN ['34012', 35078', '39222'...]
... View more
09-26-2014
10:28 AM
|
2
|
2
|
2248
|
|
POST
|
I get an error with strftime if I try to use %T, which according to TutorialsPoint is a valid format, a shortcut for %H%M%S. But this raises an error, and in fact is not in the Python.org documentation for strftime. The point being that there's erroneous information out on the web. Who knew? If it's a locale issue, you may want to look at: strftime() returns a locale depedent byte string; the result may be converted to unicode by doing strftime(<myformat>).decode(locale.getlocale()[1]) . also from the same documentation.
... View more
09-24-2014
07:02 AM
|
0
|
1
|
3460
|
|
POST
|
Well, after working on it for a couple hours, then posting it here, I got the solution on my next try. For reference, here it is; where = arcpy.AddFieldDelimiters(intable, fcc) + ' = \'' + v + '\''
... View more
08-28-2014
01:18 PM
|
0
|
0
|
1017
|
|
POST
|
Any help on how to properly format the where clause in the following code would be greatly appreciated. I get an Invalid Expression error despite whatever combinations I try. v is a string value. Thanks. code: for v in lstFCCvalues: try: outfeature = os.path.join(fdstarget, v + 'Roads') if arcpy.Exists(outfeature): arcpy.Delete_management(outfeature) where = arcpy.AddFieldDelimiters(intable, fcc) + ' = ' + v arcpy.Select_analysis(intable, outfeature, where) except Exception as e: exceptionMessage(e) sample error; ERROR 000358: Invalid expression "FCC" = A00 Failed to execute (Select).
... View more
08-28-2014
12:58 PM
|
0
|
1
|
3011
|
|
POST
|
Solved. Needed quotes around the value. value = '"' + fc.capitalize() + '"' arcpy.CalculateField_management(fc, newfield, value, 'PYTHON_9.3')
... View more
08-27-2014
05:52 AM
|
1
|
1
|
1822
|
|
POST
|
I'm getting an ExecuteError, error 000539, in the code below when Calculating the field. The error appears to be on the second instance of fc, fc.capitalize(), because when I take out the capitalize(), I get the same error but without the capitalized name. I can't figure out what the problem is. Any ideas? Thanks. # code fds = 'RawFramework' newfield = 'CountyName' lstRawFCs = arcpy.ListFeatureClasses(None, 'All', fds) for fc in lstRawFCs: try: arcpy.AddField_management(fc, newfield, 'TEXT', field_length = 25, field_alias = 'County Name') arcpy.CalculateField_management(fc, newfield, fc.capitalize(), 'PYTHON_9.3') except Exception as e: print(e.message, e.__class__) # sample error (CalculateField).\n', <class 'arcgisscripting.ExecuteError'>) ('ERROR 000539: Error running expression: St_clair \nTraceback (most recent call last):\n File "<expression>", line 1, in <module>\nNameError: name \'San_Diego\' is not defined\n\nFailed to execute (CalculateField).\n', <class 'arcgisscripting.ExecuteError'>)
... View more
08-27-2014
05:25 AM
|
0
|
3
|
3856
|
|
POST
|
Thanks Xander! A PDF with layers sounds like what I need. Much appreciated.
... View more
08-05-2014
08:43 AM
|
1
|
0
|
1063
|
|
POST
|
Is it possible to share .lyr files in AGOL? I have an mxd with a couple dozen layers, all symbolized and labeled nicely, and would like to share it with some non Arc users to get their feedback, let them turn layers off & on, etc. I'm doing this from home using ArcGIS for Home 10.2 for a non-profit, so I don't have a server to publish features to (unless I can do that on AGOL?). I could upload a bunch of zipped shapefiles, but would have to resymbolize them all, and don't really want to do that. Thanks.
... View more
08-02-2014
10:57 AM
|
0
|
2
|
3188
|
|
POST
|
Thanks Ian, but ord didn't work. The values are test, a mix of letters, blanks and numbers. Ord() works on one at a time, and gave me a TypeError when I tried parsing the values. I did manage to fix the problem though. I'd forgotten that arcpy.da returns a tuple, not the (in this case) text value. When I added row[0] to the processing instead of just row, it worked as desired. Thanks everyone. I hesitate to mark my own answer as correct, don't want to violate protocol, but on the other hand that might be useful to others.
... View more
07-16-2014
12:42 PM
|
0
|
1
|
2667
|
|
POST
|
Thanks all. I searched for a python oriented forum, couldn't find it. This new format will really take some getting used to.
... View more
07-16-2014
08:33 AM
|
0
|
0
|
2667
|
|
POST
|
In the code below, the field values are returned in unicode (e.g. (u' 06510',)). How do I get this to return ascii, as in 06510,? Thanks. Hopefully doing this right, new forums confusing. with arcpy.da.SearchCursor(fc, "OLDPLATE") as rows: for row in rows: if row is None or len(row) == 0: lstNullOldPlates.append("Null or empty") else: lstAllOldPlates.append('{0}'.format(row))
... View more
07-16-2014
06:19 AM
|
0
|
7
|
3990
|
|
POST
|
Append isn't used to add attribute values. It adds features to an existing feature class. The errors you're getting are because you're trying to add polygons to polylines. So what to do? Depends on what you want and how your data is set up. You could convert your polygons to lines and append them. There are other methods as well, but really depends on your setup.
... View more
07-10-2014
08:30 AM
|
2
|
0
|
1162
|
|
POST
|
The coordinates are points, then? Have you looked at Placement Properties, where you can set the preferred orientation for each layer? E.g. Calcium above the point, Chlorine below, etc. Or there's always Annotation or Maplex.
... View more
06-23-2014
11:43 AM
|
0
|
0
|
1016
|
|
POST
|
You might try running MXD Doctor on your original map.
... View more
06-23-2014
06:47 AM
|
0
|
0
|
1257
|
|
POST
|
Try not putting your Update code in its own loop. If necessary, retrieve the OID or other unique field in your SearchCursor as well as the current field. Use the OID in a Where clause in your UpdateCursor. This way you'll loop through the records in your SearchCursor, and target the record the SearchCursor is on in your UpdateCursor. Or, you could try ditching the SearchCursor and just use an UpdateCursor, doing your calculation there before you call updateRow. I've never done this, but Help says UpdateCursor is read/write, so presumably it can function as a SearchCursor as well. The next() method returns a tuple of the values, so you should be able to read the necessary values out of that.
... View more
06-20-2014
12:02 PM
|
0
|
0
|
1609
|
| Title | Kudos | Posted |
|---|---|---|
| 6 | 08-22-2019 07:41 AM | |
| 1 | 05-05-2014 04:30 AM | |
| 1 | 08-15-2018 06:23 AM | |
| 3 | 08-06-2018 07:31 AM | |
| 1 | 03-30-2012 08:38 AM |
| Online Status |
Offline
|
| Date Last Visited |
12-12-2021
01:00 PM
|