|
POST
|
Carlos, Just had another idea, but again it's not tested.... From what I understand, you are just updating attributes. If you decide to attempt to perform the updates with ADO.NET's DataAdapter, then you might be able to use a portion of a class I've put up on ArcScripts: http://resources.esri.com/arcgisdesktop/dotnet/index.cfm?fa=codeGalleryDetails&scriptID=16946 What I am thinking here is that you could pass in the IFeatureLayer, use the code above to convert it to a DataTable, make your edits to the DataTable, then setup your DataAdapter and perform the .Update with the DataTable. I'll post up some more code in the hopes it'll help you get started. j
... View more
11-16-2010
09:33 AM
|
0
|
0
|
1053
|
|
POST
|
Edit: yeah, I see where I am incorrect. Sorry about that --- I am not much into C# so I should have checked before posting. Just a shot in the dark on this one, but could it be with the extra "\" characters in your path? Or is that something specific to C#? (I don't code in that language so sorry if this is an elementary misunderstanding on my part). orig:
string shapeDir = "C:\\dev\\shapefiles";
try this:
string shapeDir = "C:\dev\shapefiles";
... View more
11-15-2010
08:48 AM
|
0
|
0
|
619
|
|
POST
|
Carlos, 1. Instead of just updating the FeatureCursor, have you tried accomplishing this with an Update on an IFeatureBuffer? This should speed up the ArcObjects side of things. Dim pFeatCur As IFeatureCursor
Dim pFeatBuf As IFeatureBuffer
pFeatBuf = pFeatureClass.CreateFeatureBuffer
pFeatCur = pFeatureClass.Insert(True)
pFeatBuf.Value(pFeatBuf.Fields.FindField("TheFieldName")) = CStr("blah")
pFeatCur.UpdateFeature(pFeatBuf) ...err something to that effect. That above is WAY untested there! 2. I agree that you if this is just updating attributes, then let a PL/SQL package handle it -- for just about all of my attribute updating, its almost always be faster if done on the server rather than the application tier. Get with your DBA to put together the SQL (sorry I can't help much as I deal mostly with SQLServer Stored Procedure development). 3. I am not sure about using an ADO.NET DataTable instead of the DataReader being faster. I think it'd actually be slower because there is more overhead in creating and filling a DataSet and DataTable compared to the DataReader. But don't mean to discourage you on that: you will need to setup an OracleDataAdapter, Fill a DataSet with the DataTable, then you can have access to it from there. You are real close to doing this, just replace the DataReader with the DataAdapter. http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracledataadapter.aspx 4. Last idea.... If this is not versioned data, and you cannot setup the PL/SQL package, then *perhaps* doing a straight-up .Update on a DataAdapter might be another option to increase speed. Letting the ADO.NET CommandBuilder generate the INSERT/UPDATE/DELETE commands might take away some performance, but you could mitigate this by coding these yourself. http://msdn.microsoft.com/en-us/library/z1z2bkx2.aspx Again, I don't have experience with Oracle db to say if this is even possible, but I don't see why it wouldn't work.
... View more
11-12-2010
04:59 AM
|
0
|
0
|
1053
|
|
POST
|
If all you are doing is comparing attribute information and not doing much spatial analysis, then ideally you should be doing the the attribute analysis in a database, using more traditional database query logic. The .dbf file is not really going to be the best choice, and as a developer you will need to make alternative decisions on how to proceed. This means maintaining attributes somewhere like SQLServer, SQLServerExpress or even Microsoft Access, with the option of managing the location info as well in these db's (either with ArcSDE or a Personal GDB) is going to be a better option. These two db's will allow you to devlop T-SQL for the data processing, or even using ADO.NET in the application tier, rather than clumsily processing the attribute data with ArcObjects.
... View more
10-18-2010
04:20 AM
|
0
|
0
|
897
|
|
POST
|
I handle these kinds of operations with ADO.NET functionality, generating different in memory DataTables for accessing and using varying data in other calculations. This would offer you the ability to not only create seperate data containers, but you could also generate/maintain related data in parent/child relationships too. If you are not versed in ADO.NET, then here is a good start right from the source: http://msdn.microsoft.com/en-us/library/system.data.datatable.aspx I have also put up a great example that has what you need to convert any IFeatureLayer into an ADO.NET DataTable object -- maybe you could utilize some of this: http://resources.esri.com/arcgisdesktop/dotnet/index.cfm?fa=codeGalleryDetails&scriptID=16946 Here is a relevent function from the example I've put up on the CodeGallery: Public Function ConvertToADONETDataTableFromLayer(ByVal inLayer As IFeatureLayer) As DataTable
Try
Dim tmpDT As New DataTable("tmpDT")
Dim column As DataColumn
Dim pTable As ITable = inLayer.FeatureClass
Dim pFields As IFields = pTable.Fields
Dim pCur As ICursor = pTable.Search(Nothing, False)
For c = 0 To pCur.Fields.FieldCount - 1
column = New DataColumn()
column.ColumnName = (pFields.Field(c).Name)
If pFields.Field(c).Type = esriFieldType.esriFieldTypeString Then
column.DataType = System.Type.GetType("System.String")
ElseIf pFields.Field(c).Type = esriFieldType.esriFieldTypeInteger Then
column.DataType = System.Type.GetType("System.Int32")
ElseIf pFields.Field(c).Type = esriFieldType.esriFieldTypeDouble Then
column.DataType = System.Type.GetType("System.Double")
ElseIf pFields.Field(c).Type = esriFieldType.esriFieldTypeDate Then
column.DataType = System.Type.GetType("System.DateTime")
ElseIf pFields.Field(c).Type = esriFieldType.esriFieldTypeSingle Then
column.DataType = System.Type.GetType("System.Single")
ElseIf pFields.Field(c).Type = esriFieldType.esriFieldTypeBlob Then
column.DataType = System.Type.GetType("System.Byte")
End If
column.ReadOnly = False
tmpDT.Columns.Add(column)
Next
Dim pRow As IRow = pCur.NextRow
Dim newRow As DataRow
Do Until pRow Is Nothing
newRow = tmpDT.NewRow()
newRow.BeginEdit()
For cols = 0 To pCur.Fields.FieldCount - 1
newRow(cols) = pRow.Value(pRow.Fields.FindField(pFields.Field(cols).Name))
Next
newRow.EndEdit()
tmpDT.Rows.Add(newRow)
tmpDT.AcceptChanges()
pRow = pCur.NextRow
Loop
Return tmpDT
Catch ex As Exception
MsgBox(ex.ToString)
Return Nothing
End Try
End Function Good Luck to ya! james Thanks jojolover for your reply, I'm dealing with road segments(segment layer) and crash data(point layer) for different year. So when I run the program with crash data for say 2008 it would generate an attribute table for the road segment for 2008, similarly when crash data for 2009 is selected the attribute table for road segment is modified. I need to capture these different attribute tables and save them under different names. I'm very new to ArcGIS and don't know much. Can you please explain to me how save the whole attribute to a collection type? Thanks once again
... View more
10-15-2010
10:35 AM
|
0
|
0
|
1009
|
|
POST
|
Hi folks, I am wondering what type of exporter should I use to export tables (as standalonetable) to get file.txt There is a lot of exporter to export into jpeg, tiff etc... and there is a possibility to select txt format in the Exportdialog. Unfortunately I do not find any solution to write a macro with VB to create a txt file of the attribute table ... Cheers and thank you L. The only example I have on hand at the moment will create a comma-delimited CSV/.txt file for an ADO.NET DataTable, but you could very well replace this with the rows in a standalone Table in ArcGIS. Anwyay, hope this helps! james untested Dim CSVFile As System.IO.StreamWriter
CSVFile = New System.IO.StreamWriter("C:\FileNameToCreate.txt")
Dim sb As New System.Text.StringBuilder
sb = New System.Text.StringBuilder
CSVFile.WriteLine("Field1, Field2, Field3, Field4, Field5")
Using CSVFile
For Each r As DataRow In theADONetDataSet.Tables(0).Rows
sb = New System.Text.StringBuilder
sb.Append((r("Field1")) & "," _
& (r("Field2")) & "," _
& (r("Field3") & "," _
& (r("Field4")) & "," _
& (r("Field5"))))
CSVFile.WriteLine(sb.ToString)
Next
End Using
... View more
09-24-2010
10:14 AM
|
0
|
0
|
570
|
|
POST
|
Not familiar with ModelBuilder, but the VB.NET function to check for null values is the IsDBNull function. Maybe something like this? (although I am not sure about getting/setting your "[ROAD_NAME]" value): Dim ROAD As String
If Not IsDBNull([ROAD_NAME]) Then
ROAD = [ROAD_NAME]
Else
ROAD = "NONE"
End If I am using ModelBuilder and have the following: Dim ROAD as String ROAD = [ROAD_NAME] if isNull(ROAD) = True then ROAD = "NONE" End If
... View more
09-21-2010
05:11 AM
|
0
|
0
|
3967
|
|
POST
|
Hi James, Thanks for the Panel tip. That worked perfectly and was very easy to implement. The method I am doing this with is the same as yours....using a UserControl. Thanks!! Glad it worked for you!
... View more
09-16-2010
07:09 AM
|
0
|
0
|
1975
|
|
POST
|
Thanks for the responses. I've implemented a solution based on jmhauck's posting. I'm noticing one strange thing though. Initially the toolbar opens up fine and everything is visible. But once I start an edit session, the combobox dissapears. It is still there, you just can't see it. If you click on where the control should be, it then appears and you can select from the drop down list, and use it normally. Why is it dissapearing when I start an edit session?? You need to add your controls to a Panel and Refresh the panel in the _Paint event. Just not real sure how you are going to accomplish this with the approach you have decided on. ...Like I said, I've had great success (ie, much easier to implement) with adding my ToolBar items (combobox, textbox, button controls) to a UserControl, and implement this UserControl in the ICommand object. j
... View more
09-16-2010
06:51 AM
|
0
|
0
|
1975
|
|
POST
|
I have had great success in building a UserControl for these kind of ToolBar components.
... View more
09-14-2010
11:14 AM
|
0
|
0
|
1975
|
|
POST
|
Use ADO.NET and setup an OLEDB Connection to the Excel spreadsheet, fill a DataTable, populate the shapefile attributes by going row-by-row thru the DataTable. Edit: here's a bit of code for setting up the ADO.NET DataTable, connecting to the spreadsheet and filling a ADO.NET DataSet. You can then begin to look at how to populate the shapefiles att's. 'Excel 2007
Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MyExcelSpreadsheet.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=Yes""")
Dim objCmdSelect As OleDbCommand = New OleDbCommand(expr, ExcelConnection)
Dim objAdapter1 As OleDbDataAdapter = New OleDbDataAdapter()
Dim objDT As DataTable
Dim ds As New DataSet()
Using objCmdSelect
objCmdSelect.Connection = ExcelConnection
objAdapter1.SelectCommand = objCmdSelect
objAdapter1.Fill(ds, "dtExcelData")
End Using
objDT = ds.Tables(0)
Dim ct As Integer
ct = objDT.Rows.Count 'make sure the DataTable was filled with rows Once you have your ADO.NET DataTable object filled, you can then set the pFeatureClass to your shapefile/layer and use the IFeatureBuffer to add the attributes. Something like this (just a snippet taken from one of my applications so this is untested): Dim pFeatCur As IFeatureCursor
Dim pFeatBuf As IFeatureBuffer
pFeatBuf = pFeatureClass.CreateFeatureBuffer
pFeatCur = pFeatureClass.Insert(True)
Dim dtCol As DataColumn
Dim dtColname As String
Dim row As DataRow
For i = 0 To objDT.Rows.Count - 1
row = objDT.Rows(i)
'***add the rest of the attributes
For Each dtCol In objDT.Columns
dtColname = dtCol.ColumnName.ToString
Dim dtColType As String = dtCol.DataType.ToString
If Not IsDBNull(row.Item(dtColname)) Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = row.Item(dtColname)
Else
If dtCol.DataType.FullName.ToString = "System.Int32" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CInt(0)
ElseIf dtCol.DataType.FullName.ToString = "System.String" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CStr("NA")
ElseIf dtCol.DataType.FullName.ToString = "System.Double" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CDbl(0.0)
ElseIf dtCol.DataType.FullName.ToString = "System.Decimal" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CDec(0.0)
ElseIf dtCol.DataType.FullName.ToString = "System.DateTime" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CDate(Now())
End If
End If
Next
pFeatCur.InsertFeature(pFeatBuf)
Else
End If
Next
pFeatCur.Flush()
... View more
09-03-2010
05:35 AM
|
0
|
0
|
1043
|
|
POST
|
Carlos, Glad to hear you figured it out. I'm unsure where exactly you'd need to put the Windows.Forms.Cursor.Current property in your app to get it to work --- I have placed these at the beginning and end of a click events in several of my apps (Windows form control) and have no problems. No, never did work at SFWD but a while ago Chickasaw Nation I think was the GIS contractor for the Everglades restoration project and they approached me to see about a temporary developer position located in that office --- nothing ever came out of it, I think because they lost the contract? Not sure. Perhaps you were there at the interview. Good luck. james James, I was not able to get it to work with your suggestions but by pure trial and error, I was able to solve it. At one point, the code that populates the listbox, uses ITrackCancel to sort the results before displaying them in the listbox and when it hits that line of code, the cursor goes back to a pointer. Reissung pMouseCursor.SetCursor(2); right afterwards resets the cursor back to the hourglass for the duration of the code. The cursor does briefly (a second or two) switches to the pointer between the two lines of code but that's fine. Yes, I am in the West Palm office off Gun Club road. Did you work at the District in the past? Your name does sound familiar to me for some reason. I've been here since 1988. Anyhow, thanks for your time and your help. As always, I appreciate it a lot!!! Carlos
... View more
08-18-2010
05:44 AM
|
0
|
0
|
981
|
|
POST
|
No problem at all. Any new major switch is going to cause disruptions, and I think this forum has a ways to go to get at the activity levels seen in previous versions --- it's just a part of making major changes like this I guess. Please post up your solution when you find it! I know what I have posted does work for many of the apps I have implemented and currently maintain (all are VB.NET framwork 3.5/ ArcGIS 9.3.1), so I'd like to hear if you found another way to accomplish this. {Also: are you in the West Palm Beach office off of Gun Club Rd? I'm originally from Lantana (Palm Beach County) and return quite often to visit family and freinds --- I've been residing in Charlotte County since 1999} Take Care, james Thanks for the reply James and my apologies for replying so late. The new forums is not notifying me of when I get a new message in spite of me setting it to send email immediately so if I forget to check for new messages myself, I don't see them and in this case, I got pulled away from this problem to take care of another one. 😞 Anyhow, I will give your suggestion a try. Carlos
... View more
08-17-2010
09:21 AM
|
0
|
0
|
981
|
|
POST
|
Carlos, Have you tried to implement the cursor from the parent Windows form? Prior to the method call, set the cursor (VB.NET): Windows.Forms.Cursor.Current = Cursors.WaitCursor After the method and the return to the form, re-set the cursor: Windows.Forms.Cursor.Current = Cursors.Arrow Hope this helps, james
... View more
08-12-2010
06:27 AM
|
0
|
0
|
981
|
|
POST
|
Thanks again for all who commented. I wanted to follow up with the solution that I came across, as after doing all of the recommended things on this thread I was still getting an error 1001 and rollback of the installation. Crystal Reports was the problem. Basically, if you are developing in Visual Studio 2008 with Crystal Report 10.5 components, then you must run a bootstrapper exe prior to running the install of the custom ArcGIS components. This bootstrapper is found here: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5 After running this on the target computer, my custom tools installed just fine.
... View more
08-06-2010
10:45 AM
|
0
|
0
|
263
|
| 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
|