Though i am using QGIS, yet I am not confined by tool (can use an entirely different tool or a plugin for QGIS) usage.. Only aim is to get the following:

I am reading various shapefiles in QGIS and I wish to have different colors in the same shapefile (or layer) for -

  1. Each polyline
  2. Every n number of polylines
  3. A chunk of n points in a single large polyline.
  • Can you provide a sample image of what you're trying to achieve? Color can be symbolized on an attribute, so if you want a different color for every line you'd just symbolize on the unique id for the lines. You can add a layer multiple times and symbolize it differently each time, but I don't know how you would show line x as red and then group g which contains x as green. Unless you show the individual lines at a weight of 1 on top of the groups at a weight of 3, so the thicker color 'outlines' the thinner one. Sounds like a very confusing visual though. – Chris W Dec 1 '14 at 20:47
  • @ChrisW - Let's say the shapefile has 100 polylines. I wish to display the each line in a different color. Not that i want unique 100 colors, but just like use 3-4 different colors to show different polylines. – displayName Dec 1 '14 at 21:20
  • 1
    Unless there's some attribute that would define which lines are which, it's either all unique or all the same. You can pick an attribute that some lines might have common values for and symbolize on that using a color ramp, but there won't be any way to control whether two adjacent lines use the same color (unless that's a property of the attribute). – Chris W Dec 1 '14 at 21:56
  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Aug 1 '15 at 8:02
  • @underdark: The question is too old. I'm over that project and have kinda forgotten what I was trying to do there. Still, your answer seems correct. I am not a GIS specialist, thus I just put my question here in hope that it might be a no-brainer for someone in this field. Sorry, therefore, for the lack of research. – displayName Aug 1 '15 at 13:51

If you want to use 4 colors for all your features, you can use the following approach with a categorized style:

enter image description here

Please add a sketch for your third point ("A chunk of n points in a single large polyline."). I can't imagine what that should look like.


You could pick any attribute and symbolize it using a Graduated symbol with a four color ramp, or however many colors you want. If you want more control over which colors get used, I would recommend adding a mapcolor integer field with as many values as colors you want to use. For example, the Natural Earth country data includes mapcolor7, mapcolor8, mapcolor9, and mapcolor13 fields that you can use depending on whether you want to use 7, 8, 9, or 13 unique colors.

But if this is a one-off, you might just do what I first suggested and use a four color ramp for any already existing field. As long as that field does not have a spatial pattern to it, the colors should appear random. The pattern won't be random if, for example, the polylines represent something like street numbers that are numbered sequentially. In that case, all the street numbers that are near each other would be assigned the same color.

  • I am not very well versed in QGIS. I just want to know if there is any boxes to check or chunk size to be given so as to give each polyline in the shapefile - a new color. – displayName Dec 2 '14 at 15:30

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.