Skip to main content

A convolution-based approach to detect urban extents.

Project description

PyPI version fury.io Documentation Status CI/CD pre-commit.ci status codecov GitHub license Binder DOI

Urban footprinter

A reusable convolution-based approach to detect urban extents from raster datasets.

LULC Convolution result Computed urban extent
LULC Convolution result Urban extent

The approach is built upon the methods used in the Atlas of Urban Expansion. The main idea is that a pixel is considered part of the urban extent depending on the proportion of built-up pixels that surround it. See the notebook overview or this blog post for a more detailed description of the procedure.

Citation: Bosch M. 2020. "Urban footprinter: a convolution-based approach to detect urban extents from raster data". Available from https://github.com/martibosch/urban-footprinter. Accessed: DD Month YYYY.

An example BibTeX entry is:

@misc{bosch2020urban,
  title={Urban footprinter: a convolution-based approach to detect urban extents from raster data},
  author={Bosch, Mart\'{i}},
  year={2020},
  doi={10.5281/zenodo.3699310},
  howpublished={Available from \url{https://github.com/martibosch/urban-footprinter}. Accessed: DD Month YYYY},
}

Installation and usage

To install use pip:

$ pip install urban-footprinter

Then use it as:

import urban_footprinter as ufp

# Or use `ufp.urban_footprint_mask_shp` to obtain the urban extent as a
# shapely geometry
urban_mask = ufp.urban_footprint_mask(
    "path/to/raster.tif", kernel_radius, urban_threshold, urban_classes=urban_classes
)

where

help(ufp.urban_footprint_mask)

Help on function urban_footprint_mask in module urban_footprinter:

urban_footprint_mask(raster, kernel_radius, urban_threshold, urban_classes=None, num_patches=1,
                     buffer_dist=None, res=None)
    Computes a boolean mask of the urban footprint of a given raster.

    Parameters
    ----------
    raster : ndarray or str, file object or pathlib.Path object
        Land use/land cover (LULC) raster. If passing a ndarray (instead of the
        path to a geotiff), the resolution (in meters) must be passed to the
        `res` keyword argument.
    kernel_radius : numeric
        The radius (in meters) of the circular kernel used in the convolution.
    urban_threshold : float from 0 to 1
        Proportion of neighboring (within the kernel) urban pixels after which
        a given pixel is considered urban.
    urban_classes : int or list-like, optional
        Code or codes of the LULC classes that must be considered urban. Not
        needed if `raster` is already a boolean array of urban/non-urban LULC
        classes.
    num_patches : int, default 1
        The number of urban patches that should be featured in the returned
        urban/non-urban mask. If `None` or a value lower than one is provided,
        the returned urban/non-urban mask will features all the urban patches.
    buffer_dist : numeric, optional
        Distance to be buffered around the urban/non-urban mask. If no value is
        provided, no buffer is applied.
    res : numeric, optional
        Resolution of the `raster` (assumes square pixels). Ignored if `raster`
        is a path to a geotiff.

    Returns
    -------
    urban_mask : ndarray

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

urban_footprinter-0.3.1.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

urban_footprinter-0.3.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file urban_footprinter-0.3.1.tar.gz.

File metadata

  • Download URL: urban_footprinter-0.3.1.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for urban_footprinter-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2529bb03ef33b68356da46deffcc3c994f4f256e326ccabbe81d863958c4efbe
MD5 21239ea82b05457143d95ab92d390f18
BLAKE2b-256 9278ffeff524d64b5fbed8be4f6cc39ce8c35aee63eb6208ab44f6d280b8ca97

See more details on using hashes here.

Provenance

The following attestation bundles were made for urban_footprinter-0.3.1.tar.gz:

Publisher: release.yml on martibosch/urban-footprinter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file urban_footprinter-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for urban_footprinter-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dde270d50113d802cfaded979e6d4f783c99138273dd7f1ae8764063cbeb50e9
MD5 d1a0ea070c44506f8b38b361da6069c6
BLAKE2b-256 482d9091912f1dcabcc9e26f82c3e1c0c5e0d06bdc797081b337c29ef2638886

See more details on using hashes here.

Provenance

The following attestation bundles were made for urban_footprinter-0.3.1-py3-none-any.whl:

Publisher: release.yml on martibosch/urban-footprinter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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