Skip to content

Instantly share code, notes, and snippets.

View cbeddow's full-sized avatar

Christopher Beddow cbeddow

View GitHub Profile
@cbeddow
cbeddow / osm2geojson
Created November 28, 2023 23:37
A JSON dict of Overture places categories to OSM tags
{
"forest": [
"landuse=forest"
],
"stadium_arena": [
"leisure=stadium"
],
"farm": [
"landuse=farm"
],
{
"forest": [
"landuse=forest"
],
"stadium_arena": [
"leisure=stadium"
],
"farm": [
"landuse=farm"
],
import json
import pandas as pd
tags_dict = None
with open('./overture2osm.json') as file:
tags_dict = json.load(file)
def jsonize_tags(tags):
# Split the string at the '=' character
tags = {tag.split('=')[0]: tag.split('=')[1] for tag in tags}
{
"forest": [
"landuse=forest"
],
"stadium_arena": [
"leisure=stadium"
],
"farm": [
"landuse=farm"
],
{
"forest": [
"landuse=forest"
],
"stadium_arena": [
"leisure=stadium"
],
"farm": [
"landuse=farm"
],
@cbeddow
cbeddow / mapillary_jpg_download.py
Last active November 11, 2024 16:55
Download Mapillary images a JPGs
import mercantile, mapbox_vector_tile, requests, json, os
from vt2geojson.tools import vt_bytes_to_geojson
# define an empty geojson as output
output= { "type": "FeatureCollection", "features": [] }
# vector tile endpoints -- change this in the API request to reference the correct endpoint
tile_coverage = 'mly1_public'
# tile layer depends which vector tile endpoints:
@cbeddow
cbeddow / mapillary_image_download.py
Last active March 14, 2024 13:07
Download all Mapillary images in a bounding box - API v4
import mercantile, mapbox_vector_tile, requests, json
from vt2geojson.tools import vt_bytes_to_geojson
# define an empty geojson as output
output= { "type": "FeatureCollection", "features": [] }
# vector tile endpoints -- change this in the API request to reference the correct endpoint
tile_coverage = 'mly1_public'
# tile layer depends which vector tile endpoints:
@cbeddow
cbeddow / mapillary_sequence_download.py
Last active January 18, 2022 21:28
Download Mapillary sequence lines as geojson
import mercantile, mapbox_vector_tile, requests, json
from vt2geojson.tools import vt_bytes_to_geojson
# define an empty geojson as output
output= { "type": "FeatureCollection", "features": [] }
# vector tile endpoints -- change this in the API request to reference the correct endpoint
tile_coverage = 'mly1_public'
# tile layer depends which vector tile endpoints:
@cbeddow
cbeddow / mapillary_image_download.py
Created July 20, 2021 20:39
Download Mapillary images with API v4
import mercantile, mapbox_vector_tile, requests, json
from vt2geojson.tools import vt_bytes_to_geojson
# define an empty geojson as output
output = { "type": "FeatureCollection", "features": [] }
# empty list of image keys
images = []
# vector tile endpoints -- change this in the API request to reference the correct endpoint
@cbeddow
cbeddow / tilesplitter.js
Created July 13, 2021 00:12
Tilesplitter example
interface TileCoords {
x: number;
y: number;
z: number;
}
const getParentTileCoords = (childTile: TileCoords, parentLevel: number): TileCoords => {
const deltaZ = childTile.z - parentLevel;
const scale = Math.pow(2, deltaZ);
return {
'x': Math.floor(childTile.x / scale),