Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculate bounding box for geo maps #21

Open
Henner opened this issue Jul 11, 2014 · 3 comments
Open

calculate bounding box for geo maps #21

Henner opened this issue Jul 11, 2014 · 3 comments

Comments

@Henner
Copy link

Henner commented Jul 11, 2014

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...

@Henner
Copy link
Author

Henner commented Jul 14, 2014

@kwauchope
Copy link

I dynamically set the width and height based on a selectable value 'pixels per degree' (PPD). I then scale this with an upper bound of 8192 which is based of the maximum texture size of the google earth client. Select your preferred PPD based on what quality image you are after/how far in you intend to zoom.

      width = int((east - west)*PPD + dotsize/2)
      height = int((north - south)*PPD + dotsize/2)
      largestVal = max(width,height)
      if largestVal > MAX_SIZE:
         scale = float(MAX_SIZE)/largestVal
         height = int(height*scale)
         width = int(width*scale)
         PPD = float((width-dotsize/2))/(east-west)
      dotDegrees = dotsize/2/PPD
      bounds = ((west-dotDegrees, south-dotDegrees),(east+dotDegrees,north+dotDegrees))

@kwauchope
Copy link

Updated above post with somewhat tested code. Considering adding it as a method in heatmap.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants