|
POST
|
The "easiest" being subjective to each person, I've really enjoyed and like to utilize non-ESRI libraries for this kind of grouping. Specifically, numpy and pandas are excellent at doing these kinds of operations and would allow you to determine unique values that you could then use to make additional selections or other useful tasks. import arcpy
import numpy
from pandas import *
ws = r"H:\Documents\ArcGIS\Default.gdb"
fc = ws + "\\MyFeatureClass"
#create a NumPy array from the input feature class
nparr = arcpy.da.FeatureClassToNumPyArray(fc, '*')
#create a pandas DataFrame object from the NumPy array
df = DataFrame(nparr, columns=['ObjectId', 'Layer', 'Row', 'Col'])
#access unique values for the field
uniqueValues = numpy.unique(df['Layer'])
for uniqueValue in uniqueValues:
print uniqueValue
... View more
12-29-2014
06:01 AM
|
1
|
0
|
2142
|
|
POST
|
This Python - Command Line Arguments was a good tutorial on processing incoming arguments in a python script. This .net - execute python script from vb.net - Stack Overflow has a good example of executing the python script from .NET application including the arguments.
... View more
11-21-2014
05:17 AM
|
2
|
0
|
8318
|
|
POST
|
The difference is that you fixed the sql: sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES_RDC " + arg1 Before you had it without any space between the sql string and your arg1 value (there was no space between the RDC and the last quote): sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES_RDC" + arg1
... View more
11-20-2014
08:36 AM
|
0
|
0
|
3150
|
|
POST
|
Probably of more importance..... Get rid of the "SELECT *" !!! I am of the mind that it's just silly to have this in any production environment. I see you have the fields listed out for your cursor, it's probably even more important to have them listed in your SQL.
... View more
11-19-2014
10:48 AM
|
1
|
0
|
3150
|
|
POST
|
Total guess here, but "rows" is empty. What is the value of "arg1"? If it's numeric, you may need to convert it to string, as well as add an extra space after the SELECT statement:
sql = "SELECT * FROM INTERVENTIONS_GEO_UNITES_RDC " + str(arg1)
... View more
11-19-2014
10:39 AM
|
0
|
0
|
3150
|
|
POST
|
Do you have to rebuild the entire layer each time? Why not keep a "current" version and just update that with new incoming information? It's pretty straight forward to compare two .csv's, extract the differences and use these to update the "current' layer.
... View more
11-19-2014
05:17 AM
|
1
|
0
|
1414
|
|
POST
|
If it were me I would fix the datasource first. I could understand a comment field that I *MIGHT* allow commas into it, but probably not because it leads to situations you are in now. So fix the thing that is creating the .csv datasource so that it doesn't allow commas to be inserted. That'd be the optimal thing to do. If not an option then I'd have a separate process that ran to removes commas and convert them into tabs instead. You will still have to do a bunch of gymnastics to find the specific scenario(s) that you want to use to do the replace. ...which is why it's best to juts fix the source data.
I have a python script tool that exports records from a feature layer using an (area of interest - aoi). The tool works well, but the problem is that if I have a comma in text in one of the field records
This is where I'd focus my first effort. When it's a Feature Class (before you run your tool), remove any commas in any of the fields. But again, why are you letting them into the data in the first place? Control that process and you don't need to deal with this problem.
... View more
11-12-2014
05:38 AM
|
0
|
0
|
4207
|
|
POST
|
but I want all of the fields and we will add to these fields as we grow this product
Then add them, don't be lazy. "SELECT *" is fine for quick look at things, but not a great idea for production code.
what is the |S25' for and what is the <f8 for?
ArcGIS Help 10.1
... View more
10-27-2014
11:44 AM
|
0
|
0
|
3592
|
|
POST
|
Also, please don't use "SELECT * FROM Table/View..." --- not only is it bad SQL, it's going to make your life really difficult when setting up your arrays and/or conversion into GIS-objects. Be sure to specify the fields you want... ALWAYS.
... View more
10-27-2014
11:33 AM
|
0
|
3
|
3592
|
|
POST
|
Something like this (untested and just typed out from memory and other snippets):
datArray = []
for row in cursor:
datArray.append(row)
cursor.close()
del cursor
if len(datArray)>0:
npyarr = np.array(datArray, np.dtype([('storename', '|S25'), ('xCoord', '<f8'), ('yCoord', '<f8')]))
outFC = ws_mem + "\\MyFeatureClass"
if arcpy.Exists(outFC):
arcpy.Delete_management(outFC)
print "deleted " + str(outFC)
arcpy.da.NumPyArrayToFeatureClass(npyarr, outFC, ("xCoord", "yCoord"))
print "created..." + outFC
... View more
10-27-2014
11:29 AM
|
0
|
0
|
3592
|
|
POST
|
AR.GISWEB.VW_MCYWEB is not a table (as in how you perceive your "in_Table" variable). You have to issue SQL against this to fill a cursor object and then use the cursor to build your table. GettingStarted - pyodbc - Quick Examples To Get You Started - Python ODBC library - Google Project Hosting We do something similar, but we access Oracle using cx_Oracle library. basically once you get your cursor you can just append rows to a new list and/or numpy array which is easy to convert to a feature class with arcpy.da.NumPyArrayToFeatureClass() or arcpy.da.NumPyArrayToTable()
... View more
10-27-2014
08:13 AM
|
0
|
6
|
3592
|
|
POST
|
Alternative method (I don't know it this is faster):
sql = "ObjectId=1"
_dfsource = r'H:\Documents\ArcGIS\Default.gdb\L8_Parcel'
_numparr = arcpy.da.FeatureClassToNumPyArray(_dfsource, ["ObjectId"], sql)
rowcount = len(_numparr)
print rowcount
... View more
10-23-2014
09:05 AM
|
2
|
0
|
4687
|
|
POST
|
arcgis desktop - Fastest way to count the number of features in a feature class? - Geographic Information Systems Stack …
... View more
10-23-2014
08:53 AM
|
2
|
1
|
4687
|
|
POST
|
Untested: Likely what will work:
arcpy.CalculateField_management(FeldHinzugefuegt, "Pfad", r"U:\rips\images\tk50\tk\\" + ([BLATT_NR].lower()) + "co\\" + "*.*", "PYTHON_9.3", "")
Or from your original code: arcpy.CalculateField_management(FeldHinzugefuegt, "Pfad", "\"U:\\rips\\images\\tk50\\tk\" + ([BLATT_NR].lower()) + \"co\" + \"*.*\"", "PYTHON_9.3", "")
... View more
10-22-2014
06:53 AM
|
0
|
0
|
2301
|
| 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
|