Coder Social home page Coder Social logo

heatmap's People

Contributors

jjguy avatar jjwtimmer avatar llonchj avatar martinmreed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

heatmap's Issues

Add python3 support

Have a fork based on work from @mpern port to python3 but with the latest code base.

Changes include map as iter, subscript in lambda functions, print as a function and Exception syntax. All of these have been back ported and are compatible with 2.6 and 2.7. Current travis ci build succeeds on 2.6,2.7,3.2,3.3,3.4.

hm = heatmap.Heatmap()

Hi there,

I'm new to python but I saw your module for GoogleEarth and really really want to use it. I've managed to install the module but am struggling to complete the examples. I just have a few quick questions and I would really appreciate any kind of help or advice for how to get the .kml output to display.
These first two parts work fine:

import heatmap
import random

then i get to

hm = heatmap.Heatmap()

and I get the error message "WindowsError: [Error 126] The specified module could not be found"

From looking around online apparently there could be an issue with the location of the .dll? I also saw there was a previous issue dealing with "from heatmap import Heatmap"...is that related?

Honestly I'm not even sure if I should be working in the windows command line or in IDLE.

I really think this module can do exactly what I need (creating a crime density overlay) so I'm not ready to give up. Help please!

input data with many points saturate output image

In the current implementation, each input point is directly translated into an image of DOTSIZE pixels and blended in. If there are a large number of points relative to the chosen dotsize and image resolution, the output image is completely saturated.

Weighted Heatmap

Hi there,

Great tool, thanks a lot for it. Because I needed "weighted heatmaps" support (the possibility to add "cold" points but also the possibility to specify the dot size for each point), I have forked your project (https://github.com/wrousseau/heatmap).

Two things :

  • It's a quick hack, would you be interested in such feature for a merge ?
  • I think the only thing a bit dodgy I did is for the blending in "calcDensity". I obviously could not used your formula to compute pixel values, so I added my own but I'm not quite satisfied with the visual result. The formula I use is a result of several tries, but there is no theory behind that. If you have a better idea, I'm a taker !

Cheers

WindowsError: [Error 126] The specified module could not be found

Hi there,

I'm new to python but I saw your module for GoogleEarth and really really want to use it. I've managed to install the module but am struggling to complete the examples. I just have a few quick questions and I would really appreciate any kind of help or advice for how to get the .kml output to display.
These first two parts work fine:

import heatmap
import random

then i get to

hm = heatmap.Heatmap()

and I get the error message "WindowsError: [Error 126] The specified module could not be found"

From looking around online apparently there could be an issue with the location of the .dll? I also saw there was a previous issue dealing with "from heatmap import Heatmap"...is that related?

Honestly I'm not even sure if I should be working in the windows command line or in IDLE.

I really think this module can do exactly what I need (creating a crime density overlay) so I'm not ready to give up. Help please!

Area bounding box issue

Hi,

great heatmap program and have it working nicely. I have a set of points scattered over DC and everything works great when I don't specify area=((minx,miny),(maxx,maxy)).

What I get when I do use the area = piece is that the y coord (latitute) is scrunched and I cant really seem to fix it. I have tried messing with the size parameter at the same time. Is the solution to convert all my input coordinates to a projected system first? The coordinates in my csv are all wgs 84 geo coordinates - so i thought to specify the min/max coordinates in the same way.

Sample output without area restriction (image1) and with (image2) attached, plus code.

any help appreciated. Again - great that you produced this and very helpful.
Code (with area restriction) below - same code used without area produces image1.

import heatmap # http://jjguy.com/heatmap/
import csv

hm = heatmap.Heatmap()
if __name__ == "__main__":
    pts = []
    for point in csv.reader(open("coordinates.csv")):
        pts.append((float(point[0]), float(point[1])))
    print "Processing %d points..." % len(pts)
    hm.heatmap(pts,dotsize=110,opacity=500,scheme='fire', area=((-77.11656,38.80644),(-76.909515,38.89307))).save("image2.png")

image1
image2

setup.py does not specify dependencies suitable for pip / easy_install

Running easy_install heatmap should also install PIL / Pillow if it's not already on the system. As currently written, it's not.

[root@localhost pip-1.2.1]# easy_install heatmap
Searching for heatmap
Reading http://pypi.python.org/simple/heatmap/
Reading http://jjguy.com/heatmap/
Best match: heatmap 2.2.1
Downloading http://jjguy.com/heatmap/heatmap-2.2.1.zip
Processing heatmap-2.2.1.zip
Running heatmap-2.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-NqLtUD/heatmap-2.2.1/egg-dist-tmp-RMyYR1
zip_safe flag not set; analyzing archive contents...
Adding heatmap 2.2.1 to easy-install.pth file

Installed /usr/lib/python2.6/site-packages/heatmap-2.2.1-py2.6-linux-x86_64.egg
Processing dependencies for heatmap
Finished processing dependencies for heatmap
[root@localhost pip-1.2.1]# python
Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23) 
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import heatmap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/heatmap-2.2.1-py2.6-linux-x86_64.egg/heatmap/__init__.py", line 6, in <module>
    from heatmap import Heatmap
  File "/usr/lib/python2.6/site-packages/heatmap-2.2.1-py2.6-linux-x86_64.egg/heatmap/heatmap.py", line 9, in <module>
    from PIL import Image
ImportError: No module named PIL
>>> 

SaveKML bounding box issue

SaveKML incorrectly computes the east/west boundaries from the data set when no area is specified when calling heatmap().

To reproduce, create any dataset with a wide range of longitude points (like -160 to 160) and create the KML file without specifying any area in the heatmap() function. When displaying the set in google maps with a kml overlay, the heatmap should display from west = -160 to east = 160. Instead, the heatmap displays from west = 160 to east = -160, which is a very narrow part of the map.

The KML file does correctly display in google earth as intended. However, to make the KML file also useable in Google Maps, west should be set as minX and east should be set as maxX. Switching these values does not break the display of the KML in Google Earth.

Multithreading overwrites global variables

Thanks for providing this library.

I am running this from web.py for creating map tiles. In order to get a full dot to span multiple tiles I have to include that point on each tile that displays any part of the dot. So some dots are drawn outside of the 'area'. Thats all fine and working, however I noticed that sometimes a part of a dot is duplicated on two tiles. Its not reproducible every time, so that makes me believe it is a timing/threading issue. I believe this is caused by having the 'area' variables as global instead of encapsulated in a struct so they are local to the method and not the whole shared lib.

After moving all of the global variables to a struct I am no longer seeing this issue.

Below is an example of what I mean by duplicated. The dots in the green squares are expected. The others are duplicates.

img_2973

One dot with custom opacity

I'm trying to create a KML file with a dot with custom opacity for the heatmap.
The dots opacity/strength will warry on my gps signal strength.
I also know the exact lat, lon and alt.

Can you send me an example code?

calculate bounding box for geo maps

whats the best way to calculate the bounding box for a heatmap of geo points (lng/lat)?
The auto calculated way cuts off the circles at the edges of the image...

pip and easy_install fail

Hi! I get a setup error when installing with either easy_install or pip:
$pip install heatmap
Downloading/unpacking heatmap
Downloading heatmap-2.2.tar.gz
Running setup.py egg_info for package heatmap
error in heatmap setup command: test_suite must be a string
Complete output from command python setup.py egg_info:
error in heatmap setup command: test_suite must be a string


Command python setup.py egg_info failed with error code 1 in /var/folders/1j/lkx2dg7d7tn6f4t4c6lwmt9r0000gq/T/pip-build/heatmap

saveKML only works in north western hemisphere

saveKML() assumes:

  • the inputs are a set of a (latitude, longitude) coordinates.
  • the minimum latitude is east
  • the maximum latitude is west
  • the minimum longitude is south
  • the maximum longitude is north

These assumptions are only valid in the north western hemisphere. I'm not a GIS guy, but AFAICT, the canonical mechanism to eliminate assumptions is to include N/S and E/W indicators with the coordinate that specifies which hemisphere the coordinate is from.

saveKML needs a mechanism to distinguish; perhaps a second argument that is one of ["NW", "NE", "SW", "SE"].

Thanks to Stephen M for the bug report

WindowsError: [Error 193] %1 is not a valid Win32 application

Hello.

This library seems to be exactly what I am looking for. However I have come across a few problems getting started. Initially I couldn't get pip install to work so I downloaded the zip file and ran the setup.py file (I am running on windows 7 64 bit). However, I received an error that it couldn't find the .dll. I copy and pasted both the x86 and x64 dll into the site-packages folder. This got me past the first error, however now I get another error "WindowsError: [Error 193] %1 is not a valid Win32 application".

I initially thought this was because it was trying to read in the x86 dll, and I noticed in the heatmap.py file:

        if "windows" in platform.system().lower():
            libname = "cHeatmap-x86.dll"
            if "64" in platform.architecture()[0]:
                libname = "cHeatmap-x64.dll"

I thought perhaps it was trying to open the x86 .dll, so I modified the code to only assign libname to the x64, however I get the same issue when reloading the module. I've tried it both ways.

Im using IPython Notebook as well, if that matters.

area parameter failing

pts =
[(35.3471065, -1.3717678), (35.3471055, -1.371767), (35.3471129, -1.3717759), (35.347097, -1.3717772), (35.3470594, -1.371768), (35.3469574, -1.3695878), (35.3482843, -1.3742364), (35.3471152, -1.3717737), (35.3470689, -1.3717676), (35.3470616, -1.3717587), (35.347071, -1.3717492), (35.3470982, -1.371731)]

hm.heatmap(pts, size=(1024, 512), area=((35.14455174999947, -1.4807579817798406), (35.496114249999806, -1.3050287418975504)))

results in this image:

Nashipai

removing the area parameter results in this image:

tmp

pip install heatmap fails on v2.2.1 on Ubuntu 64bit

Full trace below:

$ pip install heatmap
Downloading/unpacking heatmap
  Downloading heatmap-2.2.1.zip
  Running setup.py egg_info for package heatmap

Installing collected packages: heatmap
  Running setup.py install for heatmap
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: option --single-version-externally-managed not recognized
    Complete output from command /home/paul/v/heatmap/bin/python -c "import setuptools;__file__='/home/paul/v/heatmap/build/heatmap/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-i5sP5C-record/install-record.txt --install-headers /home/paul/v/heatmap/include/site/python2.7:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help



error: option --single-version-externally-managed not recognized

----------------------------------------
Command /home/paul/v/heatmap/bin/python -c "import setuptools;__file__='/home/paul/v/heatmap/build/heatmap/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-i5sP5C-record/install-record.txt --install-headers /home/paul/v/heatmap/include/site/python2.7 failed with error code 1 in /home/paul/v/heatmap/build/heatmap
Storing complete log in /home/paul/.pip/pip.log

mercator projections

If input points are lat/long and cover a reasonably large distance (10s of miles) the resulting points will be slightly off due to the lack of mercator projections.

The translation is simple:

from math import degrees, radians, asinh, tan
oldLatRads = radians(lat)
newLatRads = asinh(tan(oldLatRadians))
newLat = degrees(newLatRads)

This can't go in saveKML(), since that operation is post-image translation. Simplest impl is a new function provided by the lib to translate a set of points before calling heatmap(). This will add one pass in native python, decreasing perf for large sets of lat/long.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.