Skip to main content

Timeline for Gravity/Huff model tools

Current License: CC BY-SA 3.0

11 events
when toggle format what by license comment
Jan 30, 2013 at 11:52 history edited Jake CC BY-SA 3.0
Added check for correct argument layer types
Jan 30, 2013 at 11:31 vote accept Damien
Jan 30, 2013 at 9:53 comment added Damien @Jake: Ok, I think I start understanding how the console works. I did as you said and the code seems to be understood properly. Now I have another error that relates to a python package "shape_base.py". Does my QGIS install lacks some features? http://i.imgur.com/TT0i2Cl.png
Jan 30, 2013 at 9:03 comment added Damien @Jake: Thanks for the precision! I did as you said, but the console keeps telling me I have a syntax error. I think my mistake is somewhere in the second chunk of code, possibly in identifying the layers to take into account. Can you tell me what I am doing wrong? http://i.imgur.com/0wSs7OZ.png (I changed the name of my layers to avoid conflicting names and for clarity).
Jan 30, 2013 at 8:30 comment added Damien Thanks a lot, this looks like what I need. Just a problem, I am not so used to python and I never used Rasterlang extension. I Installed it on my QGIS version, but I am stuck with a "syntax error". Is your function already implemented in the rasterlang extension? If no, how do I do that? Thanks for you help! http://i.imgur.com/NhiAe9p.png
Jan 29, 2013 at 20:43 history edited Jake CC BY-SA 3.0
Added whubers second improvement
Jan 29, 2013 at 20:11 comment added whuber Jake, you still never need the square root: just forget about it altogether and use half the intended exponent. In other words, if z is the sum of squares of coordinate differences, instead of computing (sqrt(z))^p, which is two moderately expensive operations, just compute z^(p/2), which (because p/2 is a precomputed number) is just one raster operation--and leads to clearer code, too. This idea comes to fore when you apply gravitational models as they were originally intended: to travel times. There no longer is any square root formula, so you raise the travel time to the -p/2 power.
Jan 29, 2013 at 19:29 history edited Jake CC BY-SA 3.0
Wrapped code in a proper function, implemented whubers suggestions.
Jan 29, 2013 at 18:32 comment added lynxlynxlynx Doesn't that square the whole fraction?
Jan 29, 2013 at 18:02 comment added whuber (+1) The approach looks good. But why do you take the square root and then re-square it in computing curGravity? That's a waste of computational time. Another wasted set of calculations involves normalizing all the "gravity" grids before finding the max: instead, find their max and normalize that by the sum.
Jan 29, 2013 at 17:51 history answered Jake CC BY-SA 3.0