josegar74

Set Spatial Reference for a a XY event source layer

Discussion created by josegar74 on May 28, 2014
Latest reply on May 28, 2014 by Neil
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_nointerface-error and http://forums.arcgis.com/threads/7607-Is-it-possible-to-change-spatialreference-by-arcobjects?highlight=change+feature+class+spatial+reference, but didn't succeed.

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

Thanks in advance.

Outcomes