mirrorworld.lidar: LiDAR point clouds¶
Point clouds for a bounding box from Entwine Point Tile (EPT) datasets, fetching only the octree nodes that
intersect the box down to a chosen spacing. Returns laspy.LasData. Needs pip install mirrorworld[lidar].
USGS 3DEP¶
- find_datasets(north, west, south, east, refresh=False)[source]¶
Lists the surveys whose coverage intersects a bounding box, newest first.
- Parameters:
- Returns:
A list of Dataset objects.
- Return type:
- get_points(north, west, south, east, dataset=None, resolution=None, classes=None, max_points=50000000)[source]¶
Reads 3DEP LiDAR points inside a bounding box.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
dataset (str | None) – (optional) Survey name from
find_datasets(). Defaults to the newest one covering the box.resolution (float | None) – (optional) Wanted point spacing in meters (Web Mercator units). Defaults to all points.
classes (Iterable[int] | None) – (optional) Keep only these ASPRS classes, e.g.
[6]for buildings.max_points (int) – (optional) Refuse larger requests. Defaults to 50 million.
- Returns:
A
laspy.LasDatain EPSG:3857.
- async get_points_async(north, west, south, east, session, dataset=None, resolution=None, classes=None, max_points=50000000)[source]¶
- download_points(north, west, south, east, path, **kwargs)[source]¶
Same as
get_points(), then writes a.lazor.lasfile.Usage sample:
from mirrorworld.lidar import usgs3dep print(usgs3dep.find_datasets(47.6068, -122.3340, 47.6058, -122.3325)) las = usgs3dep.download_points(47.6068, -122.3340, 47.6058, -122.3325, "seattle.laz", resolution=1.0) ground = las.points[las.classification == 2]
Environment Agency National LIDAR Programme (England)¶
Environment Agency LiDAR point clouds for England, from the Defra Survey Data Download service (https://environment.data.gov.uk/survey). Open Government Licence v3 (attribution: Environment Agency), no key.
The default product is the National LIDAR Programme (NLP) point cloud, surveyed since 2016/17. The data comes as whole 5 km British National Grid tiles (e.g.
TL4055), one zipped LAZ per tile and survey year, typically 0.2-0.4 GB each: there is no way to fetch only part of a tile. Tiles are downloaded once into a cache directory and cropped locally.Points are in EPSG:27700 with heights in meters above Ordnance Datum Newlyn, classified to ASPRS codes (1 unclassified, 2 ground, 3-5 vegetation, 6 building, 7 noise), without RGB. Surveys up to 2021 are mostly LAS 1.2 point format 1, later ones LAS 1.4 point format 6; density is about 2-6 points per m², higher in recent years. The year is the survey’s nominal year; the file name records the flight dates, which can start in the previous winter.
search()asks the service which tiles, products and years cover a box (the same request as the download page’s “Get available tiles”). Don’t guess years by requesting tile URLs: under load the service answers “no data” for tiles that exist.
- get_points(north, west, south, east, year=None, directory=None, classes=None, max_tiles=4, product='national_lidar_programme_point_cloud')[source]¶
Reads point cloud data inside a bounding box, downloading the 5 km tiles it touches if they are not cached.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
year (int | None) – (optional) Survey year for every tile. Defaults to the newest year of each tile, so a box across a tile edge can mix survey years.
directory (str | None) – (optional) Where to keep the downloaded tiles. Defaults to
cache_dir().classes (Iterable[int] | None) – (optional) Keep only these ASPRS classes, e.g.
[2]for ground.max_tiles (int) – (optional) Refuse boxes needing more tiles than this (each is a 0.2-0.4 GB download). Defaults to 4.
product (str) – (optional) Point cloud product ID. Defaults to the NLP point cloud.
- Returns:
A
laspy.LasDatain EPSG:27700, heights above Ordnance Datum Newlyn.- Raises:
ValueError – If the box needs too many tiles, or no tile has data.
- download_points(north, west, south, east, path, **kwargs)[source]¶
Same as
get_points(), then writes a.lazor.lasfile.
- search(north, west, south, east, product='national_lidar_programme_point_cloud')[source]¶
Lists the tiles covering a bounding box, from the service’s own tile search.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
product (str | None) – (optional) Keep only this product. Defaults to the NLP point cloud;
Nonereturns every survey product (DTM/DSM rasters, olderlidar_point_cloudsurveys, aerial photography, …).- Returns:
Tiles sorted by tile name, then newest year first.
- Return type:
- find_years(tile, product='national_lidar_programme_point_cloud')[source]¶
Lists the survey years available for a 5 km tile, newest first.
- download_tile(tile, year=None, directory=None, product='national_lidar_programme_point_cloud')[source]¶
Downloads one tile and extracts its LAZ, unless it is already in
directory. The zip is not kept.
- Parameters:
tile (str) – Tile name, e.g.
TL4055.year (int | None) – (optional) Survey year. Defaults to the newest available.
directory (str | None) – (optional) Where to keep the LAZ files. Defaults to
cache_dir().product (str) – (optional) Point cloud product ID. Defaults to the NLP point cloud.
- Returns:
Path of the LAZ file,
<directory>/<product>/<year>/<name>.laz, keeping the provider’s file name (tile, survey project and flight dates, e.g.TL4055_P_12744_20230213_20230213.laz).- Raises:
ValueError – If the tile has no data (for that year), or the zip does not hold exactly one LAZ.
- Return type:
- tile_name(easting, northing)[source]¶
Name of the 5 km tile containing a British National Grid point, e.g.
TL4055for E 541000, N 257500.
- crop_files(paths, bounds, classes=None, chunk_size=5000000)[source]¶
Crops LAS/LAZ files to a box and merges them, reading in chunks so whole tiles never sit in memory.
- Parameters:
- Returns:
A
laspy.LasDatawith the header (point format, scales, offsets, CRS) of the first file with points in the box; points from files in another point format are converted to it.
- cache_dir()[source]¶
Default tile cache:
$MIRRORWORLD_CACHE/ea-lidarif set, else$XDG_CACHE_HOME/mirrorworld/ea-lidar, else~/.cache/mirrorworld/ea-lidar.
- Return type:
- class Tile(product, year, resolution, tile, label, url)[source]¶
One downloadable tile of one survey product and year.
- product: str¶
Product ID, e.g.
national_lidar_programme_point_cloudornational_lidar_programme_dtm.Usage sample:
from mirrorworld.lidar import ea print(ea.search(51.5085, -0.1290, 51.5070, -0.1260)) # tiles and survey years covering the box las = ea.get_points(51.5085, -0.1290, 51.5070, -0.1260) # downloads and caches each tile once ground = las.points[las.classification == 2]
Any EPT dataset¶
- get_points(url, north, west, south, east, resolution=None, classes=None, max_points=50000000, max_concurrency=8)[source]¶
Reads the points of an EPT dataset inside a bounding box.
- Parameters:
url (str) – Dataset URL.
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
resolution (float | None) – (optional) Wanted point spacing in CRS units; deeper (denser) octree levels are skipped. Defaults to all points.
classes (Iterable[int] | None) – (optional) Keep only these ASPRS classification codes, e.g.
[2](ground) or[6](building). Defaults to all.max_points (int) – (optional) Refuse requests whose candidate nodes hold more points than this. Defaults to 50 million.
max_concurrency (int) – (optional) Maximum number of simultaneous downloads. Defaults to 8.
- Returns:
A
laspy.LasDatain the dataset’s CRS (written into the header).
- async get_points_async(url, north, west, south, east, session, resolution=None, classes=None, max_points=50000000, max_concurrency=8)[source]¶
- download_points(url, north, west, south, east, path, **kwargs)[source]¶
Same as
get_points(), then writes a.lazor.lasfile.
- class EptInfo(url, bounds, bounds_conforming, span, points, crs, schema)[source]¶
The header of an EPT dataset (
ept.json).
- Parameters:
- bounds: Tuple[float, float, float, float, float, float]¶
Octree cube: minx, miny, minz, maxx, maxy, maxz.
- bounds_conforming: Tuple[float, float, float, float, float, float]¶
Tight bounds of the actual points.