QGIS Python (PyQGIS) - Add layer to a map layout

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ม.ค. 2025

ความคิดเห็น • 23

  • @no_justno
    @no_justno ปีที่แล้ว +4

    Please don't apologize for those mistakes. Those mistakes make this more informative than anything else because we learn what common errors we can make and avoid them preemptively. Your work is phenomenal.

  • @babuvanam9448
    @babuvanam9448 4 ปีที่แล้ว +1

    Thank you very much, your tutorials helped me a lot,how can I create frame in print layout using python

  • @teo11300
    @teo11300 5 ปีที่แล้ว +2

    Now I'd like to see this scripted outside of a QGIS session, in a standalone python script. Using a popular IDE like PyCharm.

  • @tofusandwich5016
    @tofusandwich5016 5 ปีที่แล้ว +1

    That's really useful, thank you. Do you know how to apply a theme by name to the layout?

  • @jonathanlalrinawma7919
    @jonathanlalrinawma7919 2 ปีที่แล้ว +1

    I get a error when i put a code layer = layers[0] like this
    File "", line 4, in
    IndexError: list index out of range
    can you please help me

  • @diwaker8616
    @diwaker8616 4 ปีที่แล้ว

    Hello Friend,
    Could you pleae help how i can add the google map [live -street view] in QGIS? Idea is to analyze the situation while jumping on to an old location with the current live situation. I looked into your videos but couldn't find it any of the videos.
    May be a plug in would be helpful, if any.

  • @pavel_pereverzev
    @pavel_pereverzev 5 ปีที่แล้ว +1

    Great tutorial! I need to create a table item in layout that contains coordinates. Is it possible to do in pyqgis?

    • @geospatialschool
      @geospatialschool  5 ปีที่แล้ว

      Thanks! I haven't looked into tables yet, and haven't seen any tutorials on it. I think it would be possible to do, but might take a little work to figure out. I'll have a video next week that shows how to add legends and scalebars. You may be able to follow the same general idea to add a table.

    • @pavel_pereverzev
      @pavel_pereverzev 5 ปีที่แล้ว

      @@geospatialschool okay, will be waiting for it! I thought about making a simple text label that contains text with tabulations and '
      ' sequences to write every pair of coordinates in a new line, but that would be too ugly to watch it without borders.

    • @geospatialschool
      @geospatialschool  5 ปีที่แล้ว

      Here's a link to the python documentation for the table item: qgis.org/pyqgis/3.0/core/Layout/QgsLayoutItemTextTable.html
      I haven't worked with it yet, but it seems like it will get you what you want. This is something I could try to do in a future video.

    • @pavel_pereverzev
      @pavel_pereverzev 5 ปีที่แล้ว

      @@geospatialschool yeah, I saw that and moreover tried to use more simple thing that load attribute table to layout. But pyqgis throws an error that tells that table layout class doesn't support by layout's method of adding features.
      Also create a new question here, still waiting for someone who knows;)
      gis.stackexchange.com/questions/314721/how-to-add-attribute-table-into-layout-pyqgis-3-x

    • @geospatialschool
      @geospatialschool  5 ปีที่แล้ว

      I tried your code and got the same error. I tried some other things, and couldn't get it to work either. It could be a bug on the QGIS end, because I think it should work. I also can't construct a QgsLayoutItemAttributeTable the same way as other layout items. For the other items I can call it like this: QgsLayoutItemAttributeTable(layout), but that throws an error about a C++ abstract class. I have to call it using the create() method like you have done.

  • @babuvanam9448
    @babuvanam9448 4 ปีที่แล้ว

    I was able to label my shape file using python but I have to label using expression
    Label expression is like below
    wordwrap("name",-3) || '
    ' || "value"
    name and value are attributes how to do this using python??
    Thanks in advance 😊

  • @kitsoskitsou
    @kitsoskitsou 4 ปีที่แล้ว

    Hey that's really great and helpful! How about displaying two layers in two maps within the same layout? I tried fiddling with the code (create a layer2 and map2 and then ms2.setLayers([layer2])) but it will display the first layer. any ideas?

    • @geospatialschool
      @geospatialschool  4 ปีที่แล้ว

      Did you add the second map item to the layout? Like this: layout.addLayoutItem(map2)

    • @kitsoskitsou
      @kitsoskitsou 4 ปีที่แล้ว

      Hey, thanks for your quick response! Yes, I did. I understand that this is not stack exchange but in cause you wanna have a look at the code: pastebin.com/aVQXYrzZ thanks again

  • @willerfagundesdeoliveira3261
    @willerfagundesdeoliveira3261 5 ปีที่แล้ว +1

    Nice!!!

    • @geospatialschool
      @geospatialschool  5 ปีที่แล้ว

      Thanks! I'll have a video next week that shows how to add a legend and scalebar

  • @irpanhidaya5329
    @irpanhidaya5329 ปีที่แล้ว

    code please, hahaha, thanks so much