Skip to content

Instantly share code, notes, and snippets.

View CloudNiner's full-sized avatar

Andy Fink-Miller CloudNiner

View GitHub Profile
@CloudNiner
CloudNiner / osmx_utils.py
Created July 29, 2020 13:10
Query OSMX by S2Region in Python
import logging
import time
import osmx
import pywraps2 as s2
logging.basicConfig(format="%(message)s")
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
@CloudNiner
CloudNiner / demo.py
Last active July 13, 2020 19:55
OSM GeoJson by Bounding Box and Tags via OSMX
"""
This demo uses OSMExpress and the s2sphere library to query a OSMX db by bounding box.
It writes a GeoJson FeatureCollection of all nodes and ways that matched the tag query to stdout
TODO: Relation support
Example:
```
@CloudNiner
CloudNiner / gt_gridextent.md
Last active June 19, 2020 12:56
A Treatise on GeoTrellis GridExtent

It looks like we're computing cols / rows via the ceil operation but validating it via the round function.

In short, yes. And GridExtent currently operates in its constructor using round so in order to remain consistent, we should use that elsewhere when we construct new GridExtents, like in withResolution and combine.

The long version is that withResolution is unclear and could use reworking because it amplifies a core issue with GridExtent. The issue is that extent and cell sizes are represented as Double while cols and rows are represented as Integer:

  1. A GridExtent can be specified as having an extent and a specific number of cols and rows. This is fine, because we divide a double by an int and get a double cell size in each dimension
  2. A GridExtent can be specified as an extent and a CellSize. This is less fine, because we take a double and divide by a double to get a...double for cols and rows. But cols and rows are ints! So how to we choose what the right answer is for cols and rows in the

Adding Trails to OpenStreetMap

I’ve contributed to OpenStreetMap (OSM) in the past but mostly as part of Azavea’s monthly HOTLunch where we work on open mapping campaigns across the globe by adding features visible on satellite imagery. Closer to home in southeast Pennsylvania, the map has always seemed pretty complete and I’ve struggled to find edits to contribute - pretty much all of the roads and interesting buildings are mapped. But then the other day I saw that a local trail we use for evening walks was missing and a short time later I was able to make my first local edit using a GPS track!

It turns out that the process pretty straightforward, thanks to the OSM community’s documentation. First, my wife and I went for a walk and recorded our track using a smartphone app capable of exporting GPX files. Once back home, we uploaded the trace to my user account at https://openstreetmap.org/traces,

@CloudNiner
CloudNiner / Dockerfile
Last active March 24, 2020 01:51
OSMExpress 0.0.4 Ubuntu 18.04 Dockerfile
FROM ubuntu:18.04 AS builder
RUN apt-get update && apt-get install -y \
cmake \
clang \
libbz2-dev \
libz-dev \
libexpat-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
@CloudNiner
CloudNiner / CreateSpaceTimeGTLayer.scala
Created March 5, 2020 22:33
GeoTrellis Layer from Landsat 8 GeoTIFFs
package geotrellis.server.ogc
import java.time.ZonedDateTime
import cats.implicits._
import geotrellis.layer.{LayoutLevel, TemporalKeyExtractor, ZoomedLayoutScheme}
import geotrellis.proj4.WebMercator
import geotrellis.raster._
import geotrellis.spark._
import geotrellis.spark.store.kryo.KryoRegistrator
@CloudNiner
CloudNiner / serve_vt.py
Created May 14, 2019 12:50
Serve Vector Tiles locally via dev Python HTTP Server
#!/usr/bin/env python
# Run with `python3 serve_vt.py <port>` within the directory you want to serve
# Credit https://github.com/moradology
try:
# Python 3
from http.server import HTTPServer, SimpleHTTPRequestHandler, test as test_orig
import sys
def test (*args):
test_orig(*args, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)
except ImportError: # Python 2
@CloudNiner
CloudNiner / bitbar-vagrant.30s.pl
Created June 13, 2018 17:22
BitBar Vagrant Global plugin -- Only count running VMs in menubar
#!/usr/bin/env perl
# <bitbar.title>Vagrant Global Status</bitbar.title>
# <bitbar.version>1.1</bitbar.version>
# <bitbar.author>Alexandre Espinosa Menor</bitbar.author>
# <bitbar.author.github>alexandregz</bitbar.author.github>
# <bitbar.desc>Show vagrant images running, from vagrant global-status command</bitbar.desc>
# <bitbar.image>http://i.imgur.com/4YAFZC6.png</bitbar.image>
#
# "running" line run command "vagrant suspend"
# "saved, poweroff, aborted" line run command "vagrant up"