I have an ArcGIS colormap (*.clr) and I want to open it in QGIS to apply a predefined style.

The *.clr file is really simple, only has four columns representing [value] [red] [green] [blue], as this example:

19 161 161 161
21 152 181 129
22 114 168 144
23 124 142 173

Is there a way to read these columns and convert them in a QGIS style file (*.qml)?

up vote 9 down vote accepted

Nice answer from @whyzar! You could load .clr files into QGIS and then save it as a .qml file. As described in this post, the standard text format is:

Value R G B Alpha Label

So in your case, you could create a text file with:

19,161,161,161,255,19
21,152,181,129,255,21
22,114,168,144,255,22
23,124,142,173,255,23

And load it from the menu:

Result

You can then edit and save the style as a .qml.


From @Stefan's comment, I've included some quick code which reformats the input text file in a way that QGIS can read it (hopefully!):

main_path = 'path/to/directory/'
with open(main_path + 'infile.txt') as infile, open(main_path + 'outfile.txt', 'w') as outfile:
    for line in infile:
        value = line.split(' ')[0]
        line = line.replace(' ', ',').rstrip('\n') + ',255,' + value + '\n'
        outfile.write(line)
  • 3
    Thanks for highlighting out the differences between these two color map files. A little bit of Python code and there could be a new QGIS Plugin. – Stefan Oct 10 '17 at 13:37
  • 1
    @Stefan - Most welcome! And I look forward to your plugin ;) – Joseph Oct 10 '17 at 13:42
  • @Stefan - Thought I'd have a go and write up some code to hopefully do the above automatically =) – Joseph Oct 10 '17 at 14:38
  • 1
    @Joseph perfect, I've been testing it and works. Thanks! – aldo_tapia Oct 10 '17 at 15:08
  • 1
    @aldo_tapia - Most welcome! Glad it worked :) – Joseph Oct 10 '17 at 15:11

I haven't yet to find a clean cut way to do this. I have come across different resources that can offer option to work with in attempting to achieve what you are interested in.

Converting/using ArcGIS *.style file for/in QGIS (QML or SLD)?

The style file might be for ARCGIS users. It is not in a human readable format.

QGIS uses XML-files to store styling properties, so you have no luck with just renaming the extension.

I am not aware of any ESRI-to-QGIS style converter.

and also an alternative

Another option might be to save the style as a .lyr file. Then use http://wald.intevation.org/projects/arcmap2sld/ to convert the .lyr file to an SLD and then use that SLD within QGIS

In QGIS, right click on the layer > properties > load style then use the drop down box to select SLD

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.