Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
"""
@author: mthh
Convert a csv file (containing WKT geometry) into a shapefile
"""
from osr import SpatialReference
import ogr
from csv import DictReader
import sys
# -*- coding: utf-8 -*-
# The MIT License (MIT)
#
# « Copyright (c) 2015, mthh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@mthh
mthh / test_glt.py
Last active November 4, 2015 14:52
# -*- coding: utf-8 -*-
"""
@author: mthh
"""
import geopandas as gpd
import numpy as np
import matplotlib.pyplot as plt
import gpd_lite_toolbox as glt
# -*- coding: utf-8 -*-
"""
@author: mthh
-------------
Example of loading node coordinates from an osrm or osrm.node file
in order to search the nearest OSRM node of an input points dataset.
"""
import csv
import sys
import numpy as np
@mthh
mthh / Rserv_zmq2.R
Last active February 17, 2016 20:57
noname_0
#!/usr/bin/env Rscript
require(base)
require(methods)
require(stats)
require(pbdZMQ)
require(jsonlite)
startServer_test <- function(port){
ctx = zmq.ctx.new()
socket = zmq.socket(ctx, .pbd_env$ZMQ.ST$REP)
@mthh
mthh / R_worker.R
Last active February 18, 2016 19:51
noname_1
require(pbdZMQ)
require(methods)
require(stats)
require(base)
R_Worker <- function(identifiant, worker_url = 'ipc:///tmp/feeds/workers'){
ctx = zmq.ctx.new()
socket = zmq.socket(ctx, .pbd_env$ZMQ.ST$REQ)
zmq.setsockopt(socket, .pbd_env$ZMQ.SO$IDENTITY, identifiant)
zmq.connect(socket, worker_url)
# -*- coding: utf-8 -*-
"""
R client (through Rpy2) trying to be used in a background for a WebPage
providing a R interactive console.
@author: mz
"""
import threading
import time
import zmq
import sys
@mthh
mthh / rpy2_client.py
Last active February 25, 2016 13:20
Some tests with rpy2 and ZMQ sockets...
# -*- coding: utf-8 -*-
"""
@author: mz
"""
import threading
import time
import zmq
import sys
import os
import pickle
getHexGrid <- function(spdf, cellsize){
boundingBox <- bbox(spdf)
boundingBox[1,1] <- boundingBox[1,1] - cellsize
boundingBox[2,1] <- boundingBox[2,1] - cellsize
boundingBox[2,2] <- boundingBox[2,2] + cellsize
cols = ceiling(((boundingBox[1,2] - boundingBox[1,1]) + 3 * cellsize) / cellsize)
rows = ceiling((boundingBox[2,2] - boundingBox[2,1]) / cellsize)
# -*- coding: utf-8 -*-
"""
Some helpers functions to try some (one dimension) data classification methods.
"""
import numpy as np
from operator import ge, le
from math import floor, log10
def head_tail_break(values, direction="head"):