This project is read-only.

Writing Polygon Z Value to Shape File - Please Help

Jul 21, 2011 at 11:32 AM


Hello everybody, this is my first post here.

I have read the sample code and can write out shape files fine except when I open them in any GIS tool (such as global mapper) they are without their Z values!

They appear as Polylines rather than polygons and when I inspect them they only have x and y values. I added polygonF.CoordinateType = CoordinateType.Z to see if this helped but it hasn't. I'm stumped.

I have attached my code below, if anyone gets a chance to look at it I really would be extremely grateful,

Thanks a lot,




        static FeatureSet polygonF = new FeatureSet(FeatureType.Polygon);
        static int polygonID = 0;

        public static void Initialize()
            //set projection
            ProjectionInfo dest = default(ProjectionInfo);
            dest = KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone41N;
            polygonF.Projection = dest;
            polygonF.CoordinateType = CoordinateType.Z;

            //initialize the featureSet attribute table
            DataColumn column = new DataColumn("PolygonID");

            if (!polygonF.DataTable.Columns.Contains("PolygonID"))

            //add the featureSet as map layer
            MapPolygonLayer polygonLayer = new MapPolygonLayer();

            PolygonSymbolizer symbol = new PolygonSymbolizer();

            polygonLayer.Symbolizer = symbol;
            polygonLayer.LegendText = "polygon";


        public static void CreatePolygon()

            List<Coordinate> polygonArray = new List<Coordinate>();

            LinearRing polygonGeometry = new LinearRing(polygonArray);

            IFeature polygonFeature = polygonF.AddFeature(polygonGeometry);

            polygonID = polygonID + 1;
            polygonFeature.DataRow["PolygonID"] = polygonID;
            Coordinate co = new Coordinate(1, 2, 1);
            polygonFeature.Coordinates.Add(co); ;
            Coordinate co2 = new Coordinate(1, 2, 2);
            Coordinate co3 = new Coordinate(2, 2, 1);

        public static void SavePolygonShapeFile()
            polygonF.SaveAs("c:\\MW\\polygon6.shp", true);