Download app/spatial.py from lablab-ai-amd-developer-hackathon/riprap-nyc: direct link, hf CLI and curl.
- Browser
- Download file 629 Bytes
-
https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/riprap-nyc/resolve/main/app/spatial.py
- Command line
-
hf download hf://spaces/lablab-ai-amd-developer-hackathon/riprap-nyc/app/spatial.py
-
curl -L -o spatial.py https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/riprap-nyc/resolve/main/app/spatial.py
629 Bytes
| """Spatial helpers. NYC works in EPSG:2263 (NY state plane, feet).""" | |
| from __future__ import annotations | |
| from pathlib import Path | |
| import geopandas as gpd | |
| NYC_CRS = "EPSG:2263" # ft | |
| WGS84 = "EPSG:4326" | |
| DATA = Path(__file__).resolve().parent.parent / "data" | |
| def to_nyc(g: gpd.GeoDataFrame) -> gpd.GeoDataFrame: | |
| if g.crs is None: | |
| raise ValueError("layer has no CRS") | |
| return g.to_crs(NYC_CRS) if g.crs.to_string() != NYC_CRS else g | |
| def load_layer(path: str | Path, layer: str | None = None) -> gpd.GeoDataFrame: | |
| g = gpd.read_file(path, layer=layer) if layer else gpd.read_file(path) | |
| return to_nyc(g) | |