Skip to main content

Building Footrprint Extraction from Aerial LiDAR data

Project description

This Python package is BUilding Footprint Extractor Test

This of example of an how you can run your code

import LasBuildSeg as lasb
import numpy as np

# Define input parameters
input_laz = '<input>.laz'  # Path to the input laz/las data file
epsg_code = <epsg_code>  # EPSG code of the input laz data
multy = <DTM non-ground multipalction number>  # Multiplication factor for DSM height enhancement
intermethod = '<interpolation method>'  # Interpolation method ('cubic', 'nearest', or 'linear')

# Define default parameter values
constant = 3.6  # Adaptive threshold constant
block_size = 51  # Adaptive threshold block size
kernel_size = 3  # Morphological open kernel size
tri_threshold = 3  # Terrain Ruggedness Index threshold

# Define contour filtering parameters
min_size = 35
max_size = 5000
squareness_threshold = 0.3
width_threshold = 3
height_threshold = 3
CloseKernel_size = 15

# Generate DSM and DTM
lasb.generate_dsm(input_laz, epsg_code, intermethod)
lasb.generate_dtm(input_laz, epsg_code, intermethod, multy)

# Generate NDHM
lasb.generate_ndhm('dtm.tif', 'dsm.tif')

# Read NDHM image and profile
img, profile = lasb.read_geotiff('ndhm.tif')

# Transform DSM
lasb.DSM_transform('dsm.tif')

# Read transformed DSM and profile
dem, _ = lasb.read_geotiff('dsm3857.tif')

# Convert image to 8-bit
img_8bit = lasb.to_8bit(img)

# Apply adaptive thresholding
img_thresh = lasb.threshold(img_8bit, block_size, constant)

# Apply morphological opening
img_open = lasb.morph_open(img_thresh, kernel_size)

# Filter contours without TRI
building_mask=lasb.filter_contours(img_open, dem, profile, min_size, max_size, squareness_threshold, width_threshold, height_threshold, tri_threshold)

# Apply morphological closing
building_mask_closed = lasb.close(building_mask, CloseKernel_size)

# Write building mask to GeoTIFF
lasb.write_geotiff('buildings.tif', building_mask_closed, profile)

# Convert building mask to GeoJSON
lasb.building_footprints_to_geojson('buildings.tif', 'building.geojson')

# Print completion message
print('All steps are complete.')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

LasBuildSeg-0.1.27.tar.gz (15.9 kB view details)

Uploaded Source

File details

Details for the file LasBuildSeg-0.1.27.tar.gz.

File metadata

  • Download URL: LasBuildSeg-0.1.27.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for LasBuildSeg-0.1.27.tar.gz
Algorithm Hash digest
SHA256 50d6de59b6056b57d57612731ce4dcef4bb63fae999d3e57d50dce20d82e3da6
MD5 d84dceeaa553d619b5d36546aa5b94ec
BLAKE2b-256 cb9ead7b33789009d5b80fedfd62a320255eb8c788e7ee68bdce1366ae3ff697

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page