How to add an existing QGSVectorLayer to QGIS project?How to add openstreetmap WMS layer to QGIS 3?Getting LayerTree reference in Processing script in QGIS 3?QgsVectorLayer - Errors opening delimited textCSV fileHow do I declare a QGIS custom expression function and use it in a single python script?Add PostGIS layer to QGIS via Python ConsolePyQGIS import csv- QGIS 3.4Saving QML styles directly into QGS project fileSetting selection border color in red and save the map of the resulting selectionLoad lines from .OSM in Processing ModelerQGIS Processing Script to Create and Add CSV Layer

Mixed Feelings - What am I

What do you call someone who likes to pick fights?

If nine coins are tossed, what is the probability that the number of heads is even?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

Short SF story. Females use stingers to implant eggs in yearfathers

What is better: yes / no radio, or simple checkbox?

Is this Paypal Github SDK reference really a dangerous site?

Tool for measuring readability of English text

Does an unused member variable take up memory?

How to recover against Snake as a heavyweight character?

Does the US political system, in principle, allow for a no-party system?

ESPP--any reason not to go all in?

Do I need a return ticket to Canada if I'm a Japanese National?

Propulsion Systems

What would be the most expensive material to an intergalactic society?

Tabular environment - text vertically positions itself by bottom of tikz picture in adjacent cell

How can I portion out frozen cookie dough?

Why aren't there more Gauls like Obelix?

What is the oldest European royal house?

How does learning spells work when leveling a multiclass character?

What exactly is the meaning of "fine wine"?

Paper published similar to PhD thesis

What does it take to become a wilderness skills guide as a business?

Is the differential, dp, exact or not?



How to add an existing QGSVectorLayer to QGIS project?


How to add openstreetmap WMS layer to QGIS 3?Getting LayerTree reference in Processing script in QGIS 3?QgsVectorLayer - Errors opening delimited textCSV fileHow do I declare a QGIS custom expression function and use it in a single python script?Add PostGIS layer to QGIS via Python ConsolePyQGIS import csv- QGIS 3.4Saving QML styles directly into QGS project fileSetting selection border color in red and save the map of the resulting selectionLoad lines from .OSM in Processing ModelerQGIS Processing Script to Create and Add CSV Layer













4















I know I can pull a vector file into my current project using:



vlayer = iface.addVectorLayer(r"S:/Data/Natural_Earth_quick_start/110m_cultural/ne_110m_admin_0_countries.shp", "admin", "ogr")


But if I create my layer using something like:



vlayer = QgsVectorLayer(r"S:/Data/Natural_Earth_quick_start/110m_cultural/ne_110m_admin_0_countries.shp", "admin", "ogr")


and then I do some processing on vlayer how do I then add it to the current project or map layers list?










share|improve this question

















  • 1





    Can you expand on what you mean by "processing"? Editing the layer such as modifying features, running a tool from the processing toolbox etc? Or do you mean something like: QgsProject.instance().addMapLayer(vlayer)?

    – Joseph
    2 days ago











  • that is the correct answer

    – Ian Turton♦
    2 days ago











  • Any sort of process that changes the layer features

    – Ian Turton♦
    2 days ago











  • You can see in the PyQGIS cookbook how to add a QgsVectorLayer to the project docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/…

    – etrimaille
    2 days ago











  • @etrimaille - thanks, I spotted that soon after I got the answer here :-)

    – Ian Turton♦
    yesterday















4















I know I can pull a vector file into my current project using:



vlayer = iface.addVectorLayer(r"S:/Data/Natural_Earth_quick_start/110m_cultural/ne_110m_admin_0_countries.shp", "admin", "ogr")


But if I create my layer using something like:



vlayer = QgsVectorLayer(r"S:/Data/Natural_Earth_quick_start/110m_cultural/ne_110m_admin_0_countries.shp", "admin", "ogr")


and then I do some processing on vlayer how do I then add it to the current project or map layers list?










share|improve this question

















  • 1





    Can you expand on what you mean by "processing"? Editing the layer such as modifying features, running a tool from the processing toolbox etc? Or do you mean something like: QgsProject.instance().addMapLayer(vlayer)?

    – Joseph
    2 days ago











  • that is the correct answer

    – Ian Turton♦
    2 days ago











  • Any sort of process that changes the layer features

    – Ian Turton♦
    2 days ago











  • You can see in the PyQGIS cookbook how to add a QgsVectorLayer to the project docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/…

    – etrimaille
    2 days ago











  • @etrimaille - thanks, I spotted that soon after I got the answer here :-)

    – Ian Turton♦
    yesterday













4












4








4








I know I can pull a vector file into my current project using:



vlayer = iface.addVectorLayer(r"S:/Data/Natural_Earth_quick_start/110m_cultural/ne_110m_admin_0_countries.shp", "admin", "ogr")


But if I create my layer using something like:



vlayer = QgsVectorLayer(r"S:/Data/Natural_Earth_quick_start/110m_cultural/ne_110m_admin_0_countries.shp", "admin", "ogr")


and then I do some processing on vlayer how do I then add it to the current project or map layers list?










share|improve this question














I know I can pull a vector file into my current project using:



vlayer = iface.addVectorLayer(r"S:/Data/Natural_Earth_quick_start/110m_cultural/ne_110m_admin_0_countries.shp", "admin", "ogr")


But if I create my layer using something like:



vlayer = QgsVectorLayer(r"S:/Data/Natural_Earth_quick_start/110m_cultural/ne_110m_admin_0_countries.shp", "admin", "ogr")


and then I do some processing on vlayer how do I then add it to the current project or map layers list?







qgis-3 pyqgis-3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









Ian Turton♦Ian Turton

49.5k547114




49.5k547114







  • 1





    Can you expand on what you mean by "processing"? Editing the layer such as modifying features, running a tool from the processing toolbox etc? Or do you mean something like: QgsProject.instance().addMapLayer(vlayer)?

    – Joseph
    2 days ago











  • that is the correct answer

    – Ian Turton♦
    2 days ago











  • Any sort of process that changes the layer features

    – Ian Turton♦
    2 days ago











  • You can see in the PyQGIS cookbook how to add a QgsVectorLayer to the project docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/…

    – etrimaille
    2 days ago











  • @etrimaille - thanks, I spotted that soon after I got the answer here :-)

    – Ian Turton♦
    yesterday












  • 1





    Can you expand on what you mean by "processing"? Editing the layer such as modifying features, running a tool from the processing toolbox etc? Or do you mean something like: QgsProject.instance().addMapLayer(vlayer)?

    – Joseph
    2 days ago











  • that is the correct answer

    – Ian Turton♦
    2 days ago











  • Any sort of process that changes the layer features

    – Ian Turton♦
    2 days ago











  • You can see in the PyQGIS cookbook how to add a QgsVectorLayer to the project docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/…

    – etrimaille
    2 days ago











  • @etrimaille - thanks, I spotted that soon after I got the answer here :-)

    – Ian Turton♦
    yesterday







1




1





Can you expand on what you mean by "processing"? Editing the layer such as modifying features, running a tool from the processing toolbox etc? Or do you mean something like: QgsProject.instance().addMapLayer(vlayer)?

– Joseph
2 days ago





Can you expand on what you mean by "processing"? Editing the layer such as modifying features, running a tool from the processing toolbox etc? Or do you mean something like: QgsProject.instance().addMapLayer(vlayer)?

– Joseph
2 days ago













that is the correct answer

– Ian Turton♦
2 days ago





that is the correct answer

– Ian Turton♦
2 days ago













Any sort of process that changes the layer features

– Ian Turton♦
2 days ago





Any sort of process that changes the layer features

– Ian Turton♦
2 days ago













You can see in the PyQGIS cookbook how to add a QgsVectorLayer to the project docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/…

– etrimaille
2 days ago





You can see in the PyQGIS cookbook how to add a QgsVectorLayer to the project docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/…

– etrimaille
2 days ago













@etrimaille - thanks, I spotted that soon after I got the answer here :-)

– Ian Turton♦
yesterday





@etrimaille - thanks, I spotted that soon after I got the answer here :-)

– Ian Turton♦
yesterday










1 Answer
1






active

oldest

votes


















4















  • To add an existing single layer:



    vlayer = QgsVectorLayer("some/path/to/shapefile.shp", "admin", "ogr")
    QgsProject.instance().addMapLayer(vlayer)




  • To add existing multiple layers:



    vlayer1 = QgsVectorLayer("some/path/to/shapefile1.shp", "admin1", "ogr")
    vlayer2 = QgsVectorLayer("some/path/to/shapefile2.shp", "admin2", "ogr")
    layers = [vlayer1 , vlayer2]
    QgsProject.instance().addMapLayers(layers)






share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "79"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f314564%2fhow-to-add-an-existing-qgsvectorlayer-to-qgis-project%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4















    • To add an existing single layer:



      vlayer = QgsVectorLayer("some/path/to/shapefile.shp", "admin", "ogr")
      QgsProject.instance().addMapLayer(vlayer)




    • To add existing multiple layers:



      vlayer1 = QgsVectorLayer("some/path/to/shapefile1.shp", "admin1", "ogr")
      vlayer2 = QgsVectorLayer("some/path/to/shapefile2.shp", "admin2", "ogr")
      layers = [vlayer1 , vlayer2]
      QgsProject.instance().addMapLayers(layers)






    share|improve this answer



























      4















      • To add an existing single layer:



        vlayer = QgsVectorLayer("some/path/to/shapefile.shp", "admin", "ogr")
        QgsProject.instance().addMapLayer(vlayer)




      • To add existing multiple layers:



        vlayer1 = QgsVectorLayer("some/path/to/shapefile1.shp", "admin1", "ogr")
        vlayer2 = QgsVectorLayer("some/path/to/shapefile2.shp", "admin2", "ogr")
        layers = [vlayer1 , vlayer2]
        QgsProject.instance().addMapLayers(layers)






      share|improve this answer

























        4












        4








        4








        • To add an existing single layer:



          vlayer = QgsVectorLayer("some/path/to/shapefile.shp", "admin", "ogr")
          QgsProject.instance().addMapLayer(vlayer)




        • To add existing multiple layers:



          vlayer1 = QgsVectorLayer("some/path/to/shapefile1.shp", "admin1", "ogr")
          vlayer2 = QgsVectorLayer("some/path/to/shapefile2.shp", "admin2", "ogr")
          layers = [vlayer1 , vlayer2]
          QgsProject.instance().addMapLayers(layers)






        share|improve this answer














        • To add an existing single layer:



          vlayer = QgsVectorLayer("some/path/to/shapefile.shp", "admin", "ogr")
          QgsProject.instance().addMapLayer(vlayer)




        • To add existing multiple layers:



          vlayer1 = QgsVectorLayer("some/path/to/shapefile1.shp", "admin1", "ogr")
          vlayer2 = QgsVectorLayer("some/path/to/shapefile2.shp", "admin2", "ogr")
          layers = [vlayer1 , vlayer2]
          QgsProject.instance().addMapLayers(layers)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        JosephJoseph

        57.8k7100199




        57.8k7100199



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid …


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f314564%2fhow-to-add-an-existing-qgsvectorlayer-to-qgis-project%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

            Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices

            How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page