[GRASS-user] v.kernel -- how to get useful results

I am not clear how to get useful results out of v.kernel. I have a vector layer imported from PostGIS that has about 2.5 million points. I want to make a high density raster to show where these points are clustered. I can get the vector layer to display in GRASS just fine, albeit without attributes because of http://trac.osgeo.org/grass/ticket/1274.

It’s not clear to me, based on http://grass.fbk.eu/gdp/html_grass64/v.kernel.html, how you can get it to do something besides make a big, pinkish (salmon-red?) square?

Aren

Maybe I could clarify. Here’s the command:
v.kernel --verbose input=master_grass7 output=master_grass7a_heatmap stddeviation=.0001

Here’s the command output:

STDDEV: 0.000100
RES: 200.000000 ROWS: 1000 COLS: 1000

Writing output raster map using smooth parameter=0.000100.

Normalising factor=0.000000.
Maximum value in output: 0.000000e+000.

If I change stddeviation to 100, here’s what I get:

STDDEV: 100.000000
RES: 200.000000 ROWS: 1000 COLS: 1000

Writing output raster map using smooth parameter=100.000000.

Normalising factor=64826.350188.
Maximum value in output: 0.000000e+000.

Either way, the resulting raster is a large salmon/pink square. I have no idea what I’m doing wrong. I’ve tried varying the stddeviation parameter from 100 to .0001 and some values in between, and I don’t get anything different. Heck, I just now used 1000000 and .000001 and got nothing different.

I was really hoping to make a high res heat map of these 2.5 million points and overlay on to a street map layer.

Aren

On Fri, Feb 11, 2011 at 9:45 PM, Aren Cambre <aren@arencambre.com> wrote:

I am not clear how to get useful results out of v.kernel. I have a vector layer imported from PostGIS that has about 2.5 million points. I want to make a high density raster to show where these points are clustered. I can get the vector layer to display in GRASS just fine, albeit without attributes because of http://trac.osgeo.org/grass/ticket/1274.

It’s not clear to me, based on http://grass.fbk.eu/gdp/html_grass64/v.kernel.html, how you can get it to do something besides make a big, pinkish (salmon-red?) square?

Aren

I am not getting any responses. :slight_smile: Am I doing something really dumb? Is this the right forum for this kind of question?

Thanks,

Aren

On Sun, Feb 13, 2011 at 8:02 AM, Aren Cambre <aren@arencambre.com> wrote:

Maybe I could clarify. Here’s the command:
v.kernel --verbose input=master_grass7 output=master_grass7a_heatmap stddeviation=.0001

Here’s the command output:

STDDEV: 0.000100
RES: 200.000000 ROWS: 1000 COLS: 1000

Writing output raster map using smooth parameter=0.000100.

Normalising factor=0.000000.
Maximum value in output: 0.000000e+000.

If I change stddeviation to 100, here’s what I get:

STDDEV: 100.000000
RES: 200.000000 ROWS: 1000 COLS: 1000

Writing output raster map using smooth parameter=100.000000.

Normalising factor=64826.350188.
Maximum value in output: 0.000000e+000.

Either way, the resulting raster is a large salmon/pink square. I have no idea what I’m doing wrong. I’ve tried varying the stddeviation parameter from 100 to .0001 and some values in between, and I don’t get anything different. Heck, I just now used 1000000 and .000001 and got nothing different.

I was really hoping to make a high res heat map of these 2.5 million points and overlay on to a street map layer.

Aren

On Fri, Feb 11, 2011 at 9:45 PM, Aren Cambre <aren@arencambre.com> wrote:

I am not clear how to get useful results out of v.kernel. I have a vector layer imported from PostGIS that has about 2.5 million points. I want to make a high density raster to show where these points are clustered. I can get the vector layer to display in GRASS just fine, albeit without attributes because of http://trac.osgeo.org/grass/ticket/1274.

It’s not clear to me, based on http://grass.fbk.eu/gdp/html_grass64/v.kernel.html, how you can get it to do something besides make a big, pinkish (salmon-red?) square?

Aren

Aren Cambre :

I am not getting any responses. :slight_smile: Am I doing something really dumb? Is
this the right forum for this kind of question?

This should be the right kind of forum, but maybe nobody has an idea
about what could be wrong.

Just a guess: maybe no points of the input vector fall into the
current region that is used to write the output raster map?

Markus M

Thanks,
Aren

On Sun, Feb 13, 2011 at 8:02 AM, Aren Cambre <aren@arencambre.com> wrote:

Maybe I could clarify. Here's the command:
v.kernel --verbose input=master_grass7 output=master_grass7a_heatmap
stddeviation=.0001
Here's the command output:
STDDEV: 0.000100
RES: 200.000000 ROWS: 1000 COLS: 1000
Writing output raster map using smooth parameter=0.000100.
Normalising factor=0.000000.
Maximum value in output: 0.000000e+000.
If I change stddeviation to 100, here's what I get:
STDDEV: 100.000000
RES: 200.000000 ROWS: 1000 COLS: 1000
Writing output raster map using smooth parameter=100.000000.
Normalising factor=64826.350188.
Maximum value in output: 0.000000e+000.
Either way, the resulting raster is a large salmon/pink square. I have no
idea what I'm doing wrong. I've tried varying the stddeviation parameter
from 100 to .0001 and some values in between, and I don't get anything
different. Heck, I just now used 1000000 and .000001 and got nothing
different.
I was really hoping to make a high res heat map of these 2.5 million
points and overlay on to a street map layer.
Aren

On Fri, Feb 11, 2011 at 9:45 PM, Aren Cambre <aren@arencambre.com> wrote:

I am not clear how to get useful results out of v.kernel. I have a vector
layer imported from PostGIS that has about 2.5 million points. I want to
make a high density raster to show where these points are clustered. I can
get the vector layer to display in GRASS just fine, albeit without
attributes because of http://trac.osgeo.org/grass/ticket/1274.
It's not clear to me, based
on http://grass.fbk.eu/gdp/html_grass64/v.kernel.html, how you can get it to
do something besides make a big, pinkish (salmon-red?) square?
Aren

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Aren Cambre wrote:

I am not getting any responses. :slight_smile: Am I doing something really dumb? Is
this the right forum for this kind of question?

Thanks,

Aren

On Sun, Feb 13, 2011 at 8:02 AM, Aren Cambre <aren@arencambre.com> wrote:

Maybe I could clarify. Here's the command:
*v.kernel --verbose input=master_grass7 output=master_grass7a_heatmap
stddeviation=.0001*

Here's the command output:
*STDDEV: 0.000100*
*RES: 200.000000 ROWS: 1000 COLS: 1000*
*
*
*Writing output raster map using smooth parameter=0.000100.*
*
*
*Normalising factor=0.000000.*
*Maximum value in output: 0.000000e+000.*

If I change stddeviation to *100*, here's what I get:
*STDDEV: 100.000000*
*RES: 200.000000 ROWS: 1000 COLS: 1000*
*
*
*Writing output raster map using smooth parameter=100.000000.*
*
*
*Normalising factor=64826.350188.*
*Maximum value in output: 0.000000e+000.*

Either way, the resulting raster is a large salmon/pink square. I have no
idea what I'm doing wrong. I've tried varying the *stddeviation
*parameter
from 100 to .0001 and some values in between, and I don't get anything
different. Heck, I just now used 1000000 and .000001 and got nothing
different.

I was really hoping to make a high res heat map of these 2.5 million
points
and overlay on to a street map layer.

Aren

On Fri, Feb 11, 2011 at 9:45 PM, Aren Cambre <aren@arencambre.com> wrote:

I am not clear how to get useful results out of v.kernel. I have a
vector
layer imported from PostGIS that has about 2.5 million points. I want to
make a high density raster to show where these points are clustered. I
can
get the vector layer to display in GRASS just fine, albeit without
attributes because of http://trac.osgeo.org/grass/ticket/1274.

It's not clear to me, based on
http://grass.fbk.eu/gdp/html_grass64/v.kernel.html, how you can get it
to
do something besides make a big, pinkish (salmon-red?) square?

Aren

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hey,

I had tried playing around with v.random and v.kernel to see if I could
understand your problem, but I couldn't find any solutions so I didn't post
it. But since you got upset with GRASS community, I will share what I found
out anyway :slight_smile:

I tried with different numbers of points and with different resolutions and
I was amazed that you could make v.kernel work with 2.5 million points in a
200 meter resolution with a 1000000 stdeviation!! My quadcore computer took
so much that I gave up.

I noticed that it goes slower with increasing resolution, increasing number
of points and increasing stdev. I also noticed that you have to set a much
higher stdev for smaller resolutions and that this value is by no means
intuitive.

For instance: for my 2.5 meter resolution, I got meaningful results for
1,000 points using a stdev of 30. However, this same 30 stdev in my 1,000
resolution region gives me the "salmon/pink" square. So, in this case, a
10,000 stdev begins to give me good results.

So, my humble opinion is that you should try stdevs greater than 100, but
still much smaller than 1,000,000. I believe that it is just a matter of
tuning these parameters with respect to your resolution and number of
points.

Hope this helps (or at least, keep you in the list :slight_smile: )

Marcello.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/v-kernel-how-to-get-useful-results-tp6018010p6027287.html
Sent from the Grass - Users mailing list archive at Nabble.com.

I had tried playing around with v.random and v.kernel to see if I could
understand your problem, but I couldn’t find any solutions so I didn’t post
it. But since you got upset with GRASS community, I will share what I found
out anyway :slight_smile:

Sorry, I am not upset!! :slight_smile: I was genuinely wondering if I didn’t describe my problem correctly or if I had posted to the wrong forum.

I tried with different numbers of points and with different resolutions and
I was amazed that you could make v.kernel work with 2.5 million points in a
200 meter resolution with a 1000000 stdeviation!! My quadcore computer took
so much that I gave up.

Something must not be right with what I’m doing because, no matter how I skewed the options, it took less than 200 seconds to run on my 4 year old 1.6 GHz Intel Core Duo M processor (i.e., slow).

I noticed that it goes slower with increasing resolution, increasing number
of points and increasing stdev. I also noticed that you have to set a much
higher stdev for smaller resolutions and that this value is by no means
intuitive.

Where is resolution adjusted? http://grass.fbk.eu/gdp/html_grass64/v.kernel.html doesn’t make that clear. Am I supposed to have a pre-made raster layer already that corresponds to my vector layer?

Hope this helps (or at least, keep you in the list :slight_smile: )

I really appreciate your advice! I’m not upset with the list, was just afraid this was too esoteric or poorly stated.

Aren

Aren said:
Where is resolution adjusted?
http://grass.fbk.eu/gdp/html_grass64/v.kernel.html doesn't make that clear.

GRASS works with the region concept. You can adjust any region settings with
the command g.region, like:

g.region res=desired_resolution -p

The -p is for you to see the resulting changes.

Am I supposed to have a pre-made raster layer already that corresponds to

my

vector layer?

No, you probably don't. I would suggest you play around with v.random to
create some random points and then use v.kernel to make the heat map. Do
that with different number points, stdev and resolutions to get the feel of
it.

Maybe in this way you will understand what is going on with your specific
case.

I really appreciate your advice!

Any time! Sorry not to help you more.

I'm not upset with the list, was just afraid this was too esoteric or

poorly stated.

I think I myself have been a little upset a few times when I did not get any
responses to my querries :slight_smile: that's why I mentioned, I guess. But I from
Brazil, so either I get upset or I get really happy :slight_smile:

Cheers,
Marcello.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/v-kernel-how-to-get-useful-results-tp6018010p6028684.html
Sent from the Grass - Users mailing list archive at Nabble.com.

As soon as a raster map is accessed as input or output, the current
region settings are used (for most modules) as the extents and
resolution for any raster operations.

If I have a GRASS vector map that is simply an import of PostGIS points (no attributes), is the region not the same as the entire map?

I looked over the g.region command, and I’m not clear how one gets from defining a region to v.kernel. v.kernel’s documentation (http://grass.fbk.eu/gdp/html_grass64/v.kernel.html) is not clear on this point, and it appears that it just takes a vector map as input? Although, that being said, I’m confused about the input and net parameters. Is input actually a region and net actually the vector map?

Also, how do I even define a region in the first place? Can I draw it using the map display? Or do I need to write down the coordinates as I hover my mouse over the NW and SE extents of the area of the vector I want to focus on?

In this case it may or may not desirable to run v.kernel on the whole
vector map, e.g. if you want to try different settings, rather use a
smaller region that covers only parts of the vector. Once you’re happy
with the results, you can expand the region to cover the whole vector
with
g.region vect=<name_of_my_vector> -p

When you say “the vector”, is this some other vector map besides the map with my 2 million points?

Thanks for your help on this!

Aren

Thanks.

I did this:
v.random output=random_vector n=10000

Then I ran this:
v.kernel --verbose input=random_vector output=random_vector_heatmap stddeviation=1

That just made a large yellow square. So I changed stddeviation to 100 and got a yellow square speckled with teal and dark blue pixels after 7 seconds. Then I changed it to 1000, and after 232(!) seconds, I got something that actually resembles a heat map!

It appears the random_vector map is 100000x100000 units, so I can see why 1000 is necessary to get a reasonable map.

I then ran r.info map=random_vector@de_maps and got this (cut down to key data):

Type of Map: vector (level: 2)

Number of points: 10000

Projection: Lambert Conformal Conic
N: 100000


S: -99975.58519242

E: 99987.79259621
W: -99975.58519242

That looks like it’s around 200000x200000 units?

So I ran v.info map=master_grass7@de_maps on my original vector data and got this key data:

Type of Map: vector (level: 2)
Number of points: 2057980

Projection: Lambert Conformal Conic
N: 2781558.27080444
S: 422254.4557289
E: 12145354.2426632
W: 767479.81703687

I went back to the Map Display window for this vector and noticed that about all I am interested in is a box bounded by 1269430.31,1210876.00 on the NW side and 1325045.16,1164615.03 on the SE side. Does this mean I should define a region with this as the bounding box, then re-run v.kernel and hope it works on just that region?

Aren

On Tue, Feb 15, 2011 at 12:15 PM, Marcello Gorini <gorini@gmail.com> wrote:

Aren said:
Where is resolution adjusted?
http://grass.fbk.eu/gdp/html_grass64/v.kernel.html doesn’t make that clear.

GRASS works with the region concept. You can adjust any region settings with
the command g.region, like:

g.region res=desired_resolution -p

The -p is for you to see the resulting changes.

Am I supposed to have a pre-made raster layer already that corresponds to
my
vector layer?

No, you probably don’t. I would suggest you play around with v.random to
create some random points and then use v.kernel to make the heat map. Do
that with different number points, stdev and resolutions to get the feel of
it.

Maybe in this way you will understand what is going on with your specific
case.

I really appreciate your advice!

Any time! Sorry not to help you more.

I’m not upset with the list, was just afraid this was too esoteric or
poorly stated.

I think I myself have been a little upset a few times when I did not get any
responses to my querries :slight_smile: that’s why I mentioned, I guess. But I from
Brazil, so either I get upset or I get really happy :slight_smile:

Cheers,
Marcello.


View this message in context: http://osgeo-org.1803224.n2.nabble.com/v-kernel-how-to-get-useful-results-tp6018010p6028684.html

Sent from the Grass - Users mailing list archive at Nabble.com.


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Aren Cambre wrote:

As soon as a raster map is accessed as input or output, the current
region settings are used (for most modules) as the extents and
resolution for any raster operations.

If I have a GRASS vector map that is simply an import of PostGIS points (no
attributes), is the region not the same as the entire map?

No, the region is independently controlled through g.region. When you
import something (raster or vector), the region is by default not
changed. See the corresponding manual pages:
http://grass.osgeo.org/grass64/manuals/html64_user/rasterintro.html
http://grass.osgeo.org/grass64/manuals/html64_user/g.region.html

I looked over the g.region command, and I'm not clear how one gets from
defining a region to v.kernel.

g.region vect=<name_of_a_points_vector> res=200 -a -p

The -a flag aligns the region to the resolution, the -p flag prints
the resulting region.

v.kernel's documentation
(http://grass.fbk.eu/gdp/html_grass64/v.kernel.html) is not clear on this
point, and it appears that it just takes a vector map as input? Although,
that being said, I'm confused about the input and net parameters. Is
input actually a region and net actually the vector map?

Input is always a vector map with points, net is an optional input
vector map with lines for a network, e.g. if you want densities of
road accidents along a road network and not per grid cell.

Also, how do I even define a region in the first place? Can I draw it using
the map display? Or do I need to write down the coordinates as I hover my
mouse over the NW and SE extents of the area of the vector I want to focus
on?

I hope the above description is clear. Alternatively you can also set
the bounds and resolutions manually with g.region -p n= s= e= w=
nsres= ewres=

In this case it may or may not desirable to run v.kernel on the whole
vector map, e.g. if you want to try different settings, rather use a
smaller region that covers only parts of the vector. Once you're happy
with the results, you can expand the region to cover the whole vector
with
g.region vect=<name_of_my_vector> -p

When you say "the vector", is this some other vector map besides the map
with my 2 million points?

I referred to your vector map with 2 million points.

Markus M

Input is always a vector map with points, net is an optional input
vector map with lines for a network, e.g. if you want densities of
road accidents along a road network and not per grid cell.

Thank you for this explanation. Are these just GRASS conventions, or are they specific to v.kernel?

Aren

Aren Cambre wrote:

Input is always a vector map with points, net is an optional input
vector map with lines for a network, e.g. if you want densities of
road accidents along a road network and not per grid cell.

Thank you for this explanation. Are these just GRASS conventions, or are
they specific to v.kernel?

Each GRASS module has its own options. See e.g. manuals for vector modules:
http://grass.osgeo.org/grass64/manuals/html64_user/vector.html