How to test for previously joined layers before run a codeHow to use classified styles with joined...

Source permutation

Why couldn't the separatists legally leave the Republic?

What sort of fish is this

What materials can be used to make a humanoid skin warm?

Can I negotiate a patent idea for a raise, under French law?

Outlet with 3 sets of wires

Is it safe to abruptly remove Arduino power?

Recommendation letter by significant other if you worked with them professionally?

Was it really inappropriate to write a pull request for the company I interviewed with?

ER diagram relationship node size adjustment

Why does Solve lock up when trying to solve the quadratic equation with large integers?

What do you call someone who likes to pick fights?

When Schnorr signatures are part of Bitcoin will it be possible validate each block with only one signature validation?

Having the player face themselves after the mid-game

PTIJ: Why does only a Shor Tam ask at the Seder, and not a Shor Mu'ad?

Street obstacles in New Zealand

Signed and unsigned numbers

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

Is it a Cyclops number? "Nobody" knows!

Is it possible that a question has only two answers?

What is the generally accepted pronunciation of “topoi”?

Which classes are needed to have access to every spell in the PHB?

What do *foreign films* mean for an American?

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



How to test for previously joined layers before run a code


How to use classified styles with joined layers?QGIS 2.4: plugin changes map tool canvas click behavior from 2.0How to remove group filter applied via Python-console (setSubsetString) of QGIS?How to wait for mapCanvas render before taking screenshot?Adding a WMS layer in QGIS using pythonRefresh joined layersUsing “Join Attributes by Location” to perform spatial join of layer with joined data on dissolved layerUsing Time Manager with joined layers?Run processing only in layers with selectionHow do I change 'Coordinate Display' for a project, programatically?













0















I've a function that join two added layers. The code works fine, but now I need to test for previously joined layers before run this function. The function code is right below:



def jointables(dict): # this dict provides [targetLayer:layerToJoin]
for k, v in dict.items():
target = QgsProject.instance().mapLayer(k)
layerToJoin = QgsProject.instance().mapLayer(v)
fieldToJoin = QgsProject.instance()
symb = QgsVectorLayerJoinInfo()
symb.setJoinFieldName('id_feature')
symb.setTargetFieldName('id')
symb.setJoinLayerId(layerToJoin.id())
symb.setEditable(True)
symb.setDynamicFormEnabled(True)
symb.setUpsertOnEdit(True)
symb.setPrefix('')
symb.setJoinLayer(layerToJoin)
target.addJoin(symb)


I've tried some things like this:



for k, v in dict.items():
if QgsProject.instance().mapLayer(k).addJoin(QgsVectorLayerJoinInfo()) == True:
break
else:
continue


or



for k, v in dict.items():
if QgsVectorLayerJoinInfo().isEditable() == True:
break
else:
continue


among others. I've missing something. Both conditionals has the same value True, doesnt matter if already exists an previously joined layer or not. How can I solve this?










share|improve this question





























    0















    I've a function that join two added layers. The code works fine, but now I need to test for previously joined layers before run this function. The function code is right below:



    def jointables(dict): # this dict provides [targetLayer:layerToJoin]
    for k, v in dict.items():
    target = QgsProject.instance().mapLayer(k)
    layerToJoin = QgsProject.instance().mapLayer(v)
    fieldToJoin = QgsProject.instance()
    symb = QgsVectorLayerJoinInfo()
    symb.setJoinFieldName('id_feature')
    symb.setTargetFieldName('id')
    symb.setJoinLayerId(layerToJoin.id())
    symb.setEditable(True)
    symb.setDynamicFormEnabled(True)
    symb.setUpsertOnEdit(True)
    symb.setPrefix('')
    symb.setJoinLayer(layerToJoin)
    target.addJoin(symb)


    I've tried some things like this:



    for k, v in dict.items():
    if QgsProject.instance().mapLayer(k).addJoin(QgsVectorLayerJoinInfo()) == True:
    break
    else:
    continue


    or



    for k, v in dict.items():
    if QgsVectorLayerJoinInfo().isEditable() == True:
    break
    else:
    continue


    among others. I've missing something. Both conditionals has the same value True, doesnt matter if already exists an previously joined layer or not. How can I solve this?










    share|improve this question



























      0












      0








      0








      I've a function that join two added layers. The code works fine, but now I need to test for previously joined layers before run this function. The function code is right below:



      def jointables(dict): # this dict provides [targetLayer:layerToJoin]
      for k, v in dict.items():
      target = QgsProject.instance().mapLayer(k)
      layerToJoin = QgsProject.instance().mapLayer(v)
      fieldToJoin = QgsProject.instance()
      symb = QgsVectorLayerJoinInfo()
      symb.setJoinFieldName('id_feature')
      symb.setTargetFieldName('id')
      symb.setJoinLayerId(layerToJoin.id())
      symb.setEditable(True)
      symb.setDynamicFormEnabled(True)
      symb.setUpsertOnEdit(True)
      symb.setPrefix('')
      symb.setJoinLayer(layerToJoin)
      target.addJoin(symb)


      I've tried some things like this:



      for k, v in dict.items():
      if QgsProject.instance().mapLayer(k).addJoin(QgsVectorLayerJoinInfo()) == True:
      break
      else:
      continue


      or



      for k, v in dict.items():
      if QgsVectorLayerJoinInfo().isEditable() == True:
      break
      else:
      continue


      among others. I've missing something. Both conditionals has the same value True, doesnt matter if already exists an previously joined layer or not. How can I solve this?










      share|improve this question
















      I've a function that join two added layers. The code works fine, but now I need to test for previously joined layers before run this function. The function code is right below:



      def jointables(dict): # this dict provides [targetLayer:layerToJoin]
      for k, v in dict.items():
      target = QgsProject.instance().mapLayer(k)
      layerToJoin = QgsProject.instance().mapLayer(v)
      fieldToJoin = QgsProject.instance()
      symb = QgsVectorLayerJoinInfo()
      symb.setJoinFieldName('id_feature')
      symb.setTargetFieldName('id')
      symb.setJoinLayerId(layerToJoin.id())
      symb.setEditable(True)
      symb.setDynamicFormEnabled(True)
      symb.setUpsertOnEdit(True)
      symb.setPrefix('')
      symb.setJoinLayer(layerToJoin)
      target.addJoin(symb)


      I've tried some things like this:



      for k, v in dict.items():
      if QgsProject.instance().mapLayer(k).addJoin(QgsVectorLayerJoinInfo()) == True:
      break
      else:
      continue


      or



      for k, v in dict.items():
      if QgsVectorLayerJoinInfo().isEditable() == True:
      break
      else:
      continue


      among others. I've missing something. Both conditionals has the same value True, doesnt matter if already exists an previously joined layer or not. How can I solve this?







      qgis pyqgis pyqgis-3






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 5 mins ago







      Francisco Camello

















      asked 21 hours ago









      Francisco CamelloFrancisco Camello

      425




      425






















          0






          active

          oldest

          votes











          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%2f314953%2fhow-to-test-for-previously-joined-layers-before-run-a-code%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f314953%2fhow-to-test-for-previously-joined-layers-before-run-a-code%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

          (145452) 2005 RN43 Классификация | Примечания | Ссылки |...

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          Энтрерриос (город) Содержание История | Географическое...