Skip to content

Instantly share code, notes, and snippets.

View ramiroaznar's full-sized avatar

Ramiro Aznar ramiroaznar

View GitHub Profile
@ramiroaznar
ramiroaznar / README.md
Last active August 16, 2021 17:38
Create layer, add two sublayers and get sublayers

How to use createLayer, add two sublayers and get them as variables for future uses. Click on "Open" and open the Developers Tools Console. It should display two objects for the two layers or CartoDBSubLayers. Based on Oriol's sublayers order cartodb createLayer block.

@ramiroaznar
ramiroaznar / get_aggs_geochicas.py
Created May 14, 2021 07:03
Get aggregated metrics from lascallesdelasmujeres geochicas project
import os
import pandas as pd
import json
# clone lascallesdelasmujeres github repository
# cd /lascallesdelasmujeres
json_list = []
for root, dirs, files in os.walk(os.getcwd() + '/data'):
for file in files:
if file == 'stats.txt':
@ramiroaznar
ramiroaznar / index.html
Created June 17, 2018 14:57
Dropdown + setQuery | CARTO.js
<!DOCTYPE html>
<html>
<head>
<title>Dropdown + setQuery | CARTO.js</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<!-- Include jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Include Leaflet -->
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
@ramiroaznar
ramiroaznar / Histogram.js
Last active May 7, 2020 10:58
Vega Lite React Component
import React, { useContext } from 'react'
import { VegaLite } from 'react-vega'
import { VEGA_SPEC, HISTO_STYLE } from './constants'
const Histogram = ({metrics}) => {
/// dummy data
const dummyData = [
{x: 'Bulls', y: 128, z: 'red'},
{x: 'Lakers', y: 100, z: 'yellow'}
@ramiroaznar
ramiroaznar / normalize.sql
Last active March 23, 2020 15:07
Cómo normalizar en SQL
SELECT *,
variable/population as var_norm,
variable*1000/population as var_norm_1000hab
FROM table
@ramiroaznar
ramiroaznar / index.html
Created August 24, 2018 10:45
Time Series widget with Chart.js and CARTO.js v4 dataviews
<!DOCTYPE html>
<html>
<head>
<title>Time Series widget | CARTO</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<!-- Include Leaflet -->
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
<link href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" rel="stylesheet">
<!-- Include CARTO.js -->
@ramiroaznar
ramiroaznar / index.html
Last active October 19, 2019 07:37
leaflet.draw + CARTO
<!DOCTYPE html>
<html>
<head>
<title>leaflet.draw + CARTO</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="https://cartodb.com/assets/favicon.ico" />
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script>
@ramiroaznar
ramiroaznar / app.js
Last active October 16, 2019 15:48 — forked from rochoa/app.js
[CARTO] basic viewer
'use strict';
var DEFAULTS = {
endpoint: 'http://ramirocartodb.cartodb.com/api/v1/map',
sql: 'select * from ne_10m_populated_places_simple',
cartocss: [
"#layer['mapnik::geometry_type'=1] {",
" marker-width: 7;",
" marker-fill: #EE4D5A;",
" marker-fill-opacity: 0.9;",
@ramiroaznar
ramiroaznar / cities.js
Last active June 22, 2019 17:36
CARTO VL & Airship with GeoJSON data source
const cities = {"type": "FeatureCollection", "features": [{"type":"Feature","geometry":{"type":"Point","coordinates":[2.450021,41.539957]},"properties":{"latitude":41.5399566844,"longitude":2.45002070986,"name":"Mataro","country":"Spain","pop":183293}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-0.980028,37.60043]},"properties":{"latitude":37.6004297069,"longitude":-0.98002832173,"name":"Cartagena","country":"Spain","pop":201274}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-5.67,43.530016]},"properties":{"latitude":43.530016092,"longitude":-5.67000044903,"name":"Gijon","country":"Spain","pop":335972}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-15.429999,28.099976]},"properties":{"latitude":28.0999760122,"longitude":-15.4299990249,"name":"Las Palmas","country":"Spain","pop":378495}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-1.698512,37.688564]},"properties":{"latitude":37.6885638621,"longitude":-1.6985115981,"name":"Lorca","country":"Spain"
@ramiroaznar
ramiroaznar / index.html
Last active May 29, 2019 08:19
CARTO JS & Planet Basemaps
<!DOCTYPE html>
<html>
<head>
<title>CARTO JS + Planet Basemaps</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- Include Airship -->
<link rel="stylesheet" href="https://libs.cartocdn.com/airship-style/v2.0.5/airship.css">