Skip to content

Instantly share code, notes, and snippets.

Useful Git commands

The laziest way to delete all unused branches safely except master:

git checkout master
git branch | xargs git branch -d

Merge master into current feature branch:

library(sf)
xmin <- -2.3743
xmax <- 0.5589
ymin <- 37.3397
ymax <- 40.8679
st_polygon(list(rbind(
c(xmin, ymin),
c(xmin, ymax),

Setting up the conda env for a python project with jupyter lab

1. Setup new python project

1. create new environment

conda create --name myenv

with specific python version:

@AlexandraKapp
AlexandraKapp / berlin-s-bahn-ring.geojson
Created August 1, 2019 12:21 — forked from derhuerst/berlin-s-bahn-ring.geojson
Berliner S-Bahn-Ring GeoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import geopandas as gpd
import cv2
# read in data
example = gpd.read_file("data/example.gpkg")
scenario1 = gpd.read_file("data/example_similar.gpkg")
scenario2 = gpd.read_file("data/example_different.gpkg")
def signature_opt1(gdf, crs):
from haversine import haversine, Unit
# construct the cost matrix
def get_cost_matrix(gdf1, gdf2):
gdf1_centroids = gdf1.to_crs(3395).centroid.to_crs(4326)
gdf2_centroids = gdf2.to_crs(3395).centroid.to_crs(4326)
coords_sig1 = list(zip(gdf1_centroids.y, gdf1_centroids.x))
coords_sig2 = list(zip(gdf2_centroids.y, gdf2_centroids.x))
#get all potential combinations between all points from sig1 and sig2

Freeze env for documentation and sharing:

pip list --format=freeze &gt; requirements.txt

Python packages for mobility data

Analysis of mobility data

  • MovingPandas implements a Trajectory class and corresponding methods based on GeoPandas.

Fokus on human mobility data

  • scikit-mobility is a library for human mobility analysis in Python.
  • trackintel is a library for the analysis of spatio-temporal tracking data with a focus on human mobility. The core of trackintel is the hierachical data model for movement data that is used in GIS, transport planning and related fields. We provide functionalities for the full life-cycle of human mobility data analysis: import and export of tracking data of different types (e.g, trackpoints, check-ins, trajectories), preprocessing, data quality assessment, semantic enrichment, quantitative analysis and mining tasks, and visualization of data and results.

Routing and travel time matrices