<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi,</p>
    <p>I think the best way is too install Python with Anaconda.  Then,
      you will need to  install geopandas, networkX and possibly pandas
      and shapely libraries.  I am not sure it it's a good idea to add
      these in the Qgis Python distribution.</p>
    <p>My algorithm currently uses 1 line input file and 1 point input
      file. It would need to be modified to work with 2 point input
      files.<br>
    </p>
    <p>Nicolas<br>
    </p>
    <div class="moz-cite-prefix">On 2022-05-06 10:02 a.m., Francesca
      Parente wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAA8dZSe8WFnZwCBNYY93rKmSPEmz6-c1e5-XWW7s1YQ-3u=Kag@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Thank you very much indeed Nicolas, for your inputs and all
          the suggested materials!</div>
        <div>I have 50 targets and 532 origins. My goal is to define
          where is best to go within the 50 destinations for each
          starting point - given the actual range of choices though, so
          I'm not sure that running a batch one-to-many would take into
          account all the variables properly as a many-to-many would do.
          In the absence of a specific modelling, also some second best
          could work.</div>
        <div><br>
        </div>
        <div>I understand that your upstream-downstream-Dijkstra script
          is suitable for layer-to-layer indeed and I'm trying to run
          it, but at the >>> import geopandas as gpd<<
          line I got the following error message:</div>
        <div><br>
        </div>
        <i>Traceback (most recent call last):<br>
            File "C:\OSGEO4~1\apps\Python37\lib\code.py", line 90, in
          runcode<br>
              exec(code, self.locals)<br>
            File "<input>", line 1, in <module><br>
            File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line
          799, in _import<br>
              mod = _builtin_import(name, globals, locals, fromlist,
          level)<br>
        </i>
        <div><i>ModuleNotFoundError: No module named 'geopandas'</i></div>
        <div> </div>
        <div>I've been following your tutorial, but I admit I'm not
          quite familiar with py. I've gone through the remaining import
          coding and it seems working, but I'm not sure the "geopandas"
          module is needed or not to properly complete the script.</div>
        <div><br>
        </div>
        <div>Thanks again!!</div>
        <div>Best,</div>
        <div>Francesca</div>
        <br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">Il giorno gio 5 mag 2022
            alle ore 22:28 Nicolas Cadieux <<a
              href="mailto:njacadieux.gitlab@gmail.com"
              moz-do-not-send="true" class="moz-txt-link-freetext">njacadieux.gitlab@gmail.com</a>>
            ha scritto:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            <div dir="auto">
              <div dir="ltr">Hi,
                <div><br>
                </div>
                <div>How many shortest path calculations are you looking
                  at? You could probably do a all pairs shortest path
                  dijkstra and filter the results.  You could batch
                  multiple one to many (point to layers)  In QGIS using
                  the processing plug-in.</div>
                <div><br>
                </div>
                <div>I did create an algorithm using networkX that could
                  be modified to work with two input layers.  This could
                  be useful if QGIS is not fast enough or if you have
                  too many routes to calculate.  You will find it in the
                  links below. Keep in mind this algorithm was for
                  rivers therefore you have no trafic rules.  This would
                  need more work.</div>
                <div><br>
                </div>
                <div>You will also find an article we wrote in Data that
                  may help.  If you have trouble with the network, look
                  in the QGIS hub for the models. Look for the 3 “fix
                  directional networks models”.</div>
                <div><br>
                </div>
                <div>I added a few YouTube videos I made.</div>
                <div><br>
                </div>
                <div><a
href="https://gitlab.com/njacadieux/upstream_downstream_shortests_path_dijkstra"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">https://gitlab.com/njacadieux/upstream_downstream_shortests_path_dijkstra</a><a
                    href="https://www.mdpi.com/2306-5729/5/1/8"
                    target="_blank" moz-do-not-send="true"> </a></div>
                <div><br>
                </div>
                <div><a href="https://www.mdpi.com/2306-5729/5/1/8"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">https://www.mdpi.com/2306-5729/5/1/8</a></div>
                <div><br>
                </div>
                <div><a href="https://plugins.qgis.org/models/"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">https://plugins.qgis.org/models/</a></div>
                <div><br>
                </div>
                <div><a href="https://youtu.be/v61PafSByvM"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">https://youtu.be/v61PafSByvM</a></div>
                <div><br>
                </div>
                <div><a href="https://youtu.be/qQrHcKtmr3o"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">https://youtu.be/qQrHcKtmr3o</a></div>
                <div><br>
                </div>
                <div><br>
                  <div dir="ltr">Nicolas Cadieux
                    <div><a href="https://gitlab.com/njacadieux"
                        target="_blank" moz-do-not-send="true"
                        class="moz-txt-link-freetext">https://gitlab.com/njacadieux</a></div>
                  </div>
                  <div dir="ltr"><br>
                    <blockquote type="cite">Le 5 mai 2022 à 10:38,
                      Francesca Parente via Qgis-user <<a
                        href="mailto:qgis-user@lists.osgeo.org"
                        target="_blank" moz-do-not-send="true"
                        class="moz-txt-link-freetext">qgis-user@lists.osgeo.org</a>>
                      a écrit :<br>
                      <br>
                    </blockquote>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div dir="ltr">Hello everyone,
                        <div><br>
                        </div>
                        <div>I'd need to identify optimal destinations
                          (within a point layer of geolocated
                          facilities) for each territory of a given set
                          of possible origins. </div>
                        <div>I already calculated a distance matrix
                          between the two point-layers, and also applied
                          the distance-to-nearest-hub tool to generate a
                          string layer and identify the optimal
                          facilities.</div>
                        <div>But I'd like to obtain a more realistic
                          estimate, accounting for the roads network
                          (and ideally their travel times). With quite a
                          few issues, I finally managed to import an OSM
                          road network from <a
                            href="http://download.geofabrik.de"
                            target="_blank" moz-do-not-send="true">download.geofabrik.de</a>
                          (in order to cover my area of interest, I had
                          to merge two different vectors fo Center and
                          Southern Italy and then extract a focus spot
                          in between the two and save it as a lighter
                          layer, otherwise it also took an eternity to
                          run every analysis). <br>
                        </div>
                        <div><br>
                        </div>
                        <div>So now my question would be: is there a
                          tool to perform a layer-to-layer shortest-path
                          analysis that takes it into account? </div>
                        <div>All that I could find was either
                          point-to-point or
                          layer-to-point/point-to-layer (I looked also
                          at built-in network analysis tool and Qneat3
                          plugin).</div>
                        <div><br>
                        </div>
                        <div>Any kind of inputs and suggestions will be
                          more than welcome! </div>
                        <div>Thanks a lot for your support and have a
                          good day,</div>
                        <div>Francesca<br clear="all">
                          <div><br>
                          </div>
                          -- <br>
                          <div dir="ltr">
                            <div dir="ltr">
                              <div dir="ltr">
                                <div dir="ltr">
                                  <div dir="ltr">
                                    <div dir="ltr">
                                      <div dir="ltr">
                                        <div>----------------------------</div>
                                        <div><font face="monospace,
                                            monospace">Francesca Parente</font></div>
                                        <div><font face="monospace,
                                            monospace"><br>
                                          </font></div>
                                        <div><font size="1"
                                            face="monospace, monospace">_
                                            <a
                                              href="https://phd.uniroma1.it/web/FRANCESCA-PARENTE_nT1602922_IT.aspx"
                                              target="_blank"
                                              moz-do-not-send="true">SESS
                                              Euro PhD</a> in
                                            SocioEconomic and
                                            Statistical Studies</font></div>
                                        <div><font size="1"
                                            face="monospace, monospace">_
                                            <a
                                              href="https://sep.luiss.it/"
                                              target="_blank"
                                              moz-do-not-send="true">Luiss
                                              SEP</a> School of European
                                            Political Economy</font></div>
                                        <div><br>
                                        </div>
                                        <div><span
                                            style="font-family:monospace,monospace;font-size:x-small"><br>
                                          </span></div>
                                        <div><span
                                            style="font-family:monospace,monospace;font-size:x-small">email:
                                          </span><font color="#20124d"><a
href="mailto:francescaparente.rse@gmail.com"
                                              style="font-family:monospace,monospace;font-size:x-small"
                                              target="_blank"
                                              moz-do-not-send="true"
                                              class="moz-txt-link-freetext">francescaparente.rse@gmail.com</a><span
style="font-family:monospace,monospace;font-size:x-small"> <br>
                                            </span><font size="1"
                                              face="monospace">       <a
href="mailto:parentef@luiss.it" target="_blank" moz-do-not-send="true"
                                                class="moz-txt-link-freetext">parentef@luiss.it</a></font> </font></div>
                                        <div><br>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                      <span>_______________________________________________</span><br>
                      <span>Qgis-user mailing list</span><br>
                      <span><a href="mailto:Qgis-user@lists.osgeo.org"
                          target="_blank" moz-do-not-send="true"
                          class="moz-txt-link-freetext">Qgis-user@lists.osgeo.org</a></span><br>
                      <span>List info: <a
                          href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
                          target="_blank" moz-do-not-send="true"
                          class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></span><br>
                      <span>Unsubscribe: <a
                          href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
                          target="_blank" moz-do-not-send="true"
                          class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></span><br>
                    </div>
                  </blockquote>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div dir="ltr" class="gmail_signature">
          <div dir="ltr">
            <div dir="ltr">
              <div dir="ltr">
                <div dir="ltr">
                  <div dir="ltr">
                    <div dir="ltr">
                      <div>----------------------------</div>
                      <div><font face="monospace, monospace">Francesca
                          Parente</font></div>
                      <div><font face="monospace, monospace"><br>
                        </font></div>
                      <div><font size="1" face="monospace, monospace">_
                          <a
                            href="https://phd.uniroma1.it/web/FRANCESCA-PARENTE_nT1602922_IT.aspx"
                            target="_blank" moz-do-not-send="true">SESS
                            Euro PhD</a> in SocioEconomic and
                          Statistical Studies</font></div>
                      <div><font size="1" face="monospace, monospace">_
                          <a href="https://sep.luiss.it/"
                            target="_blank" moz-do-not-send="true">Luiss
                            SEP</a> School of European Political Economy</font></div>
                      <div><span
                          style="font-family:monospace,monospace;font-size:x-small"><br>
                        </span></div>
                      <div><span
                          style="font-family:monospace,monospace;font-size:x-small">email:
                        </span><font color="#20124d"><a
                            href="mailto:francescaparente.rse@gmail.com"
style="font-family:monospace,monospace;font-size:x-small"
                            target="_blank" moz-do-not-send="true"
                            class="moz-txt-link-freetext">francescaparente.rse@gmail.com</a><span
style="font-family:monospace,monospace;font-size:x-small"> <br>
                          </span><font size="1" face="monospace">       <a
                              href="mailto:parentef@luiss.it"
                              target="_blank" moz-do-not-send="true"
                              class="moz-txt-link-freetext">parentef@luiss.it</a></font> </font></div>
                      <div><br>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Nicolas Cadieux
<a class="moz-txt-link-freetext" href="https://gitlab.com/njacadieux">https://gitlab.com/njacadieux</a></pre>
  </body>
</html>