Skip to content

Instantly share code, notes, and snippets.

@rochoa
rochoa / README.md
Last active June 21, 2022 18:42
CARTO Node.js code test

CARTO Node.js code test

Introduction

At CARTO, among other things, we render maps, just check this example of Map with countries and USA states.

In order to limit the scope of the challenge, we are gonna use Mapnik and Node.js. Within this repository, we are providing all the pieces you need to reproduce that map. Well, all pieces except the map tile server.

An example of how to create an image with Mapnik:

@rochoa
rochoa / ImageMagick 6.7.7-10 Homebrew Formula.md
Last active March 11, 2021 13:48
Homebrew Formula for ImageMagick 6.7.7-10

Homebrew Formula patching old ImageMagick release 6.7.7-10

Install

$ brew install https://gist.githubusercontent.com/rochoa/10017167/raw/f4f09fd9f9441513d06092c881e10935735881e2/imagemagick.rb

Tested

import click
import csv
import json
import requests
from io import StringIO
from datetime import datetime
from kafka import KafkaConsumer
import atexit
def flush(endpoint, datasource_name, token, rows):
@rochoa
rochoa / index.html
Last active February 1, 2019 17:33
Manhattan buildings by number of floors over the years | CARTO VL
<!DOCTYPE html>
<html>
<head>
<title>Manhattan buildings by number of floors over the years | CARTO VL</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<!-- Include CARTO VL JS -->
<script src="https://libs.cartocdn.com/carto-vl/v0.4.0/carto-vl.js"></script>
<!-- Include Mapbox GL JS -->
@rochoa
rochoa / app.js
Last active August 2, 2018 11:08
[CARTO] basic viewer
'use strict';
var DEFAULTS = {
endpoint: 'https://rochoa.carto.com',
sql: 'select * from airbnb_madrid_oct_2015_listings',
cartocss: `#layer['mapnik::geometry_type'=1] {
marker-width: 7;
marker-fill: #EE4D5A;
marker-fill-opacity: 0.9;
marker-line-color: #FFFFFF;
@rochoa
rochoa / README.md
Last active January 9, 2018 06:31
[CARTO] MVT service + Mapbox GL

CartoDB's MVT service + Mapbox GL

Check index.html for some examples. These use a beta feature of CartoDB's Maps API: fixed URLs. So there is no need to use cartodb.js and tiles can be consumed using a named map name.

cartodb.js example

Check cartodb.js.html to see the integration with cartodb.js and in particular with cartodb.core.js.

Mapbox GL resources

@rochoa
rochoa / index.html
Last active January 5, 2018 22:11
[CARTO] CartoCSS example – polygon-simplify
<!DOCTYPE html>
<html>
<head>
<title>CartoDB: CartoCSS example – polygon-simplify</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
height: 100%;
@rochoa
rochoa / tile.sql
Created November 8, 2017 15:22 — forked from javisantana/tile.sql
CREATE OR REPLACE FUNCTION tile (z integer, x integer, y integer, query text) RETURNS TABLE(id int8, geom geometry)
AS $$
DECLARE
sql TEXT;
BEGIN
sql := 'with _conf as (
select
CDB_XYZ_resolution(' || z || ') as res,
1.0/CDB_XYZ_resolution(' || z || ') as invres,
st_xmin(CDB_XYZ_Extent(' || x || ',' || y || ',' || z ||')) as tile_x,
@rochoa
rochoa / README.md
Last active August 4, 2017 04:59
[CARTO] turbo-cartocss examples

Color ramps: *-fill

Basic usage

marker-fill: ramp([column_name], colorbrewer(Greens));
                  |                    |
                  v                    |
      column to calculate ramp         |
                                       v
@rochoa
rochoa / app.js
Last active May 22, 2017 09:39
[CARTO] Raster demos
var map = L.map('map', {
scrollWheelZoom: false,
center: [-18, -46],
zoom: 8
});
L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: '<a href="http://cartodb.com">CartoDB</a> © 2014',
maxZoom: 18
}).addTo(map);