<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
  </head>
  <body bidimailui-charset-is-forced="true" text="#000000"
    bgcolor="#FFFFFF">
    <br>
    <br>
    <div class="moz-cite-prefix">On 28/10/2019 14:08, Taïs wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:536850e7-558f-5a53-eb98-b7a5b60e33c9@ulb.ac.be">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Hi Micha, Moritz, <br>
      </p>
      <p><br>
      </p>
      <p>I successfully create the kernel density raster. Thanks a lot
        for your support ;)</p>
      <p>I tried with ~62.000 points on a computational region of +-
        1000 cols by 1000 rows, with 10 m. spatial resolution. </p>
    </blockquote>
    <p>How long was the processing? <br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:536850e7-558f-5a53-eb98-b7a5b60e33c9@ulb.ac.be">
      <p> </p>
      <p><br>
      </p>
      <p>FYI, I had to change the type of the weights column from
        "double precision" to "integer" because I had this error message
        when it was on double precision:</p>
    </blockquote>
    <p>I'll have to think about how to handle that...</p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:536850e7-558f-5a53-eb98-b7a5b60e33c9@ulb.ac.be">
      <p> </p>
      <p><i><font size="-1">Error in matrix(rep(w, n[1]), nrow = n[1],
            ncol = nx, byrow<br>
            = TRUE) *  :<br>
              non-numeric argument to binary operator<br>
            Calls: sp.kde -> fhat<br>
          </font></i></p>
      <p><br>
      </p>
      <p>Taïs<br>
      </p>
      <p><br>
      </p>
      <div class="moz-cite-prefix">Le 25/10/19 à 13:36, Micha Silver a
        écrit :<br>
      </div>
      <blockquote type="cite"
        cite="mid:3124640f-bf1f-db2e-7477-1f65913dc956@gmail.com">
        <meta http-equiv="Content-Type" content="text/html;
          charset=UTF-8">
        <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
        <p><font face="Helvetica, Arial, sans-serif">Hi </font>Taïs</p>
        <p><br>
        </p>
        <p>Thanks for testing. </p>
        <p>As Moritz mentioned, the important parameter in spatial
          kernel density is the bandwidth.</p>
        <p>Here attached is an improved script that uses the spatialEco
          R package (instead of density.ppp from spatstat). To run this,
          you'll need to install spatialEco in your R environment.</p>
        <p><br>
        </p>
        <p>This package allows to specify both the bandwidth and the
          target raster extents and resolution. In this script I take
          the extents and resolution from the GRASS region. Bandwidth is
          specified on the command line.</p>
        <p>So to try this, in your running GRASS session:</p>
        <p><br>
        </p>
        <p>Rscript kernel_density.R <GRASS point vector>
          <weight column> <bandwidth></p>
        <p><br>
        </p>
        <p>I also attached two images in a test I did, with bandwidths
          of 10,000 and 20,000.</p>
        <p><br>
        </p>
        <p>Hope this helps,</p>
        <p>Micha</p>
        <p><br>
        </p>
        <div class="moz-cite-prefix">On 10/25/19 12:17 PM, Taïs wrote:<br>
        </div>
        <blockquote type="cite"
          cite="mid:62f305e5-46c9-20c0-3ca0-de15f9ecae09@ulb.ac.be">
          <meta http-equiv="Content-Type" content="text/html;
            charset=UTF-8">
          <p>Hi Micha, <br>
          </p>
          <p><br>
          </p>
          <p>I successfully run your R script. However to output is
            weird and I don't know how to fix it. <br>
          </p>
          <p>In v.kernel, you can setup the "raduis" parameter to
            control what I assume to be the size of the kernel (of the
            moving window). I made one test with radius=300 and another
            with value 3000. The result of the first is more what I
            would expect in terms of spatial variability. <br>
          </p>
          <p><br>
          </p>
          <p>When I try your script, the output raster has a size of
            128x128 which did not correspond at all to my computational
            region, and thus the resolution is not the same as the one
            defined in the computational region. <br>
          </p>
          <p><br>
          </p>
          <p>The other thing is that I'm wondering if it is possible to
            control the size of the moving window with the "density"
            function in R. I already tried the 'n' parameter but it
            doesn't change anything.. <br>
          </p>
          <p><br>
          </p>
          <p>I also tried with real weights (the number of inhabitants)
            and a unity weighting (value 1 for all points) to see it
            there is a change and there is which proof the weights
            affect the output :)<br>
          </p>
          <p><br>
          </p>
          <div class="moz-cite-prefix">Le 22/10/19 à 13:41, Micha Silver
            a écrit :<br>
          </div>
          <blockquote type="cite"
            cite="mid:305dc7c9-9b5d-cd22-2c1c-303dafdb15f2@gmail.com">
            <meta http-equiv="Content-Type" content="text/html;
              charset=UTF-8">
            <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
            <p>Here is the script.</p>
            <p>Let me know how it goes. (I might try to take time to
              make it into a GRASS addon)</p>
            <p><br>
            </p>
            <div class="moz-cite-prefix">On 10/22/19 2:33 PM, Taïs
              wrote:<br>
            </div>
            <blockquote type="cite"
              cite="mid:d40a1138-065b-98f1-2f44-bf86f9a3ce7a@ulb.ac.be">
              <meta http-equiv="Content-Type" content="text/html;
                charset=UTF-8">
              <p>Hi Micha, thanks for your repply.<br>
              </p>
              <p><br>
              </p>
              <p>For my own need, I think your solution is enough and I
                would like to try if you agree to send the R script. <br>
              </p>
              <p><br>
              </p>
              <p><br>
              </p>
              <div class="moz-cite-prefix">Le 22/10/19 à 12:53, Micha
                Silver a écrit :<br>
              </div>
              <blockquote type="cite"
                cite="mid:72bfdf77-6ba0-d4ad-7070-c691c0c08338@gmail.com">
                <meta http-equiv="Content-Type" content="text/html;
                  charset=UTF-8">
                <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
                <br>
                <div class="moz-cite-prefix">On 10/21/19 1:33 PM, Tais
                  wrote:<br>
                </div>
                <blockquote type="cite"
                  cite="mid:d581c296-ec9e-b2a1-7733-45722647afa2@ulb.ac.be">Hi
                  all, <br>
                  <br>
                  I would like to compute a raster density map ("heat
                  map") from vector points using v.kernel. The points
                  represent house addresses. However, I would need to
                  weight the points with a value stored in the attribute
                  table (number of inhabitants). I saw on the module
                  manual page that this functionality is a "known
                  issue". <br>
                  <br>
                  I imagined a solution to by-passe the limitation:
                  duplicate each point as many time as needed (according
                  to the value stored in the attribute table) and use
                  this new layer directly in v.kernel. However, I think
                  it will definitely not be the most efficient way to do
                  the trick. Do you have an alternative in mind ? <br>
                  <br>
                  Of course the best solution would be that someone in
                  the development community would have the time and the
                  kindness to implement this function directly in the
                  module (I'm not skilled in C and thus cannot try
                  myself). <br>
                  <br>
                </blockquote>
                <p><br>
                </p>
                <p>Maybe not the answer you are looking for, but you can
                  create a weighted kernel density in R. I can send an R
                  script that is intended to be run from within a GRASS
                  session. It accepts a point vector and attrib column,
                  and creates a kernel density raster, weighted by the
                  attribute values (using the R defaults for bandwidth
                  and Gaussian kernel)</p>
                <p>Requires, of course, that R is installed, with the
                  packages: spatstat, raster, rgrass7.<br>
                </p>
                <p><br>
                </p>
                <blockquote type="cite"
                  cite="mid:d581c296-ec9e-b2a1-7733-45722647afa2@ulb.ac.be">NB:
                  Sorry if I should have posted this on the developer
                  mailing list. I hesitated but decided to post here
                  finally. <br>
                  <br>
                  Best, <br>
                  <br>
                </blockquote>
                <pre class="moz-signature" cols="72">-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
              </blockquote>
            </blockquote>
            <pre class="moz-signature" cols="72">-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
          </blockquote>
        </blockquote>
        <pre class="moz-signature" cols="72">-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
      </blockquote>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
+972-523-665918</pre>
  </body>
</html>