|
POST
|
Asrujit SenGupta, good points of clarification. Taking those points into consideration, it doesn't change my belief that I don't want ArcGIS assuming the first non-null field it finds is the unique identifier for a database view. Embedding special meaning to column ordering doesn't seem like a sound solution.
... View more
02-09-2015
08:52 AM
|
2
|
0
|
2119
|
|
POST
|
No. The strings can be whatever length you specify, I simply chose 12 because looking over the data, it appeared 12 characters was more than enough to hold all the potential values. If you need a 48 character string, either 'S48' or '|S48' would work. If you are working with Unicode, then use a U in place of an S.
... View more
02-09-2015
08:13 AM
|
0
|
0
|
240
|
|
POST
|
I would argue the "fix" shows the limitations of not allowing views to be registered on the server side. Although implementing this fix will make the prompts go away, it is really just changing band-aids and not addressing the core issue. What happens if the first not-null field isn't the unique identifier?
... View more
02-09-2015
08:07 AM
|
2
|
0
|
1842
|
|
POST
|
The above concept can be expanded to download all the information and create a point feature class. import arcpy
import json
import numpy
import urllib2
fc = #feature class location
if arcpy.Exists(fc):
arcpy.Delete_management(fc)
url = "http://api.metro.net/agencies/lametro/vehicles/"
parsed_json = json.load(urllib2.urlopen(url))
sr = arcpy.SpatialReference(4326) #assuming wgs84 coords but didn't verify
ndtype = numpy.dtype([
('id', 'S12'),
('route_id', 'S12'),
('run_id', 'S12'),
('latitude', 'f8'),
('longitude', 'f8'),
('heading', 'f8'),
('seconds_since_report', 'i4'),
('predictable', '?')
])
vehicles = []
for item in parsed_json['items']:
vehicles.append(tuple(item for k in ndtype.names))
narr = numpy.array(vehicles, ndtype)
arcpy.da.NumPyArrayToFeatureClass(narr, fc, ['longitude', 'latitude'], sr)
... View more
02-08-2015
09:33 AM
|
2
|
6
|
1796
|
|
POST
|
Instead of troubleshooting your current approach, I am going to suggest a different one for a couple of reasons. First, there seems to be lines in your code that aren't doing anything, or at least not contributing to building your table. Fortunately your screenshots can be used to figure out the intent of the code. Second, writing the results to an intermediate/temporary CSV file on disk adds extra steps and slows performance. The NumPy conversion functions in the ArcPy Data Access module (arcpy.da) are very robust, high performing, and I would argue designed for situations just like this one. Although I still find NumPy documentation lacking in clarity in many areas, it is well worth learning and using with and without ArcPy. import arcpy
import json
import numpy
import urllib2
tbl = #table location
if arcpy.Exists(tbl):
arcpy.Delete_management(tbl)
url = "http://api.metro.net/agencies/lametro/vehicles/"
parsed_json = json.load(urllib2.urlopen(url))
LatLongs = []
for item in parsed_json['items']:
LatLongs.append((
str(item['latitude']).encode('utf-8'),
str(item['longitude']).encode('utf-8')
))
narr = numpy.array(LatLongs,
numpy.dtype([('latitude', '|S12'), ('longitude', '|S12')]))
arcpy.da.NumPyArrayToTable(narr, tbl)
... View more
02-08-2015
08:22 AM
|
0
|
7
|
1796
|
|
POST
|
Robert, if you could use Syntax highlighting in the advanced editor, it would make reading and discussing your code easier for commenters. You are getting that error because of the del cur statement in the finally section of your code. In Python error handling, the finally clause is always executed before exiting the try statement, even if there was an error. In your case, you had an error either while creating the cursor object or before, and the cursor object was never instantiated. Since it wasn't instantiated, it can't be deleted in the finally clause. Looking at the code, you should have received another error message before the del cur error. What other messages did you receive?
... View more
02-06-2015
02:42 PM
|
0
|
0
|
2140
|
|
POST
|
That is another approach. Although I like working with SQL, building SQL expressions via Python and passing them to Esri tools seems to be a hang up for lots of folks, so I decided against suggesting a where_clause, but it will work.
... View more
02-05-2015
08:57 AM
|
1
|
1
|
1300
|
|
POST
|
Haven't tested, but try: import arcpy
from arcpy import env
env.workspace = r"C:\SouthA\Bolivia.gdb"
listFCs = arcpy.ListFeatureClasses("*")
for fc in listFCs:
with arcpy.da.UpdateCursor(fc, ["field1", "field2", "field6", "field7"]) as cur:
for row in cur:
if 0 in row:
cur.deleteRow()
... View more
02-05-2015
06:54 AM
|
2
|
3
|
1300
|
|
POST
|
For starters, I encourage you to read up on the Arcpy Data Access module (arcpy.da). The cursors in the data access module are newer, more robust, and higher performing than the older cursors. I gotta step out but will post some code when I get back if someone hasn't already.
... View more
02-05-2015
06:48 AM
|
1
|
4
|
1300
|
|
POST
|
I am using ArcGIS Pro 1.0.0. Yes, it works, I tested it before posting the other day. I just tested it again, and it worked without any issues: arcpy.MakeFeatureLayer_management(r"D:\tmp\test.sqlite\webMerc1","webMerc")
<Result 'webMerc'> It is helpful if you can post specific code and error messages, especially since it keeps not working for you. I am not sure what is different between our machines. I recently re-imaged my machine using Windows 7 64-bit Enterprise Edition. I installed ArcGIS 10.3 before I got around to putting ArcGIS Pro on the machine, but the installations should be compartmentalized from each other. Anyhow, I was loading SQLite databases into Pro with the beta versions and pre-releases before I re-imaged my machine. Have you tried creating a layer file in ArcGIS Desktop that points to a SQLite data source and then load that layer file into ArcGIS Pro? As has been pointed out, SQLite isn't officially supported yet, so the best approach in the interim might be to find an alternate data store.
... View more
02-05-2015
06:44 AM
|
1
|
1
|
4787
|
|
POST
|
Is there a reason you are looking at 9.3 Help even though you are using 10.2? A lot has changed in nearly 7 years.
... View more
02-04-2015
11:12 AM
|
0
|
9
|
3470
|
|
POST
|
You might want to try: field = "COUNTY_CODE"
where_clause = "{} = '{}'".format(field, code[0]) or where_clause = "COUNTY_CODE = '{}'".format(code[0]) You don't need to put your field name in quotes, but the value itself will need to be in quotes if it is text. I strongly encourage you to read up on Python String Formatting. It is much more powerful and Pythonic for building SQL expressions than concatenating strings together.
... View more
02-04-2015
07:06 AM
|
5
|
2
|
2219
|
|
POST
|
Not completely sure this will address your need, although I think it is in the ballpark: Geodatabase Geek - THE “INVERSE” MULTI-VERSION VIEW Although I am not currently implementing it, I did implement it on a project years back. If my memory serves me, it worked well, and I especially liked that it was a SQL view so you can check for all of the edits at any time you want by refreshing the view.
... View more
02-03-2015
11:00 AM
|
1
|
0
|
1710
|
|
POST
|
It is helpful to review the Help for Building a query expression, where it states: If the string contains a single quote you will first need to use another single quote as an escape character. In Python, the backslash is the dominant escape character, but there are some additional escape sequences. ArcGIS wants users to escape a single quote by using another single quote. I see that Xander Bakker beat me to the punch with the actual code. That's what getting distracted while replying gets me. : )
... View more
02-02-2015
09:43 AM
|
1
|
1
|
2018
|
|
POST
|
It is helpful to post specific error messages, if any, as well. Try changing your second to last line to: arcpy.DeleteField_management(delete, ["Pump", "Well", "Tank"])
... View more
02-02-2015
08:34 AM
|
1
|
1
|
931
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | yesterday | |
| 1 | 2 weeks ago | |
| 1 | 3 weeks ago | |
| 1 | 12-19-2025 06:05 AM | |
| 1 | 12-02-2025 07:31 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|