Skip to content

Instantly share code, notes, and snippets.

View cbeddow's full-sized avatar

Christopher Beddow cbeddow

View GitHub Profile
@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),
@cbeddow
cbeddow / download_apiv4.py
Last active October 2, 2024 09:06
Python script for downloading data from Mapillary API v4 in a bounding box
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_points = 'mly_map_feature_point'
tile_traffic_signs = 'mly_map_feature_traffic_sign'
tile_coverage = 'mly1_public'
from stac_interact import get_collection_ids, get_item_dict, get_items_within
# desired collection ID
collection = 'sentinel-s2-l2a'
# get first item in desired collections
data = get_item_dict(collection)
assets = data['assets']
keys = assets.keys()
var images = ["Ul-D12gQYR4RKKtcqmqsDQ","uAhuDQSHVSXRCmP5eqHmGg","_vXXqJhvPKbhyMCDyFsA3Q", "A-3lBUJhPkAwqlFnIMW1hg", "xO6DsVNqMt9Tv1bVTe8UGA","5PBPwFgmu_HvQLMPda0qgg","J_KPdrHAbv7yngT43w0qrg","xLNC-Awp85IPj79OPg4fUg","AP9myH8OEMh0rtuvaRdrSg","W1s_IT_WlQ3myQ3GOpbUfQ","YG8pa7KP5LAwCX_Jhhw8fg","RGbdNKEVHf-GLj8BNp8tlg","3xxrrl04fsqF262pFDzHyg"];
var basemap = ["satellite"]
var project_title = "Exploring the World"
var project_subtitle = "A selection of beautiful Mapillary sequences from across the world"
var titles = ["Utah", "British Columbia", "California", "South Dakota", "Wyoming","California","Chile","New Zealand","Sri Lanka","Iceland","Georgia","South Africa","Nepal"]
var content = ["The capital city of Utah, Salt Lake City is situated at the foot of the Wasatch Mountains and the Great Salt Lake. The city is close to a variety of environments, ranging from alpine peaks to pine forest to red desert. It was also the host of the 2002 Winter Olympics, and is the center of the Church of Jesus Christ of Latter Day
{
"version": 8,
"sources": {
"mapillary-source": {
"tiles": [
"http://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt"
],
"type": "vector"
}
},
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.