Greenhouse Gas Emissions Hexagbin Heatmap from MapBox to CartoDB

Version Française

In my last post (Données ouvertes et les émissions de Gaz à effet de serre au Canada) I explained how I convert a CSV data file (from opendata.gc.ca) on greenhouse gases emissions in Canada to build a map. So I produced a tiled map of this project with TileMill deployed on my own server with Wax API.  You can try it now !

I tried to show two things 1) the density of facilities producing those emissions 2) the distribution of GHG emissions in Canada. of course I could used a "Heatmap" to show the density of those value.  But, I tried to produce this density map using a hexagonal grid.

The idea of ​​presenting the amount of GHGs produced in Canada in a points clustered grid came wit this example (Point Clustering) made ​​by the CartoDB developers. More recently, @elcep also proposed a similar approach in his blog. This concept was perfect to illustrate the distribution of greenhouse gases in a 300km x 300km virtual grid.  I builded my layer with this SQL in PostGIS:

SELECT max(install_ges_p.gid) AS gid, sum(install_ges_p.emis_ges) AS gazemis,     st_snaptogrid(install_ges_p.the_geom, 0::double precision, 0::double precision, 300000::double precision, 300000::double precision) AS the_geom_gr FROM install_ges_p GROUP BY st_snaptogrid(install_ges_p.the_geom, 0::double precision, 0::double precision, 300000::double precision, 300000::double precision); I loaded the data from my local "PostgreSQL / PostGIS" into my CartoDB account.  This tool is cool because it's faster to deploy and doesn't require a tiled map production as everything is dynamic.  All we must do is load the table and carto style into your CartoDB account.
@opac_grid:0.1;
@color_gris: #4F1891;
@opac_marker:0.3;
#gridemisgestot[gazemi_nb>0][zoom>=3]{
 marker-fill:@color_gris;
 marker-opacity:@opac_grid;
 marker-line-color:@color_gris;
 marker-line-opacity:@opac_marker;
 marker-allow-overlap:true;
 text-name:"[gazemis]";
 text-face-name:"DejaVu Sans Book";
 text-allow-overlap:true;
 text-halo-radius:1.5;
 text-halo-fill:rgba(255,255,255,0.50);
 text-placement:point;
 [zoom=3]{marker-width:7.5;text-size:4;}
 [zoom=4]{marker-width:15;text-size:9;}
 [zoom=5]{marker-width:30;text-size:18;}
 [zoom=6]{marker-width:60;text-size:36;}
 [zoom=7]{marker-width:120;text-size:36;}
}
Then you can 1) use this API

2) or use the small 'embed_map' provided by CartoDB layer by layer.

https://smercier.cartodb.com/tables/hex_gazemis_cnt/embed_map?sql=SELECT * FROM hex_gazemis_cnt' width='100%' height='480'

2 comments — post a comment

gis guru

Not bad. But seems like a complicated way of dealing with a simple matter of displaying data. Comes across as using a hammer to break open an egg.

gis guru

Not bad. But seems like a complicated way of dealing with a simple matter of displaying data. Comes across as using a hammer to break open an egg.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current month ye@r day *