Morton Code Converter
Convert between Morton code (Z-order curve) and 2D coordinates (X, Y). Morton code is a space-filling curve that maps multidimensional data to one dimension while preserving locality.
Coordinates to Morton Code
Morton Code to Coordinates
Visualization
How It Works
Morton code interleaves the bits of X and Y coordinates. For example, X=3 (011) and Y=5 (101) become Morton code 27 (011011) by interleaving: 0x1y1x1y.
Example
How to use:
- Coordinates to Morton Code: Enter X and Y coordinates (non-negative integers, 0-65535) and click Convert
- Morton Code to Coordinates: Enter a Morton code (0-4294967295) and click Convert to get X and Y coordinates
- View the binary representation to understand how bits are interleaved
- Copy the results as needed
About Morton Code
Morton code (also known as Z-order curve or Lebesgue curve) is a space-filling curve that maps multidimensional data to one dimension. It interleaves the bits of coordinates, preserving spatial locality. Morton codes are widely used in spatial indexing, database systems, and computer graphics for efficient range queries and spatial data structures. The code allows nearby points in 2D space to have similar Morton codes, making it useful for spatial indexing algorithms.