|
POST
|
Sorry for the cross-post, but the OP in the Python forum is not getting much more attention... Perhaps I am missing the obvious here, but I am in need of (Python, VB or C#) a way to populate ROW, COL field values in a polygon grid. That is, starting at cell 1 (top left) and moving right, set the cell Row, Col values: Row, Col Row, Col Row, Col [1, 1] [1, 2] [1, 3] [2, 1] [2, 2] [2, 3] [3, 1] [3, 2] [3, 3] [4, 1] [4, 2] [4, 3] This is the same functionality found in the XTools Extension, and yes it works great! However, I need to implement this same functionality in another tool that has additional automation requirements. Any help or comments are appreciated!
... View more
09-24-2012
05:30 AM
|
0
|
5
|
4076
|
|
POST
|
I have a geodatabase line FC symbolized using the "Unique value, many fields" option. For some reason one of my features is not displaying in the map/MXD? It there and coded properly, but its not displying? Both fields have domains, but as I mentioned I am sure thay are coded properly? Anyone? Thanks, RR> Bumping this to the top because of possible explanation and I am also looking for alternatives on how to approach this too. 1. Could the problem be that you have polygons that are digitized on top of each other, where a larger polygon feature is "hidding" a smaller feature under it? If you do a feature selection within the boundary of the larger polygon, does is select polygon features underneath it? 2. I am running into this issue and is the nature of the data -- in my case, polygons are added as new ones come in regardless of the qualities of the feautre (ie, it "could" completely overlap a feature under it). This means that no matter how different symbology may be, the one underneath the others will never be seen.
... View more
08-27-2012
05:12 AM
|
0
|
0
|
650
|
|
POST
|
Hi jamesfreddyc IDisplayTable dispTable = (IDisplayTable)actFeatLyr; ITable table = dispTable.DisplayTable; IRow row = table.GetRow(feature.OID); Debug.Print(row.get_Value(index).ToString()); Thanks you! Perfect! Excellent. If you mark as answered then it will benefit others who are searching on this topic 😉
... View more
08-09-2012
04:06 AM
|
0
|
0
|
834
|
|
POST
|
Hello, how get the value of joined attributtes like string valueCode = m_currentFeature.get_Value(indexField).ToString(); the index of specific joined field in FeatureClass i get with public static int FindAttributeIndexWithJoinedFields(frmKarte form, string layerName, string attributName) { IFeatureLayer actFeatLyr = (IFeatureLayer)form.axMapControl1.Map.GetLayerByName(layerName); ILayerFields fields = (ILayerFields)actFeatLyr; return fields.FindField(attributName); } Can you help me, please? Thank you! Use IDisplayTable when working with Joins.
... View more
08-09-2012
03:31 AM
|
0
|
0
|
834
|
|
POST
|
The table joins were not slowing down code, they were slowing down the performance of the layer. For example, layer redraws or opening the attribute table. At times, it was taking 2 or 3 minutes to open the attribute table when the layer was joined to a table and only seconds when not joined. Admittedly I have not travelled far down this road, but you may have to implement version edit sessions. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Editing_with_the_geodatabase_API/00010000010s000000/ "...A versioned edit session can be started on an ArcSDE geodatabase using the IMultiuserWorkspaceEdit.StartMultiuserEditing method. Versioned edit sessions allow applications to edit a version of the geodatabase as opposed to the base tables of datasets (which is the case with local geodatabase editing and non-versioned edit sessions)." Perhaps even if no other concurrent edits are being made to the version, you still may be required to setup the edit session to accomodate for such a thing?
... View more
08-08-2012
07:38 AM
|
0
|
0
|
3615
|
|
POST
|
Don't you need to pass true to pWorkspaceEdit.StartEditing() then? Your code is passing false, or am I seeing that wrong? I believe that the False parameter is for specifying undo/redo on the WorkspaceEdit.
... View more
08-08-2012
07:16 AM
|
0
|
0
|
3615
|
|
POST
|
Carlos, Have a look/read at: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/d/0001000002rs000000.htm While your approach is similar, there are some minor differences in the actual code implementation that may help (I notice they wrap the ComReleaser in a Using statement). Also, scroll down towards the bottom of that page to see if the UpdateSearchedRows method using the IRowBuffer offers any benefit or resolution to your issues. Take Care, James
... View more
08-08-2012
04:13 AM
|
0
|
0
|
3615
|
|
POST
|
Sameer, What version of ArcGIS are you running this utility on? I had seen this a while ago but did not pursue it because I was under the impression that this utility was moved to Server.WebControls namespace and is unavailable for ArcGIS desktop solutions. Does this work for ArcGIS 10.x? Hi, Above post converts the table data to .net datatable which seems to me is nice and easy way. but I believe we can avoid ICursors and looping through the IRow. There is a better way to do it, and this is how to do it use ESRI.ArcGIS.Utility.Converter.ToDataSet. Sample code: ITable table = featureWorkspace.OpenTable(tableName);
IRecordSetInit recordSetInit= new ESRI.ArcGIS.Geodatabase.RecordSetClass();
recordSetInit.SetSourceTable(table, new QueryFilterClass());
IRecordSet recordSet= recordSetInit as IRecordSet;
System.Data.DataSet netDS = ESRI.ArcGIS.Utility.Converter.ToDataSet(recordSet); I believe this will reduce the efforts and time required for looping through cursors. after getting Datatable you can easily bind it with the Datagrid. Hope this helps! Regards, Sameer
... View more
08-06-2012
04:34 AM
|
0
|
0
|
1784
|
|
POST
|
I am uncertain of any specific ArcObjects that will do what you want. What I do is simply create an ADO.NET DataTable object from the FeatureLayer then its just a matter of setting your DataGridView.DataSource to this. Here's a function that you can pass in your IFeatureLayer and it will return the DataTable. This is in VB.NET, so you will have to convert to C# 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
... View more
07-31-2012
06:30 AM
|
0
|
0
|
1784
|
|
POST
|
James, Thanks for the suggestion and sample code. I will give it a try and post back what the results were. Yeah, intermmitent problems are never fun to debug especially when you are trying to show the problem to another programmer and the problem doesn't occur while they are watching. See my edit I made above: try to implement your update with a RowBuffer instead.
... View more
07-26-2012
10:05 AM
|
0
|
0
|
1717
|
|
POST
|
Edit: I just noticed -- you are not using a RowBuffer in your update. Maybe try your update with such a thing instead? Forgot to post the ADO.NET DataTable-->ITabl update code. You could easily replace the ITable for your FeatureClasses. Hope you can gather some insight from it to help solve your issue... Private Function ConvDT_To_ITab(ByVal inDataTable As DataTable, ByVal inITableName As String) As ITable
Try
'**Open the PGDB for temp layers
Dim db_path As String = "C:\yourpathname\yourPGDBname.mdb"
Dim pWS As IWorkspace
Dim pFWS As IFeatureWorkspace
Dim pWorkspaceFactory As IWorkspaceFactory
pWorkspaceFactory = New ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactory
pFWS = pWorkspaceFactory.OpenFromFile(db_path, 0)
pWS = pFWS
' Set up a simple fields collection
Dim pFields As ESRI.ArcGIS.Geodatabase.IFields
Dim pFieldsEdit As ESRI.ArcGIS.Geodatabase.IFieldsEdit
pFields = New ESRI.ArcGIS.Geodatabase.Fields
pFieldsEdit = New ESRI.ArcGIS.Geodatabase.Fields
pFieldsEdit = pFields
Dim pField As ESRI.ArcGIS.Geodatabase.IField
Dim pFieldEdit As ESRI.ArcGIS.Geodatabase.IFieldEdit
pField = New ESRI.ArcGIS.Geodatabase.Field
pFieldEdit = pField
'' create the object id field
pField = New ESRI.ArcGIS.Geodatabase.Field
pFieldEdit = pField
pFieldEdit.Name_2 = "OBJECTID"
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID
pFieldsEdit.AddField(pField)
For i = 0 To inDataTable.Columns.Count - 1
pField = New ESRI.ArcGIS.Geodatabase.Field
pFieldEdit = pField
With pFieldEdit 'set all the properties according to the columns in the recordset
.Length_2 = inDataTable.Columns(i).MaxLength
.Name_2 = inDataTable.Columns(i).ColumnName
.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeInteger
End With
Dim ColName As String = inDataTable.Columns(i).ColumnName.ToString
Dim dtColType As String = inDataTable.Columns(i).DataType.ToString
If inDataTable.Columns(i).DataType.FullName.ToString = "System.Int32" Then
pFieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeInteger
ElseIf inDataTable.Columns(i).DataType.FullName.ToString = "System.String" Then
pFieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString
ElseIf inDataTable.Columns(i).DataType.FullName.ToString = "System.Double" Then
pFieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeDouble
ElseIf inDataTable.Columns(i).DataType.FullName.ToString = "System.Decimal" Then
pFieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeDouble
ElseIf inDataTable.Columns(i).DataType.FullName.ToString = "System.DateTime" Then
pFieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeDate
End If
pFieldsEdit.AddField(pField)
Next i
'**Check for existing FeatClass and delete if present
Dim pExistingDs As ESRI.ArcGIS.Geodatabase.IDataset
Dim pEnumDataset As IEnumDataset
pEnumDataset = pWS.Datasets(esriDatasetType.esriDTTable)
pExistingDs = pEnumDataset.Next
Do Until pExistingDs Is Nothing
If pExistingDs.Name = inITableName Then
If pExistingDs.CanDelete Then
pExistingDs.Delete()
End If
End If
pExistingDs = pEnumDataset.Next
Loop
Dim UID_FEATURE As String = "esriGeodatabase.Object"
'** create a UID for simple features
Dim pUID As ESRI.ArcGIS.esriSystem.UID
pUID = New ESRI.ArcGIS.esriSystem.UID
pUID.Value = UID_FEATURE
''** Create new FeatClass in PGDB
Dim newITable As ITable = pFWS.CreateTable(inITableName, _
pFields, _
pUID, _
Nothing, Nothing)
Dim pCur As ICursor
Dim pRowBuf As IRowBuffer
pRowBuf = newITable.CreateRowBuffer
pCur = newITable.Insert(True)
Dim dtCol As DataColumn
Dim dtColname As String
Dim row As DataRow
For i = 0 To inDataTable.Rows.Count - 1
row = inDataTable.Rows(i)
If Not IsDBNull(row.Item(0)) Then
'***add the rest of the attributes
For Each dtCol In inDataTable.Columns
dtColname = dtCol.ColumnName.ToString
Dim dtColType As String = dtCol.DataType.ToString
If Not IsDBNull(row.Item(dtColname)) Then
pRowBuf.Value(pRowBuf.Fields.FindField(dtColname)) = row.Item(dtColname)
Else
If dtCol.DataType.FullName.ToString = "System.Int32" Then
pRowBuf.Value(pRowBuf.Fields.FindField(dtColname)) = CInt(0)
ElseIf dtCol.DataType.FullName.ToString = "System.String" Then
pRowBuf.Value(pRowBuf.Fields.FindField(dtColname)) = CStr("NA")
ElseIf dtCol.DataType.FullName.ToString = "System.Double" Then
pRowBuf.Value(pRowBuf.Fields.FindField(dtColname)) = CDbl(0.0)
ElseIf dtCol.DataType.FullName.ToString = "System.Decimal" Then
pRowBuf.Value(pRowBuf.Fields.FindField(dtColname)) = CDec(0.0)
ElseIf dtCol.DataType.FullName.ToString = "System.DateTime" Then
pRowBuf.Value(pRowBuf.Fields.FindField(dtColname)) = CDate(Now())
End If
End If
Next
pCur.InsertRow(pRowBuf)
Else
End If
Next
pCur.Flush()
Return newITable
Catch ex As Exception
MsgBox(ex.ToString)
Return Nothing
End Try
End Function
... View more
07-26-2012
09:48 AM
|
0
|
0
|
1717
|
|
POST
|
James, Do you know of a better (maybe faster) way to update attributes on a layer? If you have VB or even VBA code I can easily convert it to C#. Thanks again for you help on this and in previous posts, I REALLY appreciate it! Carlos The alternative suggestion I am thinking is to skip the whole update with AO and do it directly with SQL on the database(s). I think you may have mentioned that you don't have access to or cannot get the DBA's to work with you on this? Not sure. But just high-level thought here, I'd be inclined to approach this task at the database level as a scheduled job (if Oracle offers such a thing) and skip the whole invoke of AO into it. Or as PL/SQL package/procedure that executes from whever you intend to invoke it from. I wish I could see/state the obvious problem with the code you show here -- I'd probably end up with something very similar to what you have now. Intermmitent issues are squirrely to resolve. Will follow this thread to see suggestions from others and re-look at your code in hopes to see something else. j
... View more
07-26-2012
09:42 AM
|
0
|
0
|
1717
|
|
POST
|
Carlos, I may be mistaken here out of my unfamiliarity with C#, so please ignore if this is obvious.
if (!dataReader.IsDBNull(0))
{
permitNo = dataReader.GetString(0);
permitNo = permitNo.Replace("'", "");
} So, am I incorrect to say that you are not dealing with the case when something actually IS null? Again, I am a VB guy so I am looking for an else somewhere! lol... But I would think that if there are no errors but no data is actually updated, then maybe there was no data in the dataReader itself? When doing a similar implementation (ADO.NET DataTable-->FeatureClass/ITable write), I would test by writting something in the row/field IF something was null. This would simply allow me to see that it was actually writting to it. Again -- sorry if I am misreading your C# there!
... View more
07-26-2012
07:21 AM
|
0
|
0
|
1717
|
|
POST
|
James, I got pulled away from this project and have not gotten back to it because now my boss wants to do this in Python instead of C# and I'm not the Python programmer in our group. Sorry I couldn't be of more help. Carlos Oh you will love all of that Python -- it' such a clean programming language to write (ha) 😄 No problem --- good luck!
... View more
07-25-2012
06:49 AM
|
0
|
0
|
908
|
|
POST
|
Carlos --- did you resolve this issue or make any progress?
... View more
07-25-2012
06:35 AM
|
0
|
0
|
908
|
| 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
|