/urban_datasets

Repository with the code for generation of urban datasets (top view / masterplan) based on QGis software.

Primary LanguagePythonMIT LicenseMIT

Urban Datasets Generator

This script is intended to be used inside QGIS Software to create an image urban datasets. The contents of the images can vary based on the shapefiles available to you:)

These images were created using the script presented in this repo. The data were taken from Comune di Milano.

Arxiv | SimAUD Video Presentation (8 min)

To use Pix2Pix GAN models on the generated images, refer to Urban Gen repo

How To Use

  1. Open QGIS
  2. Upload your shapefiles and style them according to your needs
  3. Go to Plugins -> Python Console
  4. NAvigate to city_generator.py and choose it
  5. Set the variables:
  • SAMPLES - number of images to generate
  • BASE_PATH - path to save the images to
  1. Change the variable trainA to True if you need to generate both the normal set and the set with a central block painted in white.
  2. Set the variable EXTRA to True if ou want to generate annotations of building density and green density. Make sure to provide the name of the green layer!
  3. To adapt the files to pix2pix:
$python change_dim.py FOLDER [--folder1 FOLDER1] [--concat 1]
  • FOLDER - path to the folder with the images (trainB)
  • folder1 - path to the second folder with the images (trainA) optional
  • concat - an option to concat two images together, the output will be stored in trainAB
  1. Enjoy!

Images only for some specific blocks

You can also generate images just for some specific blocks. Make sure they are on a separate layer and provide your layer name as the interest_layer in the end of the script file. If you want to generate images in one specific region only (e.g. city center), make a separate layer with a polygon delimiting this zone and add the name of this layer as region_layer in the end of the script file.

What if I don't have any shapefiles?

Don't worry! There is a script that gets the shapefiles from the region you need directly from OpenStreetMap data (OdBL license). The script will make one shapefile with the roads and one with the buildings. Find a good location for your dataset and follow the steps:

  1. Install Conda
  2. Install osmnx package in a new environment named osm
$conda config --prepend channels conda-forge
$conda create -n osm --strict-channel-priority osmnx
  1. Activate the environment:
$conda activate osm
  1. Run the script, placing the name of your geographical location inside (make sure it corresponds to osm naming and query):
$python get_shapefiles.py "City, Country"

If you do not need the whole city shapefile to be downloaded you can specify just one zone:

$python get_shapefiles.py "Zone, City, Country"

Example:

$python get_shapefiles.py "Bovisa, Milan, Italy"

Metrics calculation

To calculate metrics:

$python metrics.py images_folder

images_folder should contain concatenated images (A+B).

Citation

Bibtex format

@inproceedings{gan4ud,
    author = {Fedorova, Stanislava},
    title = {GANs for Urban Design},
    year = {2021},
    month = {04},
    pages = {9},
    booktitle = {In proceedings of 12th Symposium on Simulation for Architecture and Urban Design (SimAUD 2021)}
}

Credits

OpenStreetMap

QGIS

Portal of Open Data of Comune di Milano