Skip to main content

A convolution-based approach to detect urban extents.

Project description

PyPI version fury.io Build Status Coverage Status GitHub license Binder

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.

Installation and usage

To install use pip:

$ pip install urban-footprinter

Or clone the repo:

$ git clone https://github.com/martibosch/urban-footprinter.git
$ python setup.py install

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, largest_patch_only=True, 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.
    largest_patch_only : boolean, default True
        Whether the returned urban/non-urban mask should feature only the
        largest urban patch.
    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.2.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

urban_footprinter-0.2.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file urban-footprinter-0.2.0.tar.gz.

File metadata

  • Download URL: urban-footprinter-0.2.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0.post20200209 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for urban-footprinter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d01ec04f8f43fdde568fc8cf94a262d9f3e3294196503f36699b4e639c7b9057
MD5 0e3b99680a10dc7487b24a6cde6cdb54
BLAKE2b-256 86d025cc27bf37940b42b30f1492d172bac7f421d0026fff2754f89aeb28d44d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for urban_footprinter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7df8642a8654f2f1543db74ebe85bf52b090fdecb590cf5ad39651b0b2ce7513
MD5 9cd1571520e48f1e121617b67b14d0d2
BLAKE2b-256 af721947e793ff85eb0f2f3c3be41078cdeb0466fad11ade0c8572a326bb6896

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