Draw a Multi-color Polyline

Jan 9, 2013 at 7:22 AM

I have the necessity to draw all the pipelines of a specific area. The issue is that I need to plot each pipeline with a scale of colors based on the temperature measured in each point. Is there a way to draw a polyline in which each segment has its own color?

Jan 10, 2013 at 5:40 PM

With different Symbolizer.

Check this out link page http://dotspatial.codeplex.com/discussions/429118. it will the same that for Polylines.

Jan 14, 2013 at 8:05 AM

Thank you a lot for the answer. 

Due to my lack of experience with dotspatial I spent a lot of time trying to figure out how I can join all the PointSymbolizer (or LineSymbolizer) added to PointScheme (or LineScheme) with the Points (or Lines) of a FeatureSet added as layer to a map. Is it possible to have a link to an example that explains how to do it?

Thanks a lot.

Jan 14, 2013 at 3:08 PM

It is equal to what is done with the points...

Dim waterLinkLayer As IMapLayer = 'Load MapLayer
If waterLinkLayer IsNot Nothing Then
  Dim linkLayer As IMapLineLayer
  Dim linkScheme As New LineScheme()
  Dim pipe As New LineSymbolizer(Color.Blue,2)
  Dim myPipe As New LineCategory(pipe)
  myPipe.FilterExpression="[TYPE] = 'PIPE'"
  Dim valve As New LineSymbolizer(Color.Red,5)
  Dim myValve As New LineCategory(valve)
  myValve.FilterExpression="[TYPE] = 'VALVE'"
End If

Jan 14, 2013 at 4:04 PM

I will try do explain better my issue with an example:

        private void AddGasPipeline()
            Random rnd = new Random();
            Feature f = new Feature();
            FeatureSet fs = new FeatureSet(FeatureType.Line);
            double x;
            double y;

            double xmin = uxMap.Extent.MinX;
            double xmax = uxMap.Extent.MaxX;
            double ymin = uxMap.Extent.MinY;
            double ymax = uxMap.Extent.MaxY;

            Coordinate[] coord = new Coordinate[36];
            for (int i = 0; i < 36; i++)
                x = xmin + rnd.NextDouble() * (xmax - xmin);
                y = ymin + rnd.NextDouble() * (ymax - ymin);

                coord[i] = new Coordinate(x, y);

            LineString ls = new LineString(coord);

            f = new Feature(ls);

            ILineLayer myGasPipeline = uxMap.Layers.Add(fs) as ILineLayer;

Now I would like to have some segment of myGasPipeline of type "[PIPE]" and other of type "[Valve]" what is the correct way to do it?

Thanks in advance.

Jan 14, 2013 at 4:17 PM

I do not quite understand..

Do you want to change any field of the database, when you add a shape to shapefile?

Jan 14, 2013 at 4:22 PM
Edited Jan 14, 2013 at 4:25 PM

if what you want would be something like..

f = New Feature(ls)


But  "TYPE" column must exist in the database of the shapefile...

Jan 15, 2013 at 7:48 AM

Thank you a lot, that is exactly what I was looking for. Now it works.

Thanks again