2

I'm using QGIS and trying to save a point layer with labels. When I save that point layer and then try to open it separately. But now there are only the points no any labels which I fix earlier.

Why is that?

Before saving the point layer. enter image description here

After saving the point layer and opened it. enter image description here

What can I do in here to avoid this situation?

  • I need to use this shape file in C# program.So that I used dotspatial libraries.I can only load the .shp files to the map.But unfortunately, I can load the shape file without labels.It's useless.Because anyone can't identify what are the points are. – amavi Aug 1 '16 at 9:34
  • why do you need labels to identify what a point in a shape file is? because shapefiles consist of geometry TOGETHER WITH attribute data, one can identify what what is anyway, or am i wrong? I have allways been regarding labels as visual benefit, and not as having semantic meaning in terms of data content?! – Jochen Schwarze Aug 1 '16 at 9:56
  • Of course, I need labels for visualization purpose.I need to show this point is this(ex:name of the place).Something like that. – amavi Aug 1 '16 at 10:13
  • 1
    but name of the place comes from the attributes, not from the labels. the lables feed from the attributes as well too. – Jochen Schwarze Aug 1 '16 at 10:14
  • You might want to check out this answer: gis.stackexchange.com/a/4317/37568 . Basically, it says that if you save a style file with the shapefile's name, in the same directory as the shape file, it will auto-pickup the symbology when loading the shape file. – pkExec Aug 1 '16 at 10:25
5

Shapefiles are not capable of storing additional information, e.g. where to put labels, wich font and size and so on. Shapefiles only store geometries (like the points in your example) together with attribute information. The information you wish to store can be saved in a qgis layer definition file (*.qlr) or in a qgis project, rsp.

The layerfile will store WHERE your shapefile is (the data source) and HOW it is displayed (and some further settings like editors and so on). You can achieve this by right clicking on the layer (NC_with_answer [10] in your example) and then select 'Save layer definition...' (hint: I unfortunaltly have the german GUI and hope to translate this correctly).

The layer definition file can be re-opened by the Layers-Menu > Add from layer definition...

Here is a technical description of what shapefiles are capable of: https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf and I strongly suggest reading the documentation at qgis.org!

  • thanks..it totally works but I can't use .qlr file in C#. – amavi Aug 1 '16 at 9:41
  • 1
    depends on what you want to do with the qlr file. qlr files are plain xml, and for shure you can read and parse xml with C#. bit of googling: stackoverflow.com/questions/642293/… hint: the section you might be interested in in the qlr file is <customproperties><property key="labeling.... – Jochen Schwarze Aug 1 '16 at 9:52
1

This is because the styling is not saved in the shapefile. In order to achieve what you want you have to save it as project (.qgs, File > Save). Mind you that if you want to share your project with someone, you have to share the shapefile as well.

  • yeahhh...that's correct.But the thing is I need a shape file(.shp format) not the qgis file(.qgs format). – amavi Aug 1 '16 at 9:17

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.