What I would like to check is if the raster layer and feature layer have the same projection.

Code developed so far:

public void SpatialReferencEquality()
 var rasterLayer = ((ILayer)comboBox1.SelectedItem).ConvertToRasterLayer();
 var featureLayer = ((ILayer) comboBox2.SelectedItem).ConvertToFeatureLayer();
 var spRef1 = rasterLayer.SpatialReference;
 var spRef2 = featureLayer.SpatialReference;
 if(!IsSpatialReferenceSame(spRef1 , spRef2 )
   MessegeBox.Show(" ");
public static bool IsSpatialReferenceSame(ISpatialReference sp1, ISpatialReference sp2)
        return sp1.Equals(sp2);

 public bool Equals(ISpatialReference sp2)
            var sp1Clone = this.Clone;
            var sp2Clone = sp2.Clone;
            return sp1Clone.IsEqual(sp2Clone);

But IsSpatialReferenceSame returns False, why?

In my case horizontal parameters are same of projection system of the layers. But there is a mismatch of vertical parameters. For this reason return false.

  • It is solved. Horizontal projection parameters are same but vertical projection parameters are not same. – osman May 13 '17 at 6:35
  • write the answer in the answer box and then approve it so this does shows as ab answered question. – If you do not know- just GIS Feb 25 at 14:19

You should try comparing the ISpatialReferenceInfo.Name property. This would essentially be a string comparison and would be much more straight forward.


You could try and use the Interface ICompareCoordinateSystems?

I'm wondering if it is failing the test because one is named BTM and the other is Transverse_Mercator_complex?

  • Projection are same Transverse_Mercator_complex. Feature layer and raster layer. – osman Nov 30 '16 at 4:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.