Set Spatial Reference for a a XY event source layer

521
1
05-28-2014 12:14 AM
JoseGarcia
New Contributor
I have an XY event source layer, added to ArcMap with the option File > Add Data > Add XY Data, but when trying to change the spatial reference of this layer with ArcObjects I get a E_NOINTERFACE error.

The code snippet that manages the change of the spatial reference is like:

Dim spatialRef As ISpatialReference = ...
Dim geoDataset As IGeoDataset = fl.FeatureClass

Dim geoDatasetSchemaEdit As IGeoDatasetSchemaEdit = geoDataset
If (geoDatasetSchemaEdit.CanAlterSpatialReference) Then
 geoDatasetSchemaEdit.AlterSpatialReference(spatialRef)
End If


Previous code works fine for other type of layers. Also from the ArcMap UI is possible to change the spatial reference of an XY event source layer, so I guess should be possible with ArcObjects.

I found these related posts: http://forums.arcgis.com/threads/74625-casting-igeodataset-to-igeodatasetschemaedit-gives-e_nointerf... and http://forums.arcgis.com/threads/7607-Is-it-possible-to-change-spatialreference-by-arcobjects?highli..., but didn't succeed.

Any idea how can be change the spatial reference of XY event source layers with ArcObjects?

Thanks in advance.
0 Kudos
1 Reply
NeilClemmons
Regular Contributor III
I would imagine that you will have to set it on the layer itself using IFeatureLayer.SpatialReference.
0 Kudos