Skip to content

Instantly share code, notes, and snippets.

View JesseCrocker's full-sized avatar

Jesse Crocker JesseCrocker

View GitHub Profile
@JesseCrocker
JesseCrocker / rio-to-pmtiles.py
Last active September 19, 2024 18:20
Slice a raster into tiles using rio-tiler, write to a pmtiles file
import argparse
import os
import warnings
import mercantile
import rasterio
from pmtiles.tile import Compression
from pmtiles.tile import TileType
from pmtiles.tile import zxy_to_tileid
from pmtiles.writer import Writer
@JesseCrocker
JesseCrocker / merge-pmtiles.py
Created March 29, 2024 13:19
Merge a directory of PMTiles files into a single file
#!/usr/bin/env python3
import argparse
import os
from pmtiles.reader import MmapSource, Reader, all_tiles
from pmtiles.writer import Writer
from pmtiles.tile import Compression
from pmtiles.tile import zxy_to_tileid
from tqdm import tqdm
def merge_pmtiles(input_dir: str, output_file: str) -> None:
@JesseCrocker
JesseCrocker / extract-pmtiles.py
Last active March 28, 2024 21:22
Extract tiles in a PMTiles file to a directory in z/x/y.ext format. Chat GPT wrote this for me.
#!/usr/bin/env python3
import argparse
import os
from pmtiles.reader import all_tiles
from pmtiles.reader import MmapSource
from pmtiles.reader import Reader
from pmtiles.tile import TileType
from tqdm import tqdm