|
POST
|
I can't seem to locate the exact thread I participated in but it was about attempting to setup a Make Query Table with multiple fields and include a GROUP BY statement in the SQL. It wouldn't work from what I can remember, or it would execute but it doesn't do the grouping as expected. Perhaps I am misunderstanding the QueryTable!
... View more
09-11-2014
11:47 AM
|
0
|
0
|
4448
|
|
POST
|
cx_Oracle here. It's not always SDE data that is needed and non-spatial attribute data can be utilized in functional ways (mapping, joins, raster processing, etc...)
... View more
09-11-2014
05:59 AM
|
0
|
0
|
3327
|
|
POST
|
Can you post an example? I remember not being able to correctly apply a GROUP BY with multiple fields present in the SQL statement but it has been a while since then and I am not sure if I can even locate the thread in this new place.
... View more
09-11-2014
05:54 AM
|
0
|
5
|
2099
|
|
POST
|
It works for Robert because he is only returning 1 field. Your OP has multiple fields -- how can you return distinct values for multiple fields without correctly apply a GROUP BY clause?
... View more
09-09-2014
11:45 AM
|
0
|
7
|
2099
|
|
POST
|
Thanks for the example Xander --- it's good to see straight-forward solutions. While it's frustrating to be unable to issue more complex SQL on arcpy/GIS side of things, I'd even prefer to completely remove the SQL out of the code I posted and move that to StoredProcedures/PL-SQL packages on the database instead. As as an application and database devloper, it just makes sense to only return the rows needed rather than return everything and filter on the app side.
... View more
09-09-2014
10:26 AM
|
0
|
3
|
4448
|
|
POST
|
Looks like pyodbc will connect to SQL Server sql server - MSSQL in python 2.7 - Stack Overflow Pandas home Python Data Analysis Library — pandas: Python Data Analysis Library I am just a developer and don't have experience getting these installed, so you will have to figure that out.
... View more
09-09-2014
10:22 AM
|
0
|
0
|
4448
|
|
POST
|
I doubt you can perform GROUP BY clause in any arcpy SearchCursor (I can't remember where I saw this, but I think this is the case). However, you can: 1. Depending upon the Database type, you can issue your SQL in the python code. You will need the appropriate library (cx_Oracle, pyodbc, pysmssql, etc). 2. These typically put results into a "cursor" (not an arcpy cursor). So you will then have to parse this into your own list/array. 3. Take the list and either use it as it or perform an additional conversion to NumPy. 4. Or you can utilize pandas library to convert from your list and perform just about any grouping you'd want.
import cx_Oracle
import numpy
import pandas
con = cx_Oracle.connect('theuser', 'thepass', 'your DB alias on your TNSNAMES.ORA file ')
cur = con.cursor()
if cur.execute('select fld1, fld2 from WHERE fld1 = 'blah' GROUP BY fld1, fld2'):
print "finally, it works!!!"
else:
print "facepalm"
datArray = []
cxRows = cursor.fetchall()
for cxRow in cxRows:
datArray.append(cxRow)
con.close()
#convert the array to a pandas DataFrame
dbDF = DataFrame(datArray, columns=['fld1', 'fld2'])
#to get unique values from any pandas datframe
uniquevals = numpy.unique(dbDF['fld1'])
... View more
09-09-2014
06:23 AM
|
0
|
2
|
4448
|
|
POST
|
You can also try to output a File Geodatabase Feature Class instead of a .shp and just make an additional conversion step in your process to convert it to a final .shp --- this may take care of issues like you have run into. There's quite a few issues I've run into that worked themselves out because I moved to an FGDB.
... View more
09-05-2014
04:27 AM
|
0
|
1
|
4773
|
|
POST
|
Check: Help with Python -->Merge_management - GIS - CartoTalk
... View more
09-04-2014
11:56 AM
|
0
|
3
|
3607
|
|
POST
|
Maybe try starting at a lower directory level and see if you can get it to run thru a few of the them. That will help answer the question of limits.
... View more
09-04-2014
11:50 AM
|
1
|
0
|
3607
|
|
POST
|
I don't have a Frillion .shp files to test but it worked for 3 .shp files, so possibly the problem is too many fields getting tacked-on to the final "merged" .shp?
... View more
09-04-2014
10:58 AM
|
0
|
6
|
3607
|
|
POST
|
Edit: I copied/pasted your code, replaced with my workspace and it ran just fine for 3 .shp files in a single directory. I tried it with all 3 a duplicates of each other, then again with each one with different attributes (I simply added a different field to each one). If there is no field mapping being completed (that 3rd optional parameter) then won't it just simply add on a bunch of fields that don't match between all of these .shp files? I guess I am not clear on how you intend to combine all of these .shp files into a sinlge one. Are they all the same (just different data)? Are they all different but same feature type (polygons)? etc...
... View more
09-04-2014
10:24 AM
|
0
|
8
|
3607
|
|
POST
|
Is it necessary to use walk? This works fine for me and is much simpler:
workspace = r"myworkspace"
arcpy.env.workspace = workspace
arcpy.Merge_management(arcpy.ListFeatureClasses(), r'H:\Documents\output_merged.shp')
... View more
09-04-2014
09:49 AM
|
1
|
10
|
3607
|
|
POST
|
I suspect that you are not correctly setting up the nparray: turbinesNPArray = df.to_records() Without knowing your fields info, I don't see you fully qualifying the fields in your conversion from Pandas DataFrame to NumPy Array. You can try the following but I have no real way to test:
turbinesNPArray = numpy.array(df.to_records(), numpy.dtype([('index', '<i8'), ('TurbineID', '<f8'), ('X', '<f8'), ('Y', '<f8'), ('Z', '<f8'), ('HubH', '<f8'), ('RotorD', '<f8'), ('WGS84Lat', '<f8'), ('WGS84Long', '<f8'), ('OFFSETA', '<f8'), ('OFFSETB', '<f8')]))
... View more
09-04-2014
04:40 AM
|
0
|
0
|
3130
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-17-2020 10:47 AM | |
| 1 | 10-25-2022 11:46 AM | |
| 1 | 08-08-2022 01:40 PM | |
| 1 | 02-15-2019 08:21 AM | |
| 2 | 08-14-2023 07:14 AM |
| Online Status |
Offline
|
| Date Last Visited |
01-22-2025
02:28 PM
|