Aquí puedes ver la implementación más sencilla de un cartograma en d3.js. Lo único que hace el script es crear un mapa base y actualizar los polígonos de acuerdo al valor de una variable escalada
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select 1 as id, st_geomfromtext( | |
'POLYGON ((-99.5408690000000007 19.9525709999999989, -99.5435870000000023 19.9554469999999995, -99.3506809999999945 20.0420480000000012, -99.3361179999999990 20.0463349999999991, | |
-99.1990940000000023 20.2146280000000012, | |
-99.1924779999999942 20.2391210000000008, | |
-99.1860319999999973 20.2430979999999998, | |
-99.1860300000000024 20.2430990000000008, | |
-98.9455770000000001 20.2654850000000017, | |
-98.9449809999999985 20.2654619999999994, | |
-98.9423579999999987 20.2606110000000008, | |
-98.8173819999999949 20.1350939999999987, -98.7599189999999965 20.1261369999999999, -98.7324749999999938 20.1274310000000014, -98.5636429999999990 20.2358669999999989, -98.4145270000000068 20.0966829999999987, -98.7129479999999973 20.0652369999999998, -98.5766100000000023 19.7826479999999982, -98.5761750000000063 19.7703230000000012, -98.5397349999999932 19.6572999999999993, -98.6620520000000027 19.3520900000000005, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Crear columnas para las categorías generals y tipo de actividades (primarias, secundarias, terciarias y de gobierno): | |
select gid, substring(clase_act from 0 for 3) as sector, | |
case when substring(clase_act from 0 for 3) like '11' | |
then ('prmario') | |
when substring(clase_act from 0 for 3) in ('21','22','23','31','32','33') | |
then ('secundario') | |
when substring(clase_act from 0 for 3) in ('43','46','48','49','51','52','53','54','55','56','61','62','71','72','81') | |
then 'terciario' | |
when substring(clase_act from 0 for 3) like '93' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Tenemos dos tablas, una con los datos para las colonias (colonias_final) y otra con los nombres de las colonias (colonias_names). Lo que quiero hacer es pegarle los nombres de las colonias a los datos | |
--Para hacer el spatial join voy a usar un punto al interior de las colonias porque las geomeetrías no coinciden perfectamente (no quiero usar st_centroid porque las geometrías de las colonias son caprichosas y el centroide puede caer fuera de la colonia). Para poder usar índices, voy a crear una tabla intermedia con los centroides de la capa con nombres | |
--Creamos la tabla de centroides | |
create table centro_col_nombres as select gid, nombre, st_PointOnSurface(geom) as geom | |
from colonias_names; | |
--Le ponemos índice | |
create index sidx_centro_col_nombres_geom on centro_col_names USING GIST (geom); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from pylons import request, response, session, tmpl_context as c | |
from pylons.controllers.util import abort, redirect | |
from mapfishapp.lib.base import BaseController | |
from mapfishapp.model.mallas import Malla | |
from mapfishapp.model.meta import Session | |
from mapfishapp.model import meta | |
from shapely.wkt import loads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @include OpenLayers/Map.js | |
* @include OpenLayers/Projection.js | |
* @include OpenLayers/Layer/XYZ.js | |
* @include OpenLayers/Tile/Image.js | |
* @include OpenLayers/Control/Navigation.js | |
* @include OpenLayers/Control/ZoomBox.js | |
* @include OpenLayers/Control/NavigationHistory.js | |
* @include GeoExt/data/LayerStore.js | |
* @include GeoExt/widgets/MapPanel.js |
based on https://github.com/CartoDB/cartodb with additions as necessary
11/2013 to 02/2014
Install git
sudo apt-get install git-core
Clone project
NewerOlder