PostGIS tips & tricks with CartoDB.js

It is been awhile since my last post. A lot of cool things have happened since then!  I continue to learn Javascript and PostGIS. In fact, with the combination of these two and a little help of CartoDB.js, you could make amazing visualizations. In this post, you will learn how to connect points using great circles and also how to stack your points as chips in order to solve the “overlapping points problem”.

I believe that everyone is familiar with great circles thanks to the Facebook friendship map. But in my case, I get completely in love with them when I learnt how to “paint” them in R. But maybe the most brilliant visualization is the one recently made by Carlos Matallín. Here we are going to learn the most basic SQL query used in the former viz that allows us to connect our points of interest and getting simple but outstanding cartographies:

And this beautiful visualization can be achieved with just a few lines of code. Here is the block where you can see how to embed both the following SQL query and the CartoDB.js:

A little bit more complicated is the second example. This solution, explained in more detail here, will allow you to visualize multiple overlapping points. How? Stacking them as if they were casino chips. But be aware that as commented in the cited post, if you allow zoom interaction you will need to implement a function to keep the distance between each of them constant.

Here you can find a block with both the visualization and the following SQL to hack the map:

More and better in the following posts. Happy coding, querying and mapping!

GIS Analyst. Working at @CARTO and @ongawa4d.

0 Comments

  1. Pingback: 3D buildings with CartoCSS! | Ramiro Aznar

  2. Pingback: How to use CARTO BUILDER analysis to create insightful map applications | Ramiro Aznar

Leave a Reply

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *