|
POST
|
Use the UniqueValueRendering to accomplish this. These are the basic steps to it: 1. Get a SelectionSet/FeatureCursor on the Layer you want to symbolize. (this means you'd want to set the IQueryFilter's where clause twice, once for each date. 2. Setup a SimpleMarkerSymbol. In your case, esriSMSCircle will work. 3. Create/Setup a New UniqueValueRenderer 4. Cycle thru each of the IFeatures in the FeatureCursor, setting the Renderer. Here is an example Sub that is out of one of my applications that renders a point feature layer based upon it's "flag" field. This could really be any field in the layer, so just replace it with your own requirements. Good luck!
Private Sub UniqueValuePointRenderer(ByVal pFL As IFeatureLayer, ByVal inFlag1 As String, ByVal inFlag2 As String)
Try
Dim pFClass As IFeatureClass = pFL.FeatureClass
Dim pfeature As IFeature
Dim pQF As IQueryFilter = New QueryFilter
'' Set the where clause
Dim tStr, pStr As String
tStr = "FlagType = '" & inFlag1 & "'"
pStr = "FlagType = '" & inFlag2 & "'"
pQF.WhereClause = tStr
Dim pFeatureSelection As IFeatureSelection
pFeatureSelection = pFL
pFeatureSelection.SelectFeatures(pQF, esriSelectionResultEnum.esriSelectionResultNew, False)
pFeatureSelection.SelectionChanged()
Dim pSelectionSet As ISelectionSet
pSelectionSet = pFeatureSelection.SelectionSet
Dim pFeatureCursor As IFeatureCursor
pFeatureCursor = Nothing
pSelectionSet.Search(Nothing, True, pFeatureCursor)
Dim symd As SimpleMarkerSymbol
symd = New SimpleMarkerSymbol
symd.Style = esriSimpleMarkerStyle.esriSMSCircle
symd.Size = 4
'Create unique value renderer
Dim pUVRenderer As IUniqueValueRenderer
pUVRenderer = New UniqueValueRenderer
pUVRenderer.FieldCount = 1
pUVRenderer.Field(0) = "FlagType"
pUVRenderer.DefaultSymbol = symd
Dim pSym As ISimpleMarkerSymbol
Dim col1, col2 As IRgbColor
col1 = New RgbColor
col1.Red = 145
col1.Green = 145
col1.Blue = 145
col2 = New RgbColor
col2.Red = 200
col2.Green = 200
col2.Blue = 200
pfeature = pFeatureCursor.NextFeature
Do Until pfeature Is Nothing
pSym = New SimpleMarkerSymbol
pSym.Style = esriSimpleMarkerStyle.esriSMSCircle
pSym.Size = 4
pSym.Outline = True
pSym.Color = col1
pUVRenderer.AddValue(pfeature.Value(pFClass.FindField("FlagType")), "", pSym)
pfeature = pFeatureCursor.NextFeature
Loop
'reset the where clause of the queryfilter
pQF.WhereClause = pStr
pFeatureSelection.SelectFeatures(pQF, esriSelectionResultEnum.esriSelectionResultNew, False)
pFeatureSelection.SelectionChanged()
pSelectionSet = pFeatureSelection.SelectionSet
pfeature = Nothing
pFeatureCursor = Nothing
pSelectionSet.Search(Nothing, True, pFeatureCursor)
pfeature = pFeatureCursor.NextFeature
Do Until pfeature Is Nothing
pSym = New SimpleMarkerSymbol
pSym.Style = esriSimpleMarkerStyle.esriSMSCircle
pSym.Size = 8
pSym.Outline = True
pSym.Color = col2
pUVRenderer.AddValue(pfeature.Value(pFClass.FindField("FlagType")), "", pSym)
pfeature = pFeatureCursor.NextFeature
Loop
Dim pGFLayer As IGeoFeatureLayer
pGFLayer = pFL
pGFLayer.Renderer = pUVRenderer
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
... View more
04-27-2011
03:53 AM
|
0
|
0
|
1200
|
|
POST
|
I am not totally certain exactly what you need to accomplish, but if you are having difficulty with acquiring a layer in the TOC (that has been altered/changed/shortened) because the name you are passing is difficult to match up to fully qualified names from ArcSDE, then you could utilize the IDataset:Name property. I use the following function when I need to access a specific layer in the TOC by passing it's fully qualified SDE name: Private Function ReturnFLayer(ByVal inName As String) As IFeatureClass
Try
Dim pDoc As ESRI.ArcGIS.ArcMapUI.IMxDocument
Dim pMap As ESRI.ArcGIS.Carto.IMap
Dim pLayer As ESRI.ArcGIS.Carto.IFeatureLayer
Dim dataset As IDataset
Dim i As Short
'Layer name to find
Dim sLayerName As String = inName
Dim Name As String
pDoc = m_application.Document
pMap = pDoc.FocusMap
For i = 0 To pMap.LayerCount - 1
pLayer = pMap.Layer(i)
dataset = pLayer.FeatureClass
Name = dataset.Name
If Name = sLayerName Then
pLayer = pMap.Layer(i)
Exit For
End If
Next
Return pLayer.FeatureClass
Catch ex As Exception
MsgBox(ex.ToString)
Return Nothing
End Try
End Function
... View more
04-25-2011
06:04 AM
|
0
|
0
|
716
|
|
POST
|
Just to follow up, here is an example of how you can accomplish what you want to do. Again, there might very well be a simple ArcObjects solution here --- howver most of my GIS apps are really data-centric and I do a lot of work implementing ADO.NET stuff into my GIS applications. So that is the way I am going to create any .xml conversion process. First, you should go to the ArcScripts and save a copy of one of my uploads I did there. This is a slick little toolset that converts your IFeatureLayer to an ADO.NET DataTable and can be used for a wide variety of scenarios. I particularly like to use this functionality to display data in DataGridViews and the like. http://resources.arcgis.com/gallery/file/arcobjects-net-api/details?entryID=675318D8-1422-2418-8814-772B0A56383D But, I've pasted the relevent Function below that you'll need out of that script. Private Function ConvertToADONETDataTableFromLayer(ByVal inLayer As IFeatureLayer) As DataTable
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
End Function Then use this to build the .xml file:
Dim pDoc As IMxDocument
Dim pMap As IMap
pDoc = m_pApp.Document
pMap = pDoc.FocusMap
Dim pLayer as IFeatureLayer = pMap.Layer(0) 'just get the first layer for simplicity/example
'Create the ADO.NET DataTable
Dim adoDataTable As DataTable = ConvertToADONETDataTableFromLayer(pLayer)
'Setup the ADO.NET Dataset and add the newly created DataTable
Dim ds As New DataSet()
ds.DataSetName = "dsToConvertToXML"
ds.Tables.Add(adoDataTable)
'Now write the DataTable's schema to an .xml file
'remember, this is *really* the schema of the IFeatureLayer because we converted it to an
'ADO.NET DataTable!
Dim filename As String = ds.DataSetName.ToString & ".xml"
ds.WriteXmlSchema(filename) So from the test that I ran, this adds the .xml file to the directory where your VS.NET project folder is located. There are probably ways to manipulate exactly where to place this .xml file, but you'll have to look into that. Good luck and let me know if this helps! Here's the sample schema that I build from a point layer I had run this on: [HTML]<?xml version="1.0" standalone="yes"?> <xs:schema id="dsToConvertToXML" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="dsToConvertToXML" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="tmpDT"> <xs:complexType> <xs:sequence> <xs:element name="Shape" type="xs:string" minOccurs="0" /> <xs:element name="OBJECTID" type="xs:string" minOccurs="0" /> <xs:element name="zone" type="xs:string" minOccurs="0" /> <xs:element name="Location" type="xs:int" minOccurs="0" /> <xs:element name="timestart" type="xs:dateTime" minOccurs="0" /> <xs:element name="FlagType" type="xs:string" minOccurs="0" /> <xs:element name="Latitude" type="xs:double" minOccurs="0" /> <xs:element name="Longitude" type="xs:double" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema>[/HTML]
... View more
04-22-2011
09:48 AM
|
0
|
0
|
1086
|
|
POST
|
If you are not into the the whole ADO.NET stuff, then you might be able to use something from this sample: http://edndoc.esri.com/arcobjects/9.0/default.asp?URL=/arcobjects/9.0/Samples/Geodatabase/Creating_and_Converting_Data/Serialize_a_Recordset_and_Save_As_XML.htm I have not attempted to implement this particular sample.
... View more
04-20-2011
08:13 AM
|
0
|
0
|
1086
|
|
POST
|
Hi ESRI-Forum, I'm looking for a code-sample for exporting the attribute table of a layer to a XML-File. Would be nice, if somebody can send me a hint! Kai I am unsure of any ArcObjects that could do this for you. Perhaps there is and someone will reply, but otherwise I'd suggest writing the attributes to an ADO.NET DataTable that is added to an ADO.NET DataSet. From there you could simply write out the schema of the DataSet to an .xml file with: Dim ds As New DataSet()
ds.DataSetName = "dsName"
Dim filename As String = ds.DataSetName.ToString & ".xml"
ds.WriteXmlSchema(filename)
... View more
04-20-2011
08:00 AM
|
0
|
0
|
1086
|
|
POST
|
Looks to me like it needs to be something more like: pEnv.PutCoords(9.0, 0.75, 10.35, 2.2) The parameters position the corners referencing zero as the lower left page corner: LowerLeftX, LowerLeftY, UpperRightX, UpperRightY So the size of the envelope is determined by the difference between the values. -Jeff H That looks pretty good to me, Jeff. Thanks for the help! james
... View more
04-18-2011
12:16 PM
|
0
|
0
|
987
|
|
POST
|
so the legend never moves no matter what the putcoords are? my code for a creating/placing a legend (using putcoords to place it) is pretty long but i can post it up if it will help. I think that is correct. For example, if I replace the PutCoords line with this one, it simply resizes the legend (making it larger) and appears to keep the same position:
pEnv.PutCoords(1, 1, 4, 4)
Here is the full Sub that I am using to add the Legend: Public Sub AddMapSurrounds()
Dim pMxDoc As IMxDocument
Dim pActiveView As IActiveView
Dim pEnv As IEnvelope
Dim pId As New UID
Dim pMapSurround As IMapSurround
pMxDoc = m_pApp.Document
pActiveView = pMxDoc.PageLayout
pEnv = New Envelope
pEnv.PutCoords(0.4, 1.3, 1.75, 2.75)
pId.Value = "esricore.Legend"
pMapSurround = CreateSurround(pId, pEnv, "Index Reporting", pMxDoc.FocusMap, pMxDoc.PageLayout)
pMapSurround.Refresh()
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, Nothing)
End Sub
... View more
04-18-2011
11:23 AM
|
0
|
0
|
987
|
|
POST
|
ArcMap 9.3.1 I have written some automation processing for Layout creation and cannot seem to get the legend that is added programmatically to a specific position in the Layout View. As seen in the attached image, it is added and is the correct size, but I need to place it as specified. Here's the currnt "putcoord" parameters for the lengend:
pEnv.PutCoords(0.4, 1.3, 1.75, 2.75) Also, the page size is 8.5x11 but in Landscape orientation. If you need to see the rest of the code that I am using to process this stuff, I can add more detailed snips. Thanks in advance! james
... View more
04-18-2011
10:18 AM
|
0
|
4
|
1214
|
|
POST
|
First, I am more comfortable with VB.NET, so if I mention something that is irrelevent because it is something else in C# then forgive me. But there are a couple of things that sort of jump out at me and might be worth looking into. 1. I don't see you including any SimpleMarkerSymbol or other symbol as a parameter in the .AddValue method of your renderer. The parameters I've always set for a uniqueval renderer are as such:
pUVRenderer.AddValue(pfeature.Value(pFClass.FindField("FlagType")), "", pSym)
Where pSym is an ISimpleMarkerSymbol (or some other type) with its color, style, size, etc.. set up already. 2. This doesn't see right or in the wrong location (however, this may simply be a C# thing that I am not understanding): pUVR = ((IGeoFeatureLayer)player).Renderer as IUniqueValueRenderer; Shouldn't the IGeoFeatureLayer.Rendere property be set at the very last step? That is, arent' you supposed to loop thru the FeatureCursor and set all of the pUVRenderer.AddValue properties first, then finally set the GeoFeatureLayer's .Renderer? 3. After an UpdateContents, try a partialRefresh on the ActiveView:
pDoc.UpdateContents()
pDoc.ActiveView.Refresh()
pDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, Nothing, Nothing)
... View more
04-13-2011
03:49 AM
|
0
|
0
|
967
|
|
POST
|
Thank you very very much James, I've been stressing and pulling my hair out for weeks trying to figure this out and all along it was the simplest of problems. I can't thank you enough for your speedy and fantastic reply everything works perfectly now! Great! Glad it helped out! james
... View more
04-12-2011
10:33 AM
|
0
|
0
|
680
|
|
POST
|
Are you sure "Sect" in your WHERE clause is of type numeric? iq.WhereClause = "[Branch]='" & Bran & "' AND [Section_]=" & Sect If it is a string type then you'd need to add single quotes around it like you have done wiht "[Branc]". Something like: iq.WhereClause = "[Branch]='" & Bran & "' AND [Section_]='" & Sect &'"
... View more
04-12-2011
04:54 AM
|
0
|
0
|
680
|
|
POST
|
I've had a great deal of success with the ADO.NET data classes -- specifically, the DataSet and DataTable objects. I have several implementations that have highly detailed/customized Crystal Reporting components for reporting and the ADO.NET data model is very compatible with CR and a whole host of other technologies. While this may/may not be an exact solution to your needs, you might find a use for the ADO.NET DataTable in your own implementation(s). Here's a great example of converting a FeatureLayer's attributes into an ADO.NET DataTable. I've uploaded this onto ArcScripts for everyone to use: http://resources.arcgis.com/gallery/file/arcobjects-net-api/details?entryID=675318D8-1422-2418-8814-772B0A56383D My other upload that some might find useful: http://resources.arcgis.com/gallery/file/arcobjects-net-api/details?entryID=6753AB56-1422-2418-7F3C-C2C87DD27F3E
... View more
03-15-2011
07:36 AM
|
0
|
0
|
1711
|
|
POST
|
If you're talking about starting ArcMap (or Catalog, etc) then Express 2008 works just fine. Debugs, step into, step through..it's all there. The only real problem I have is building a deployment package. Professional or standard is required for that (I think). Thanks for the reply. Yes, I was concerned regarding Express because there is an exerpt in the ESRI docs that suggested you could not launch external programs (ArcMap.exe) to debug the code (VB.NET). Either way, we def need to build deployment packages, so if anyone has a bit more info about Professional Vs. Standard versons that'd be great. james
... View more
03-01-2011
09:05 AM
|
0
|
0
|
627
|
|
POST
|
I've read Visual Studio Express cannot start external applications for debugging, which this is not acceptable. Trying to decide on the most economical recommendation for a customer. So which version of VS is most economical yet will provide adequate development tools? Standard? Professional? Work will be done to develop .dll's for ArcGIS v10 (ArcMap toolbars), ADO.NET, SQLServer connections.
... View more
03-01-2011
07:07 AM
|
0
|
3
|
1218
|
|
POST
|
I think you want to implement ISpatialFilter and set the .SpatialRel to esriSpatialRelIntersects http://resources.esri.com/help/9.3/arcgisserver/apis/arcobjects/esrigeodatabase/ispatialfilter.htm
... View more
02-28-2011
08:01 AM
|
0
|
0
|
772
|
| 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
|