Skip to content

Instantly share code, notes, and snippets.

View matiskay's full-sized avatar

Edgar Marca matiskay

View GitHub Profile
@matiskay
matiskay / xyz_vs_tms.md
Last active August 29, 2015 14:07 — forked from tmcw/xyz_vs_tms.md

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

@matiskay
matiskay / README.md
Last active August 29, 2015 14:07 — forked from tyrasd/README.md

Plotting Node Density

  1. download the source data

     wget http://fred.dev.openstreetmap.org/density/tiles.13
     wget http://fred.dev.openstreetmap.org/density/tiles.16
    
  2. convert to simple, gnuplot-readable text format

sed 's/([0-9]) z=([0-9]) x=([0-9]) y=([0-9])/\3 \4 \1/' < tiles.13 > tiles.13.txt

Peru in OpenStreetMaps

Points evolution 14/01/01 - 14/09/18

Peru Data Evolution

@matiskay
matiskay / README.mkd
Last active August 29, 2015 14:07
All the independent country in LATAM

Latam in OpenStreetMaps

Rendering all the points in Latam

Points

Rendering all the lines in Latam

Lines

@matiskay
matiskay / output-mbutil.txt
Last active August 29, 2015 14:07
Using DataMaps.
ops@osm-db:~/learning$ mb-util tiles/planet planet.mbtiles
INFO:mbutil.util:Importing disk to MBTiles
DEBUG:mbutil.util:tiles/planet --> planet.mbtiles
INFO:mbutil.util:metadata from metadata.json restored
DEBUG:mbutil.util: Read tile from Zoom (z): 0 Col (x): 0 Row (y): 0
DEBUG:mbutil.util: Read tile from Zoom (z): 2 Col (x): 1 Row (y): 2
DEBUG:mbutil.util: Read tile from Zoom (z): 1 Col (x): 0 Row (y): 1
DEBUG:mbutil.util: Read tile from Zoom (z): 8 Col (x): 75 Row (y): 159
DEBUG:mbutil.util: Read tile from Zoom (z): 5 Col (x): 9 Row (y): 19
DEBUG:mbutil.util: Read tile from Zoom (z): 6 Col (x): 18 Row (y): 39
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 1.
Fecha Local Hora Local Latitud Longitud Profundidad Magnitud "Intensidad - Localidades"
05/10/2014 06:05:29 -11.95 -77.59 36 Km 4.0 ML II Ancón, Lima
02/10/2014 16:33:57 -12.04 -77.13 60 Km 4.0 ML II-III Lima
01/10/2014 18:47:54 -13.69 -76.47 41 Km 4.6 ML III Pisco; II-III Tambo de Mora, Chincha Alta;II San Vicente, Lunahuana, Ica
30/09/2014 06:39:22 -13.84 -71.83 8 Km 3.6 ML II Misca
27/09/2014 21:35:27 -13.81 -71.89 6 Km 5.1 ML VII Misca;VI Cusibamba, Toroy, Moyoc; V Colcha,Rondocán;IV Paccaritambo, Ccochirihuay;III-IV Yaurisque, Huanoquite;III Cusco, Omacha; II-III Ccapi;II Urubamba, Calca, Anta, Yanaoca, Huancarani
25/09/2014 22:54:12 -16.79 -70.60 8 Km 3.8 ML II Calacoa
25/09/2014 06:19:10 -12.49 -77.31 24 Km 3.9 ML II Callao, Lima
19/09/2014 21:44:36 -15.65 -74.03 66 Km 4.5 ML II-III Chala; II Atico, Yauca, Caraveli
17/09/2014 23:19:58 -6.15 -76.35 123 Km 4.9 ML II Lamas, Moyobamba
import json
import geojson
from shapely.geometry import shape
o = {
"coordinates": [[[23.314208, 37.768469], [24.039306, 37.768469], [24.039306, 38.214372], [23.314208, 38.214372], [23.314208, 37.768469]]],
"type": "Polygon"
}
s = json.dumps(o)
@matiskay
matiskay / pizza.py
Created September 6, 2014 23:23
Get Pizza information
import requests
import json
pizza_list = 'http://pizzahut.com.pe/Content/static/jsons/pizza-list.json'
#size_list = 'http://pizzahut.com.pe/Content/static/jsons/size-list.json'
r = requests.get(pizza_list)
pizzas = json.loads(r.text)
@matiskay
matiskay / svmflag.py
Created August 28, 2014 03:15 — forked from glamp/svmflag.py
import numpy as np
import pylab as pl
import pandas as pd
from sklearn import svm
from sklearn import linear_model
from sklearn import tree
from sklearn.metrics import confusion_matrix