This project is read-only.


Feb 2, 2011 at 10:53 PM

I'm trying to add a Bitmap to a point within an ImageLayer using the following code:

if (_myPoints == null) _myPoints = new FeatureSet(FeatureType.Point);
            _myPoints.Projection = KnownCoordinateSystems.Geographic.World.WGS1984;  

            // Assume background layers have been added, and get the current map extents.

            double xmin = map1.ViewExtents.MinX;
            double xmax = map1.ViewExtents.MaxX;
            double ymin = map1.ViewExtents.MinY;
            double ymax = map1.ViewExtents.MaxY;
            // create a known static point on the map
                double x = 127;
                double y = 36;
                Coordinate c = new Coordinate(x, y);

                Point point = new Point();
                point.X = 127;
                point.Y = 36;
                Coordinate coord = map1.PixelToProj(point);


                IMapImageLayer imageLayer = map1.Layers.Add(_myPoints) as IMapImageLayer;
                imageLayer.Symbolizer = new ImageSymbolizer();
                Image image = System.Drawing.Bitmap.FromFile("c:\\Pictures\\Unknown.bmp", true);

                imageLayer.Image.SetBitmap((Bitmap) image);


I'm getting an unknown exception at ImageLayer.Image.SetBitmap....

I saw a PictureSymbol method in DotSpatial.Symbology but I'm not sure how it fits into the equation.

Any tips are greatly appreciated.



Feb 7, 2011 at 5:07 PM

Does anyone have an example using the PictureSymbol object?



Jun 27, 2011 at 9:52 AM
Edited Jun 27, 2011 at 9:54 AM

Hi, aleberkn! Please try to use symolizer instead of setting image for the map layer. You can find examples from DotSpatial_Tutorial_2.docx "Working with DotSpatial Symbology and Attribute table", which located in: Tutorials&referringTitle=Documentation 

Jun 27, 2011 at 10:28 AM


I think Aleberkn wants to add an image to a singlepoint and not to all points in a layer. As far as I know the Symbolizer will show the same image for all points in the specific layer. I would like to be corrected on this matters as I have been weeks trying to find a way how to add an image per point rather than having to create a layer for each point since I need a different images for each point.

Well actually I need the same symbol but ritated at a different angle for each point. Is it possible to define a different rotation angle for each point for the symbol defined in the layer symbolizer. That is the real problem I am facing. (e.g. having an arrow as the symbol and the arrows at each point will be showing wind direction at that point) 

Any ideas welcome.



Jun 29, 2011 at 4:42 AM
Edited Jun 29, 2011 at 8:01 AM

Hi, arrow01,

I think it could be use the "Unique Value" rendering method to solve the problem you met, if you want to assign each point a differnt picture symbol. For example, if you want to describe the wind speed and direction of each point, you can use "Charactor symbol" (charsymbolizer) instead of picture symbols, where many kind of vector symbols could be used, including the arrow. Suppose you use a arrow symbol, the symbol size and angle could represent wind speed and direction of a point, respectively. Then you could creat a pointscheme, then creat a new pointsymbolizer, and set the symbol of each point as the "arrow" symbol with its length and angle, and add it the the pointscheme. I think it could be done in this way, and I wish it could help you.  

Jun 14, 2012 at 8:41 AM

using the follow method ,can server your need

private void SetPictrue(FeatureLayer fl,FeatureSet fs,IFeature ff)   //fl the layer you want to add an image to ,fs is from fl, ff is from the location of the image 

            PointScheme pointScheme = new PointScheme();
            foreach (IFeature f in fs.Features)
                if (f.Coordinates[0] == ff.Coordinates[0])
                    PictureSymbol pis = new PictureSymbol(deviceImageInfo.DeviceImage, 28);  //deviceImageInfo.DeviceImage is an image from an imagefile
                    pis.ImageFilename = deviceImageInfo.ImageFileName;    //the image filename
                    PointCategory pc = new PointCategory(pis);
                    pc.FilterExpression = "[ID]='" + ff.DataRow["ID"].ToString() + "'";
                IFeatureCategory fc = fl.GetCategory(f);
                if (fc==null)
                fc.FilterExpression = "[ID]='" + f.DataRow["ID"].ToString() + "'";
            fl.Symbology = pointScheme;