I have polygons with the area in the attribute table and I want change polygons to red color if they have area less 70.

area and polygon

  • Thank you for help, yes is also a GOOD answer, if I want to save the changes in GeoJSON, can I do it or I need to create an attribute table different column and save the color by a polygon? – Evgeny Ryvkin Jan 2 '19 at 20:16
  • is help me and useful, I just try to learn more about this program. – Evgeny Ryvkin Jan 2 '19 at 20:24
  • Unrelated to your question, but I noticed that the feature in the top-left of your screenshot looks like it has self-intersecting boundaries, which would make it an invalid geometry. – csk Jan 2 '19 at 20:46

Create a rule based symbology like this: One with the rule "area" < 70 and one with the rule ELSE ("area" refers to an attribute value while $area calculates the area; use the one you need; according to your sceenshot it is "area")

enter image description here

  • @EvgenyRyvkin you can also use a graduated renderer on the $area variable (rather than a SHAPE_AREA column), then set your own class breaks and colours. – DPSSpatial Jan 2 '19 at 21:54

Here's another method. It's not really any better than MrXsquared's answer, but I had already started writing it.

Use data-defined settings to control fill color

enter image description here

with this expression: if("area"<70, '#ff0000','#00ff00')

This expression will set the fill color to red (#ff0000 in hex notation) when the area is less than 70, and green otherwise.

enter image description here

If you want to use different shades of red and green, you can get the hex notation for the desired color from the "select color" dialog - just select the color you want and scroll down to find the hex notation near the bottom.

enter image description here

  • Thank you for your answer, yes is a good example of how can I write different color in hexa and using data-defined. – Evgeny Ryvkin Jan 2 '19 at 20:27

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.