2

I'm currently developing a plugin (python, pyqt4) for QGIS 2.10+. Normal data source which I could use should contain complete path to the loaded layer. For example, my Alaska layer when uploaded normally contains path as:

/home/user/qgis_dataset/shapefiles/Alaska.shp.

The crucial thing for my plugin is to extract correct data source, which proves to be a problem in certain situations. When layers are uploaded as directory, source looks like:

/home/user/qgis_dataset/shapefiles|layer_id={num}.

Although I derived a hack to solve this problem there are some cases which still remain problematic. Firstly I tried to use provided source and look for file names that match layer.name(), but what if user changes layer name. Than I must use layer.id() which looks like original_layer_name201709281148. For now I'm using layer.name(), layer.source() and layer.id(), and it would be great if there is some kind of method that returns correct data source

  • What do you mean by "data source"? Do you mean it in the OGR sense of having DSN and a layer? Some OGR data sources don't map to files. What do you want to do if the layer is a WMS or other server-based layer? – Spacedman Sep 30 '17 at 7:58
  • I'm strictly speaking about layers that are loaded from local storage (vector/raster layers) that are loadedas files or folders. – Filip Zoric Oct 2 '17 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.