Skip to content

Instantly share code, notes, and snippets.

@alvincyh
alvincyh / generate-shx.py
Last active November 20, 2016 10:28
Repair corrupted .shx file
# Based on the solution described here: http://geospatialpython.com/2011/11/generating-shapefile-shx-files.html
# Requires pyshp (pip install pyshp)
# Run script from shapefile folder
# Build a new shx index file
import fnmatch
import os
import shapefile
# List all the shapefiles
@alvincyh
alvincyh / HaversineBtwODPostCodes.Rmd
Last active January 16, 2017 06:23
Haversine distance between ODPostalCodes
---
title: "Haversine distance between ODPostalcodes"
output:
html_notebook: default
html_document: default
---
```{r}
require("dplyr")
postalcodes <- read.csv(file.choose(), stringsAsFactors = FALSE, header=TRUE)
head(postalcodes)
@alvincyh
alvincyh / sgRailTravelTime.R
Last active March 18, 2018 08:43
Scrap TransitLink for Singapore MRT / LRT Station to Station Travel Travel Time
# Estimated travel time does NOT include waiting time
library(httr)
library(stringr)
getTravelTime <- function(start_code, stop_code){
params <- list(
mrtcode_start = start_code,
mrtcode_end = stop_code,