Skip to content

Instantly share code, notes, and snippets.

View kuanb's full-sized avatar
🚌
trains, buses, bikes, and maps

Kuan Butts kuanb

🚌
trains, buses, bikes, and maps
View GitHub Profile
@kuanb
kuanb / groupby_after_apply.py
Last active July 5, 2017 16:30
Dealing with (attempting to circumvent) workers getting caught up in long Shapely operations
import sys
from dask.distributed import Client
from dask.dataframe.utils import make_meta
import dask.dataframe as dd
import math
import numpy as np
import pandas as pd
from shapely.wkt import loads
# change for different ref location for geometries csv
Note: Looks like workers completely crashed, were restarted (by the Docker container within which they were running) and then got out of sync (?).
...
Jul 05 15:14:06 ip-10-0-0-164 trusting_swanson: distributed.scheduler - INFO - Register tcp://10.0.0.132:38621
Jul 05 15:14:06 ip-10-0-0-164 trusting_swanson: distributed.scheduler - INFO - Register tcp://10.0.0.132:39862
Jul 05 15:14:06 ip-10-0-0-164 trusting_swanson: distributed.scheduler - INFO - Starting worker compute stream, tcp://10.0.0.132:42596
Jul 05 15:14:06 ip-10-0-0-164 trusting_swanson: distributed.scheduler - INFO - Starting worker compute stream, tcp://10.0.0.132:38847
Jul 05 15:14:06 ip-10-0-0-164 trusting_swanson: distributed.scheduler - INFO - Starting worker compute stream, tcp://10.0.0.132:38621
Jul 05 15:14:06 ip-10-0-0-164 trusting_swanson: distributed.scheduler - INFO - Starting worker compute stream, tcp://10.0.0.132:39862
Jul 05 15:14:10 ip-10-0-0-216 dhclient: DHCPREQUEST of 10.0.0.216 on ens3 to 10.0.0.1 port 67 (xid=0x6212458
from copy import copy
import geopandas as gpd
from shapely.wkt import loads
geodataset_geom_count = 30000
# two generic shapes
a = loads('MULTIPOLYGON (((649141.3988551921 119588.0508027334, 649205.3394444393 119586.6252604292, 649204.4036520078 119547.1810296645, 649203.3471333382 119400.7549073702, 649137.6164607083 119401.7231623645, 649141.3988551921 119588.0508027334)))')
b = loads('MULTIPOLYGON (((638329.3738409473 104950.4713290278, 637929.373791253 104951.4454448997, 637929.3737395091 105287.3536795844, 638329.3738592704 105287.3537065834, 638329.3738409473 104950.4713290278)))')
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuanb
kuanb / determine_straightness.ipynb
Created July 25, 2017 21:13
Get the "straightness" of a given path
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuanb
kuanb / index.html
Last active August 10, 2017 20:15
Bl.ock to play with line offsetting in Mapbox GL.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@kuanb
kuanb / cleaning_flocktracker_bogota.ipynb
Created August 12, 2017 19:02
Companion notebook to notes on cleaning Flocktracker data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.