Question

How to set colour value automatically for polygons in a ESRI Shapefile?


Language_region_maps_of_India_incorrectLanguage_region_maps_of_India_correct.svgHi everybody,

 

I have 6 values which are standing for colour values for making maps. So each number is standing for a colour. The values are always the same and the numbers are 59, 63, 70, 72, 76 and 77.

 

I have a lot of polygone ESRI shapefiles which are showing the administration of each country (OSM Data for example the states of India, which is the first administration level of India). To have the same style in each map for printing, I would like to use the colour values (59, 63, etc.) for every administration of each country. So each shapefile has a attribute field which is called "colour value".

 

Now the tricky part is: the polygons (so the states of India) should have always one of the values, but the direct neighbour state should have always another value. Otherwise the colour of the states are the same of maybe two of them, which are neighbour states, and you can't see directly the difference on the map after colouring.

I put some picture in the attachment, where you can see the correct version how it should be and the incorrect version.

 

Has anybody a clue how to resolve that problem automatically? Right now I have to go in each attribute field line and fill out by hand, because I have to watch which is the next neighbour to don't use the same colour value.

 

Thanks in advance.

 

Cheers,

Fabian


6 replies

Userlevel 1
Badge +21

I think you can use a FeatureColorSetter to do this. If you choose Map Coloring (N Color) Fast, you can then choose 6 colours. This should ensure that neighbouring polygons are not the same colour if possible. The output is given a color_id numbered 0 through 5. You can then use an AttributeValueMapper or similar to map these numbers to the values you want (59, 63, 70, 72, 76 and 77)

Hi ebygomm,

thanks for reply. I will try that and then let u know if it was working.

I think you can use a FeatureColorSetter to do this. If you choose Map Coloring (N Color) Fast, you can then choose 6 colours. This should ensure that neighbouring polygons are not the same colour if possible. The output is given a color_id numbered 0 through 5. You can then use an AttributeValueMapper or similar to map these numbers to the values you want (59, 63, 70, 72, 76 and 77)

Hi ebygomm,

sorry for the late answer. I tried your way and it works for countries which have no islands. So for example Mali. But for countries Australia it was not working. FME gave small islands of Australia, which are external territories, like Christmas Island or Coral Sea Islands a colour value but the states on the continent not. Do u have an idea why this is happening?

Hi ebygomm,

thanks for reply. I will try that and then let u know if it was working.

Hi ebygomm,

sorry for the late answer. I tried your way and it works for countries which have no islands or are just only one polygon. So for example Mali. But for countries Australia it was not working. FME gave small islands of Australia, which are external territories, like Christmas Island or Coral Sea Islands a colour value but the states on the continent not. Do u have an idea why this is happening?

 

Is there any other way to make in a different way?

Thanks for answering.

 

Greetings,

Fabian

Userlevel 3
Badge +26

Hi ebygomm,

sorry for the late answer. I tried your way and it works for countries which have no islands or are just only one polygon. So for example Mali. But for countries Australia it was not working. FME gave small islands of Australia, which are external territories, like Christmas Island or Coral Sea Islands a colour value but the states on the continent not. Do u have an idea why this is happening?

 

Is there any other way to make in a different way?

Thanks for answering.

 

Greetings,

Fabian

@zentnerfabian​ It may be helpful if you can upload a sample of your data where you are seeing the issues.

Hi ebygomm,

sorry for the late answer. I tried your way and it works for countries which have no islands or are just only one polygon. So for example Mali. But for countries Australia it was not working. FME gave small islands of Australia, which are external territories, like Christmas Island or Coral Sea Islands a colour value but the states on the continent not. Do u have an idea why this is happening?

 

Is there any other way to make in a different way?

Thanks for answering.

 

Greetings,

Fabian

@dustin​ ,

 

I will try. Lot of the data is restricted in my case.

I try to explain it again. Maybe it helps. The first administrative level of Australia consist of 6 states : New South Wales, Victoria, Queensland, Western Australia, South Australia and Tasmania.

Also external territories like the Christmas Island belong to the first administrative level. But these are all islands. So they have no direct neighbour as a polygon like the 6 states have.

That means if I work with the FeatureColourSetter and the AttributeValueMapper for only the 6 states, then it works. But if I do it with the external territories FME gave islands like Christmas Island a colour value but the states on the continent not. This could be beause of the neighbour topic, cause the islands have no direct neighbour.

Hope the explaination is understandable.

Cheers,

Fabian

Reply