Skip to main content

A package for mapping parcels and buildings using various data sources

Project description

building2parcel-training

building2parcel-training is a Python package for mapping parcels and buildings, designed to assist in training models to associate buildings with their corresponding parcels. It provides functionality for loading, processing, and visualizing geospatial data for parcels and buildings.

Features

  • Load and process parcel and building data from shapefiles or geoJSON
  • Optional loading and processing of block data
  • Join parcel and building data based on spatial relationships
  • Split buildings that span multiple parcels
  • Generate maps using Mapbox satellite imagery
  • Customize map output with various options
  • Generate dataset specifications and statistics
  • Support for creating training datasets for building-to-parcel association models

Installation

You can install building2parcel-training using pip:

pip install building2parcel-trainingdata

For development, clone the repository and install in editable mode:

git clone https://github.com/scalable-design-participation-lab/building2parcel-trainingdata.git
cd building2parcel-trainingdata
pip install -e .

Configuration

Before using the package, you need to set up your environment:

  1. Create a .env file in the main folder (it will be a hidden file on Unix-based systems).
  2. In the .env file, add the following lines:
MAPBOX_ACCESS_TOKEN="YOUR-API-KEY"
LOCAL_PATH="YOUR-DROPBOX-PATH/Million Neighborhoods/"

Replace YOUR-API-KEY with your Mapbox Access Token for the Mapbox Web API, and YOUR-DROPBOX-PATH with the path to your Dropbox folder containing the parcel and building data (NYC data is available on our Dropbox).

Usage

Here's a basic example of how to use building2parcel-training:

from building2parcel_trainingdata import Building2ParcelMapper

# Initialize the mapper with paths to your data
parcels_path = "path/to/your/parcels.shp"
buildings_path = "path/to/your/buildings.shp"
blocks_path = "path/to/your/blocks.shp"  # Optional
mapper = Building2ParcelMapper(parcels_path, buildings_path, blocks_path)

# Split buildings (optional)
mapper.split_buildings(threshold_high=0.75, threshold_low=0.15)

# Assign colors to parcels and buildings
mapper.assign_colors()

# Generate dataset specifications and statistics
mapper.generate_dataset_specs(output_folder='./dataset_specs')

# Generate images
parcel_images_directory = "./parcels_output/"
buildings_images_directory = "./buildings_output/"
number_of_images = 100
mapper.generate_images(parcel_images_directory, buildings_images_directory, number_of_images)

Command-line Usage

The package also provides a command-line interface:

python -m building2parcel_trainingdata --buildings_path path/to/buildings.shp --parcels_path path/to/parcels.shp --blocks_path path/to/blocks.shp --split_buildings True --threshold_high 0.75 --threshold_low 0.15 --parcel_images_directory ./parcels_output/ --buildings_images_directory ./buildings_output/ --number_of_images 100

Requirements

  • matplotlib
  • cartopy
  • geopandas
  • python-dotenv
  • Pillow
  • numpy
  • owslib
  • tqdm
  • pandas

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to Mapbox for providing satellite imagery services.
  • This project was developed to support machine learning efforts in associating buildings with their corresponding parcels.

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

building2parcel_trainingdata-0.2.6.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file building2parcel_trainingdata-0.2.6.tar.gz.

File metadata

File hashes

Hashes for building2parcel_trainingdata-0.2.6.tar.gz
Algorithm Hash digest
SHA256 d99493ae93a4ae52532cd64bbb77378580c5358b246e77c1a04dcf21fec55e9c
MD5 f3f76d64f6a9ac272ac69bc07dd2e4e2
BLAKE2b-256 1a4220f42cbb99f0c1e10262fcded8fd0fa49fbcbb9fdc61e909a083b413afad

See more details on using hashes here.

File details

Details for the file building2parcel_trainingdata-0.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for building2parcel_trainingdata-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3080d6fab0f570ee8224dd53baf1c7817d90980f65726e41002f246152c11060
MD5 fe80697bf74484eac14302ddde19dfb3
BLAKE2b-256 399df88797b16fe89e446d9b2e6c4c320e476232325e6a19c6c2665763a1bd39

See more details on using hashes here.

Supported by

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