I've been asked to map an area of land using QGIS, so I created a new vector layer polygon and saved it to my PC without problems.

They've asked for the following files: .shp, .shx, .dbf, .prj and .cpg.

When I go to the folder containing my saved polygon files, all files except .cpg are there.

How do I create a .cpg file for my polygon?

  • 3
    .cpg isn't a required extension for your file. From gisgeography.com/arcgis-shapefile-files-types-extensions : ".cpg: These are optional plain text files that describes the encoding applied to create the Shapefile. If your shapefile doesn’t have a cpg file, then it has the system default encoding." – MaryBeth Jul 5 '17 at 18:48
  • Thanks MaryBeth. They've said they definitely need a .cpg file but I'll try and explain to them what you said. – bird0507 Jul 5 '17 at 19:20

The .cpg file is optional.

It is used to specify the code page (only for .dbf) for identifying the character encoding to be used (for example to encode utf-8).

It should not be a problem for the one who gets the shapefile to open it without .cpg-file

For further information https://en.wikipedia.org/wiki/Shapefile

But if you really need that file. just open a texteditor and write "UTF-8" into the first line and save it as "shapefilename.cpg"

| improve this answer | |
  • Thanks Dirk, I'll try your text editor suggestion. What does UTF-8 mean? – bird0507 Jul 5 '17 at 19:26
  • UTF-8 is a character encoding capable of encoding all possible Unicode code points. It encodes the text so all possible letters are written correctly and not like hieroglyphics en.wikipedia.org/wiki/UTF-8 – DirkB. Jul 5 '17 at 19:31
  • To decide if you really need that file, check if the attributes contain wrong representations of characters. E.g. "Kreisbögen" instead of "Kreisbögen" etc. In QGIS you can also go to "Layer Properties -> Source -> Data Source Encoding" to quickly check some different encodings that are correct for the data you have. – Matthias Kuhn Jul 17 '19 at 9:11

In the 'Save As' window select 'UTF-8'as Encoding.

| improve this answer | |

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.