Skip to content

Instantly share code, notes, and snippets.

@ashnair1
ashnair1 / road_data_download.py
Last active November 10, 2025 09:30
Script to download nodes, edges and traffic lights of a road network
import osmnx as ox
import geopandas as gpd
from shapely.geometry import Polygon, MultiPolygon
# --- INPUTS ---
polygon_path = "<ADD-GEOJSON-PATH-HERE>"
out_nodes = "<ADD-GEOJSON-PATH-HERE>"
out_edges = "<ADD-GEOJSON-PATH-HERE>"
out_traffic_lights = "<AADD-GEOJSON-PATH-HERE>"
@ashnair1
ashnair1 / upload_3dtiles.py
Created July 9, 2025 11:25
Python script to upload 3D Tiles.
import os
import argparse
from minio import Minio
from minio.error import S3Error
from dotenv import load_dotenv
import urllib3
from tqdm import tqdm
# Disable SSL verification warnings (internal use only)
urllib3.disable_warnings()
@ashnair1
ashnair1 / xyz_to_tms_converter.py
Last active September 29, 2025 07:11
Convert XYZ to TMS
import os
import shutil
from xml.etree.ElementTree import Element, SubElement, ElementTree
import argparse
# Mercator projection measures the Earth in meters, and the TMS format uses a specific tiling scheme.
EARTH_CIRCUMFERENCE = 40075016.68557849 # in meters
TILE_SIZE = 256 # in pixels
@ashnair1
ashnair1 / xyz_vs_tms.md
Created May 28, 2025 17:03 — forked from tmcw/xyz_vs_tms.md
The difference between XYZ and TMS tiles and how to convert between them

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

import matplotlib.pyplot as plt
import torch
import torchvision.transforms.functional as F
import kornia.augmentation as K
import kornia.io as Kio
# Note: Regarding dict keys and/or data keys for boxes in AugmentationSequential.
# If using 'bbox', kornia assumes boxes are in 'vertices_plus' mode (i.e. (N,4,2) tensor).
# If using 'bbox_xyxy', kornia assumes boxes are in 'xyxy' mode (i.e. (N,4) tensor).
@ashnair1
ashnair1 / CUDA_Compilers.md
Created May 30, 2023 11:15 — forked from ax3l/CUDA_Compilers.md
CUDA Compilers
@ashnair1
ashnair1 / predict.py
Created September 21, 2022 12:28
torchgeo predict using Caleb's SingleRasterDataset
#!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""torchgeo model inference script."""
import argparse
import os
from typing import Any, Callable, Dict, Optional, Tuple, Type, cast
@ashnair1
ashnair1 / Difference between EPSG 4326 & 3857
Created January 12, 2022 12:05 — forked from keum/Difference between EPSG 4326 & 3857
EPSG 4326 and EPSG 3857 of Web Mercator
EPSG: 4326 uses a coordinate system on the surface of a sphere or ellipsoid of reference.
WGS 84 - Earth as Geoid. -Mercator
EPSG: 3857 uses a coordinate system PROJECTED from the surface of the
sphere. Earth as perfectly sphere. -Web Mercator
Think of it as this way:
EPSG 4326 uses a coordinate system the same as a GLOBE (curved surface).
EPSG 3857 uses a coordinate system the same as a MAP (flat surface).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.