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
--twitts table | |
create table tweets | |
( | |
t_id bigint, | |
uname text, | |
n_id bigint, | |
loc_text text, | |
u_img text, | |
lat float, | |
lon float, |
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
with gp as( | |
select dim_colonia.*, deg.count as degree | |
from | |
(select h.colonia_cve, count(h.name) | |
from | |
( | |
select gu.colonia_cve, name | |
from | |
( | |
select c.colonia_cve, rp.gid, rp.the_geom, rp.name |
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
-- create delaunay lines | |
select st_delaunaytriangles(st_collect(the_geom),0.0000001, 1)from planet_osm_roads_vertices_pgr | |
-- create delaunay and dump the resulting multilinestrings | |
select (st_dump(st_delaunaytriangles(st_collect(the_geom),0.0000001, 1))).path[1] as id, (st_dump(st_delaunaytriangles(st_collect(the_geom),0.0000001, 1))).geom | |
from planet_osm_roads_vertices_pgr | |
-- add edge length in meters (over the spheroid) | |
select (st_dump(st_delaunaytriangles(st_collect(the_geom),0.0000001, 1))).path[1] as id, | |
(st_dump(st_delaunaytriangles(st_collect(the_geom),0.0000001, 1))).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
import pandas as pd | |
import geopandas as gpd | |
from shapely.geometry import Point | |
import fiona | |
#supongamos que tienes los tuits en un csv (las coordenadas en las columns "x" y "y"). Los lees con pandas | |
df = pd.read_csv('data.csv') | |
#conviertes las coordenadas en objetos Point | |
geometry = [Point(xy) for xy in zip(df.x, df.y)] | |
#Le pones proyección (lat, long en este caso) |
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
CREATE OR REPLACE FUNCTION _get_cell_intersects( | |
IN vertex geometry[], -- vertices geometries | |
IN vv numeric[], -- vertices values | |
IN bu integer[], -- vertices buckets | |
IN breaks numeric[], -- breaks | |
IN i1 integer, -- first vertex index | |
IN i2 integer -- last vertex index | |
) | |
RETURNS geometry[] AS $$ | |
DECLARE |
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
structure(list(Time = c("2015-12-07", "2016-05-03", "2015-12-07", | |
"2016-05-03", "2015-12-07", "2016-05-03", "2015-12-07", "2016-05-03", | |
"2015-12-07", "2016-05-03", "2015-12-07", "2016-05-03", "2015-12-07", | |
"2016-05-03", "2015-12-07", "2016-05-03"), Topic = c("treasonous, demsinphilly, khan, manafort, notorious, vpdebate, gloves, mcmullin", | |
"treasonous, demsinphilly, khan, manafort, notorious, vpdebate, gloves, mcmullin", | |
"clinton, debate, hillary, ryan, women, paul, tape, rally", "clinton, debate, hillary, ryan, women, paul, tape, rally", | |
"debates, debatenight, hillary, clinton, hillaryclinton, vote, debate, women", | |
"debates, debatenight, hillary, clinton, hillaryclinton, vote, debate, women", | |
"will, hillary, like, just, people, president, vote, said", "will, hillary, like, just, people, president, vote, said", | |
"critics, bills, aswafbjtet, policy, up.trump, jekyll, tmjr7gwqze, 10pm", |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import glob | |
import os | |
import zipfile | |
print 'hey' | |
w_dir = '/home/plablo/tmp_data/' | |
files = glob.glob(w_dir + '*.zip') |
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 -*- | |
import psycopg2 as psy | |
from datetime import datetime | |
import time | |
import csv | |
import json | |
def date_formatter(date_string): | |
"""Returns datetime object""" |
NewerOlder