Strange behaviour when reprojection shapefile

May 24, 2012 at 4:15 AM

Have a process which creates a new layer from the intersection of two layers using

IFeatureSet output = layer2.Intersection(layer, FieldJoinType.All, mapControl.MapWindow.ProgressHandler);
                    output.ProjectionString = layer.ProjectionString;
                    output.Name = "Union";

Then  want to calculate the area of each polygon, taking into projection using the follow code


public static string Area(IFeatureSet input, float multiplier = 0.000001F)
            // We add the area field
            string fieldname = AddField(input, "Area");
            FeatureSet featureSetReproject = new FeatureSet();
            featureSetReproject.Projection = input.Projection;
            // we add all the old features to output
            foreach (IFeature feature in featureSetReproject.Features)
                IMultiPolygon polygon = MultiPolygon.FromBasicGeometry(feature.BasicGeometry);
                feature.DataRow[fieldname] = polygon.Area * multiplier;
                DataRow[] rows = input.DataTable.Select("FID = " + feature.DataRow["FID"]);
                if(rows.Length >0)
                    rows[0][fieldname] = feature.DataRow[fieldname];
            return fieldname;

Then add the layer to the map control

                    output.Filename = @"\\ceres\Projects\testFiles_paddockGRASP\union.shp";
                    mapControl.MapWindow.Layers.Add(output).SelectionEnabled = true;

What I end up with is the resultant layer has been reprojected, why....

May 24, 2012 at 4:56 PM

Do you mean it is reprojected to 

May 25, 2012 at 12:01 AM

I think this is right, I would have gone for a Australian Lambert Equal Area projection.

But the question still remains why the input featureset has also been transformed, when I tried to copy the featureset first, then transform the data. Thinking that this will leave the input featureset untouched?