If I have geolocalized records with a simple true/false value for a field with title "Do you like flowers?"

How can I draw a map that shows me in which areas people like flowers more than in which areas like flowers less.

If I need to after-cook the data it is not a problem but I don't see how can I draw a kind of a "intensity/heat" map with the areas where people like flowers more. Remember that counting "yes" it not enough, has to be the difference between "yes"es and "no"es for each area.

The table would look like this:

Lat, Long, like flowers
1,   1,    y
3,   2,    n
4,   2,    n
4,   1,    y

And I would like to generate something like this:

enter image description here

  • 1
    To get a more helpful answer, I would suggest editing the question and/or the tags to the question to note what GIS software and what version of that software, you are using/have access to. Without knowing the tools at your disposal, we can't help you use them. Also, do you have regions (polygons) such as community zones, block groups, etc... you are trying to aggregate this by specifically (you don't have to, but it would likely change how you'd approach a solution). – John Feb 10 '15 at 17:38
  • Thanks for the suggestion @John I just added more explanations – fguillen Feb 10 '15 at 17:52
  • just use CartoDB that provides that visualization with one click :) – javisantana Feb 11 '15 at 7:24
  • @javisantana not really, I'm trying with #cartodb and it deals very good with density of population but not with density based on a weight calculation of one of their fields. The visualization wizard "Choropleth" is the most close to my needs but it colorizes every dot individually without aggregate dots in the proximity to generate an "area dot". – fguillen Feb 11 '15 at 14:05
  • I understand. In that case you would need to do the aggregation using SQL. Not that simple but possible with this helper function: github.com/CartoDB/cartodb-postgresql/blob/master/… the query we use is this github.com/CartoDB/cartodb/blob/master/lib/assets/javascripts/… you would need to change the aggregation method – javisantana Feb 11 '15 at 15:29

Here's a tutorial on 'hex binning' using free and open source tools, and another. A couple of years old, but may still be applicable. Once you have the hexagons, it should be easy to import and style by intensity in cartodb.

Basic steps

  1. Install QGIS
  2. Install the MMQGIS plugin
  3. Use the MMQGIS "Create Grid Layer" tool to create hexagonal grid at your desired resolution.
  4. Import your "yes" and "no" data as csv. In QGIS 2+, Click on LayersAdd Delimited Text Layer.
  5. Use the QGIS "Point in Polygon" tool to sum both "yes" and "no" counts within each hexagon. Sum each field ("yes" and "no") to its own column for use the next step. If you have a lot of points, this step might be more efficient in PostGIS.
  6. If as you say, the important thing is the difference between total "yes" and "no" in each hexagon, then add a new field, and use the QGIS Field Calculator to calculate the difference between the "yes" and "no" fields created in the last step.
  7. Assuming this ultimately goes to cartodb, import the hexagon shapefile to cartodb and symbolize by intensity.
| improve this answer | |

The solution I ended up in with (in CartoDB) was a combination of a shapefile with all the provinces in the area of my population, and custom sql that updates a column into the shapefile table with the aggregated calculations of the records in each province. Then, everything rendered using the wizard "Choropleth".

If I manage to generate a shapefile with the hexagons of my example I could reproduce it exactly.

Check this answer.

Check also this @javisantana comment.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.