--- license: mit library_name: pytorch pipeline_tag: feature-extraction tags: - location-encoder - geospatial - implicit-neural-representation - siren - hash-grid --- # NeRF-Earth Location encoders: neural fields over the globe that map a latitude/longitude to a unit-length embedding, for use as features in downstream geospatial models (e.g. a linear or k-NN probe). Each model is a learned multiresolution hash grid on the sphere followed by a SIREN MLP; coordinates are the only input. | Model | Dim | Weights | Training signal | CoordBench R² (random / spatial) | |---|---:|---:|---|---| | `n10` | 1,023 | 4.5 GB | Overture Maps labels + distillation from Overture/Wikipedia encoders | 0.733 / 0.568 | | `smooth_global_seed65` | 256 | 6 MB | Wikipedia contrastive + GeoCLIP distillation | 0.564 / 0.219 | | `hashgrid_depth4_seed54` | 256 | 7 MB | Wikipedia contrastive | 0.544 / 0.214 | The Wikipedia signal is ~12.7M geotagged articles in 320 languages, contrastively aligned with their Cohere `embed-multilingual-v3` text embeddings. ## Usage ```bash pip install torch numpy safetensors huggingface_hub hf download calebrob6/nerf-earth nerf_earth.py --local-dir . ``` ```python from nerf_earth import load encoder = load("n10", device="cuda") # or "smooth_global_seed65", "hashgrid_depth4_seed54" features = encoder.encode(lat=[40.7128, -33.8688], lon=[-74.0060, 151.2093]) print(features.shape) # (2, 1023), float32, unit-length rows ``` - Inputs are **latitude, longitude** in degrees (WGS84), in that order. - `encoder(coords)` is the PyTorch path: `coords` is an `[N, 2]` `(lat, lon)` tensor on the model's device. - `n10` needs about 4.5 GB of CPU or GPU memory for its weights. - `load("path/to/folder")` loads a local copy of a model folder (`config.json` + `model.safetensors`). ## PCA maps The first three principal components (centered PCA) of each model's embeddings over all land, on a 5 km equal-area grid, shown as RGB. Colors are not comparable between models. **n10** ![n10 PCA](https://huggingface.co/calebrob6/nerf-earth/resolve/main/n10/pca3_5km.png) **smooth_global_seed65** ![smooth_global_seed65 PCA](https://huggingface.co/calebrob6/nerf-earth/resolve/main/smooth_global_seed65/pca3_5km.png) **hashgrid_depth4_seed54** ![hashgrid_depth4_seed54 PCA](https://huggingface.co/calebrob6/nerf-earth/resolve/main/hashgrid_depth4_seed54/pca3_5km.png) ## Notes - CoordBench scores are macro R² over 35 regression benchmarks from the [NeuralFTW](https://github.com/taylor-geospatial/neuralftw) standard suite (ridge probe; random and 10° spatial-block splits). These benchmarks were also used during model development, so treat them as development results. Overture layers used to train `n10` overlap some benchmark targets. - Training data: Wikipedia (CC BY-SA), [Overture Maps](https://docs.overturemaps.org/attribution/) (`n10`), and the [GeoCLIP](https://github.com/VicenteVivan/geo-clip) location encoder as a teacher (`smooth_global_seed65`).