<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hi,<br>
    </p>
    The Expressions Plus plugin is there for sharing expressions that
    are of broader interest but for whatever reason did not make it
    (yet) to core [1]<br>
    <br>
    Would be great to push there whatever is interesting so we don't
    have to install a bazillion different plugins.<br>
    <br>
    Matthias<br>
    <br>
    [1] <a class="moz-txt-link-freetext" href="https://plugins.qgis.org/plugins/qgsexpressionsplus/">https://plugins.qgis.org/plugins/qgsexpressionsplus/</a><br>
    <br>
    <div class="moz-cite-prefix">On 19/10/16 21:42, DelazJ wrote:<br>
    </div>
    <blockquote
cite="mid:CAECJsSo9dd3++=jH5yUP3Rv-SJ7UpnOmCM6y+KysqAE0k7aBtQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div style="font-family:'Calibri','sans-serif'">
          <div dir="ltr">
            <div dir="ltr"><font size="2">Hi all,</font></div>
            <div dir="ltr"><font size="2">Thank you all for your
                answers. This is really a great community! I already
                knew that but let me say it loudly. It also shows all
                the capabilities of QGIS to solve a problem.</font></div>
            <div dir="ltr"><font size="2"><br>
              </font></div>
            <div dir="ltr"><font size="2">Nicolas, as Andreas said, I'm
                looking for something dynamic, live. </font></div>
            <div dir="ltr"><font size="2"><br>
              </font></div>
            <div dir="ltr"><font size="2">The virtual layer can indeed
                be an option despite the creation of an intermediate but
                somehow live layer. Would be nice to have Andreas
                questions documented in the user manual so that users
                are fully aware of any potential limitations of the
                feature or its great power.</font></div>
            <div dir="ltr"><font size="2"><br>
              </font></div>
            <div dir="ltr"><font size="2">Another powerful feature I
                often neglect is the function editor. Maybe because
                there are so many functions in the list that I end up
                thinking that their combination would be enough. I think
                it's the way I will go as no intermediate layer is
                involved and despite your remarks (which are not far
                from Andreas questions about virtual layers). Thank you
                Germán for reminding me. </font></div>
            <div dir="ltr"><font size="2">That makes me wonder: we have
                in QGIS, ways to share processing scripts and models, to
                share symbols, styles... What about something to share
                custom expression functions? Plugins somehow already do
                that but I think there are many people that have an
                operational code (that fills some small and common needs
                like mine) but don't have time/skills to create the Gui
                around. Does it sound reasonable/feasible? Maybe should
                I open a discussion in dev list (or a ticket)?</font></div>
            <div dir="ltr"><font size="2"><br>
              </font></div>
            <div dir="ltr"><font size="2">Back to the approach I was
                following to solve the issue (combining default
                functions in expression) may I understand that it was
                endless? No way to group by when using aggregate
                function...?</font></div>
            <div dir="ltr"><font size="2"><br>
              </font></div>
            <div><font size="2">Greetings,<br>
              </font></div>
            <div><font size="2">Harrissou<br>
                <br>
              </font></div>
            <div dir="ltr">
              <div dir="ltr"><font size="2">Envoyé depuis mon HTC</font></div>
            </div>
            <font size="2">
            </font></div>
          <br>
          <div id="m_1040782985649138824htc_header">----- Reply message
            -----<br>
            De : "Germán Carrillo" <<a moz-do-not-send="true"
              href="mailto:carrillo.german@gmail.com" target="_blank">carrillo.german@gmail.com</a>><br>
            Pour : "Neumann, Andreas" <<a moz-do-not-send="true"
              href="mailto:a.neumann@carto.net" target="_blank">a.neumann@carto.net</a>>,
            "Harrissou 'DelazJ'" <<a moz-do-not-send="true"
              href="mailto:delazj@gmail.com" target="_blank">delazj@gmail.com</a>><br>
            Cc : "Nathan Woodrow" <<a moz-do-not-send="true"
              href="mailto:madmanwoo@gmail.com" target="_blank">madmanwoo@gmail.com</a>>,
            "qgis-user" <<a moz-do-not-send="true"
              href="mailto:qgis-user@lists.osgeo.org" target="_blank">qgis-user@lists.osgeo.org</a>>,
            "Nicolas Cadieux" <<a moz-do-not-send="true"
              href="mailto:nicolas.cadieux@archeotec.ca" target="_blank">nicolas.cadieux@archeotec.ca</a>><br>
            Objet : [Qgis-user] Using aggregates functions to count
            intersected features from another layer<br>
            Date : mer., oct. 19, 2016 18:04</div>
        </div>
        <br>
        <div dir="ltr">Hi All, 
          <div><br>
          </div>
          <div><br>
          </div>
          <div>Harrissou, have a look at [1] for a very similar question
            and one possible solution using the Function Editor (of
            course, instead of sum you would use count).</div>
          <div><br>
          </div>
          <div>Do you other devs find that approach useful? Any hint for
            keeping the index up-to-date?</div>
          <div><br>
          </div>
          <div>Is there any interest in having this kind of functions
            available for QGIS expressions? I could help with that.</div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>Regards, </div>
          <div><br>
          </div>
          <div>Germán</div>
          <div>--</div>
          <div>[1] <a moz-do-not-send="true"
              href="http://gis.stackexchange.com/a/212762/4972"
              target="_blank">http://gis.stackexchange.com/<wbr>a/212762/4972</a><br>
          </div>
          <div><br>
          </div>
        </div>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">2016-10-19 7:42 GMT-05:00 Neumann,
            Andreas <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:a.neumann@carto.net" target="_blank">a.neumann@carto.net</a>></span>:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div
                style="font-size:10pt;font-family:Verdana,Geneva,sans-serif">
                <p>Good idea to use a virtual layer for that! It is
                  probably also more efficient than a QGIS expression.</p>
                <p>Just to understand the virtual layers correctly:</p>
                <p>when is the query behind the virtual layer executed?</p>
                <p>- at every redraw?</p>
                <p>- once at creation?</p>
                <p>- at project reload?</p>
                <p>Aren't the virtual layers automatically updated, at
                  least when the project reloads?</p>
                <p>Are the results cached or not?</p>
                <p>Would also make sense to add a "update" option for a
                  virtual layer, if that doesn't exist yet.</p>
                <p>Greetings,</p>
                <p>Andreas</p>
                <div>
                  <div class="m_1040782985649138824h5">
                    <p> </p>
                    <p>On 2016-10-19 14:32, Nathan Woodrow wrote:</p>
                    <blockquote type="cite" style="padding:0
                      0.4em;border-left:#1010ff 2px solid;margin:0">
                      <div dir="ltr">Maybe using a virtual layer query
                        via DB Manager will work.  You have full SQL
                        join support. Speed isn't always the best but
                        gives you the full power of SQL which is the
                        correct way to do this IMO.
                        <div> </div>
                        <div>E.g SELECT LayerA.id, COUNT(*) FROM layerA </div>
                        <div>JOIN layerB ON ST_WithIn(layerA.geometry,
                          layerB.geometry)</div>
                        <div>GROUP BY layerA.type</div>
                        <div> </div>
                        <div>Although you can't do an update but you can
                          make a new layer with the new counts.<br>
                          <div> </div>
                          <div>- Nathan</div>
                        </div>
                      </div>
                      <div class="gmail_extra"><br>
                        <div class="gmail_quote">On Wed, Oct 19, 2016 at
                          10:22 PM, Neumann, Andreas <span><<a
                              moz-do-not-send="true"
                              href="mailto:a.neumann@carto.net"
                              target="_blank">a.neumann@carto.net</a>></span>
                          wrote:<br>
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex">
                            <div
                              style="font-size:10pt;font-family:Verdana,Geneva,sans-serif">
                              <p>Well yes - but that is not a "live"
                                point in polygon. It create separate
                                layers which need to be kept up-to-date.</p>
                              <p>Harrissou was after a "live" point in
                                polygon, which is automatically kept
                                up-to-date through a QGIS expression.</p>
                              <p>Maybe Nyall knows how to write the
                                correct aggregate expression for that?</p>
                              <p>Greetings,</p>
                              <p>Andreas</p>
                              <div>
                                <div
                                  class="m_1040782985649138824m_-566526819833031328h5">
                                  <p>On 2016-10-19 14:11, Nicolas
                                    Cadieux wrote:</p>
                                </div>
                              </div>
                              <blockquote style="padding:0
                                0.4em;border-left:#1010ff 2px
                                solid;margin:0">
                                <div>
                                  <div
                                    class="m_1040782985649138824m_-566526819833031328h5">
                                    <div> </div>
                                    <div>Try this.</div>
                                    <div> </div>
                                    <div><a moz-do-not-send="true"
                                        href="http://www.qgistutorials.com/fr/docs/points_in_polygon.html"
                                        target="_blank">http://www.qgistutorials.com/f<wbr>r/docs/points_in_polygon.html</a></div>
                                    <div> </div>
                                    <div>Nicolas</div>
                                    <div><br>
                                      Le 19 oct. 2016 à 06:37, DelazJ
                                      [via <a moz-do-not-send="true"
                                        href="http://OSGeo.org"
                                        target="_blank">OSGeo.org</a>]
                                      <<a moz-do-not-send="true">[hidden
                                        email]</a>> a écrit :<br>
                                      <br>
                                    </div>
                                    <blockquote style="border-left:2px
                                      solid #cccccc;padding:0 1em">
                                      <div>
                                        <div dir="ltr">
                                          <div>
                                            <div>
                                              <div>
                                                <div>
                                                  <div>
                                                    <div>Hi,<br>
                                                      <br>
                                                    </div>
                                                    I have a polygon
                                                    layer and a point
                                                    one.</div>
                                                  I'd like to calculate
                                                  for each polygon
                                                  feature, the number of
                                                  points that it covers.
                                                  I thought the
                                                  aggregates functions
                                                  could help me find an
                                                  easier and straight
                                                  expression to perform
                                                  this (without creating
                                                  intermediate layers)
                                                  but I fail to find any
                                                  correct syntax. <br>
                                                  <br>
                                                </div>
                                                I tried aggregate
                                                ('mypoint', 'count',
                                                "id", intersects
                                                ($geometry,
                                                geometry($currentfeature)))<br>
                                                <br>
                                                 And many variants of
                                                the fourth option but It
                                                always return the total
                                                of points or an error.
                                                Actually this option is
                                                a filter and I wonder if
                                                i'm not missing a "group
                                                by" option in the
                                                aggregate function
                                                (which seems to be the
                                                appropriate one in my
                                                case). Is it possible?</div>
                                            </div>
                                            <div>The work around I found
                                              is to populate an ad'hoc
                                              field in the point layer
                                              with overlapping polygon
                                              id, thanks to the
                                              SpatialJoin plugin, then I
                                              create a one-to-many
                                              relation in the project
                                              between the two layers in
                                              other to use
                                              relation_aggregate
                                              function.</div>
                                            <div>But I expected
                                              something more direct.</div>
                                            <div><br>
                                              Any hint, please?<br>
                                              <br>
                                            </div>
                                            Thanks,</div>
                                          Harrissou</div>
                                        <br>
                                        ______________________________<wbr>_________________
                                        <br>
                                        Qgis-user mailing list <br>
                                        <a moz-do-not-send="true">[hidden
                                          email]</a> <br>
                                        List info: <a
                                          moz-do-not-send="true"
                                          href="http://lists.osgeo.org/mailman/listinfo/qgis-user"
                                          target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-user</a><br>
                                        Unsubscribe: <a
                                          moz-do-not-send="true"
                                          href="http://lists.osgeo.org/mailman/listinfo/qgis-user"
                                          target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-user</a>
                                        <br>
                                        <br>
                                        <hr size="1">
                                        <div style="color:#444;font:12px
tahoma,geneva,helvetica,arial,sans-serif">
                                          <div style="font-weight:bold">If
                                            you reply to this email,
                                            your message will be added
                                            to the discussion below:</div>
                                          <a moz-do-not-send="true"
href="http://osgeo-org.1560.x6.nabble.com/Using-aggregates-functions-to-count-intersected-features-from-another-layer-tp5291420.html"
                                            target="_blank">http://osgeo-org.1560.x6.nabbl<wbr>e.com/Using-aggregates-functio<wbr>ns-to-count-intersected-featur<wbr>es-from-another-layer-tp529142<wbr>0.html</a></div>
                                        <div style="color:#666;font:11px
tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">To
                                          start a new topic under
                                          Quantum GIS - User, email <a
                                            moz-do-not-send="true">[hidden
                                            email]</a> <br>
                                          To unsubscribe from Quantum
                                          GIS - User, <a
                                            moz-do-not-send="true">click
                                            here</a>.<br>
                                          <a moz-do-not-send="true"
                                            style="font:9px serif"
href="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml"
                                            target="_blank">NAML</a></div>
                                      </div>
                                    </blockquote>
                                    <br>
                                    <hr align="left" width="300">View
                                    this message in context: <a
                                      moz-do-not-send="true"
href="http://osgeo-org.1560.x6.nabble.com/Using-aggregates-functions-to-count-intersected-features-from-another-layer-tp5291420p5291443.html"
                                      target="_blank">Re: Using
                                      aggregates functions to count
                                      intersected features from another
                                      layer</a><br>
                                    Sent from the <a
                                      moz-do-not-send="true"
href="http://osgeo-org.1560.x6.nabble.com/Quantum-GIS-User-f4125267.html"
                                      target="_blank">Quantum GIS - User
                                      mailing list archive</a> at
                                    Nabble.com.<br>
                                    <br>
                                  </div>
                                </div>
                                <div
class="m_1040782985649138824m_-566526819833031328m_-8854446165931069833pre"
style="margin:0;padding:0;font-family:monospace">______________________________<wbr>_________________<br>
                                  Qgis-user mailing list<br>
                                  <a moz-do-not-send="true"
                                    href="mailto:Qgis-user@lists.osgeo.org"
                                    target="_blank">Qgis-user@lists.osgeo.org</a><span><br>
                                    List info: <a
                                      moz-do-not-send="true"
                                      href="http://lists.osgeo.org/mailman/listinfo/qgis-user"
                                      target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-user</a><br>
                                    Unsubscribe: <a
                                      moz-do-not-send="true"
                                      href="http://lists.osgeo.org/mailman/listinfo/qgis-user"
                                      target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-user</a></span></div>
                              </blockquote>
                              <p> </p>
                              <div> </div>
                            </div>
                            <br>
                            ______________________________<wbr>_________________<br>
                            Qgis-user mailing list<br>
                            <a moz-do-not-send="true"
                              href="mailto:Qgis-user@lists.osgeo.org"
                              target="_blank">Qgis-user@lists.osgeo.org</a><br>
                            List info: <a moz-do-not-send="true"
                              href="http://lists.osgeo.org/mailman/listinfo/qgis-user"
                              target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-user</a><br>
                            Unsubscribe: <a moz-do-not-send="true"
                              href="http://lists.osgeo.org/mailman/listinfo/qgis-user"
                              target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-user</a></blockquote>
                        </div>
                      </div>
                    </blockquote>
                    <p> </p>
                    <div> </div>
                  </div>
                </div>
              </div>
              <br>
              ______________________________<wbr>_________________<br>
              Qgis-user mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
              List info: <a moz-do-not-send="true"
                href="http://lists.osgeo.org/mailman/listinfo/qgis-user"
                rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-user</a><br>
              Unsubscribe: <a moz-do-not-send="true"
                href="http://lists.osgeo.org/mailman/listinfo/qgis-user"
                rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/qgis-user</a><br>
            </blockquote>
          </div>
          <br>
          <br clear="all">
          <div><br>
          </div>
          -- <br>
          <div class="m_1040782985649138824gmail_signature"
            data-smartmail="gmail_signature">
            <div dir="ltr">
              <div>
                <div dir="ltr">
                  <div dir="ltr">
                    <div>-----------<br>
                    </div>
                    <div>   |\__  <br>
                      (:>__)(<br>
                         |/    <br>
                      Soluciones Geoinformáticas Libres                
                                 <br>
                      <a moz-do-not-send="true"
                        href="http://geotux.tuxfamily.org/"
                        target="_blank">http://geotux.tuxfamily.org/</a><br>
                      <a moz-do-not-send="true"
                        href="http://twitter.com/GeoTux2"
                        target="_blank">http://twitter.com/GeoTux2</a></div>
                    <div><a moz-do-not-send="true"
                        href="http://about.me/germancarrillo"
                        target="_blank">http://about.me/germancarrillo</a><br>
                    </div>
                    <div>
                      <div><br>
                      </div>
                      <div><a moz-do-not-send="true"
                          href="http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo"
                          target="_blank"><img moz-do-not-send="true"
                            src="http://gis.stackexchange.com/users/flair/4972.png"></a></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
    </blockquote>
    <br>
  </body>
</html>