1

I kept my original question clear and concise to make it easier to answer. This is a response to requests for more information.

Introduction I am using QGIS version 2.18.9. I created about 20 new memory layers by clicking on "Layer", then "Create Layer", then "New Memory Layer". I want to create 8 duplicates of each layer.

Aim I want to avoid creating from scratch multiple layers containing identically-shaped polygons. I want to create duplicates so I can simply change the colour of each polygon to represent different data.

Problems When I right click on a layer and then click "Duplicate" I get an error message saying "Memory Layer type unsupported"

What I have tried As above. I have not found anything else on the program that looks promising. I have not found any topics on here that help. My knowledge is limited and I am not familiar with all the jargon or protocols.

  • 2
    which QGIS version are you using what type is your layer? please give more context – LaughU Jun 29 '17 at 11:07
  • 1
    Please edit your question to include the following: 1) an introduction to your problem, 2) What you hope to accomplish, 3) and error messages or problems encountered, and 4) What you may have tried. – Aaron Jun 29 '17 at 11:53
  • Can you provide more information like a screenshot of your problem? So, would it maybe make sense to save your memory layer as a shapefile and then duplicate it? If you want to avoid to begin from scratch again, not working with memory-layers could be a first step. – DirkB. Jun 29 '17 at 19:57
  • What kind of datasets make up your layer(s)?. If you open up Windows Explorer and browse to a shapefile, you can drag the shp into your project window 8 times pretty quickly and then work on each layer's color. You could use the add data button 8 times each for any data type too but that is probably what you are trying to avoid. – johns Jun 29 '17 at 20:39
  • "Duplicate" no longer shows as an option when I right click on a layer, so I cannot show a screen shot of that. I get the same result from choosing "Duplicate" from the "Layers" tab (.i.e. " ! Duplicate layer... Memory Layer type unsupported") but I can't seem to paste a screen shot here. If I right click on the memory layer and choose save as I can save it as a shapefile and can duplicate that. Thanks Dirk – user34581 Jul 1 '17 at 10:59
1
  • Using PyQGIS, you can create another memory layer and copy the features over:

    layer = iface.activeLayer()
    feats = [feat for feat in layer.getFeatures()]
    # Use "Polygon" for polygon layer; "Point" for point layer; "LineString" for line layer
    mem_layer = QgsVectorLayer("Polygon?crs=epsg:4326", "duplicated_layer", "memory")
    
    mem_layer_data = mem_layer.dataProvider()
    attr = layer.dataProvider().fields().toList()
    mem_layer_data.addAttributes(attr)
    mem_layer.updateFields()
    mem_layer_data.addFeatures(feats)
    
    QgsMapLayerRegistry.instance().addMapLayer(mem_layer)
    
  • The Speedy Layer plugin also allows you to select a loaded layer (including memory layers) and output another memory layer. You can also select the features and fields you want copied over. You can download/install this from the menubar:

    Plugins > Manage and Install Plugins...
    

    Speedy Layer Interface

  • Thanks but pyQGIS looks too complicated for me and I have downloaded Speedy Layer but don't know what to do next. I was hoping for a simple answer. – user34581 Jun 29 '17 at 16:17
  • @user34581 - For the Speedy Layer plugin, you select a layer you want to duplicate from the Choose Layer list, then leave the Only selected features option unchecked and don't select any fields. Then click Speed Up to create the duplicated layer :) – Joseph Jun 30 '17 at 9:24

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.