Skip to main content

A package for calculating land use mix indices

Project description

Land Use Mix Python Package

Overview

The landusemix package provides tools for calculating land use mix indices. These indices can be used to measure the diversity and concentration of land use areas, which is valuable for GIS researchers and urban planners.

Features

  • Entropy Index: Measures the diversity of land use. Values range from 0 (no diversity) to 1 (maximum diversity).
  • Herfindahl-Hirschman Index (HHI): Measures the concentration of land use. Values range from 0 (many small equally-sized areas) to 10,000 (one single area).

Installation

You can install the package using pip:

pip install landusemix

Usage

Here's how you can use the landusemix package to calculate the entropy and HHI indices.

Importing the Package

from landusemix import LandUseMixIndices

To import the utility functions of the package:

from landusemix.utils import *

Loading Data

# Example land use areas (in square meters)
land_use_areas = {
    'residential': 5000,
    'commercial': 3000,
    'industrial': 2000,
}

# Create an instance of the LandUseMixIndices class
mix_indices = LandUseMixIndices(land_use_areas)

# Calculate the entropy index
entropy = mix_indices.entropy_index()
print(f"Entropy Index: {entropy}")

# Calculate the Herfindahl-Hirschman Index (HHI)
hhi = mix_indices.herfindahl_hirschman_index()
print(f"Herfindahl-Hirschman Index: {hhi}")

You can also load data from various formats including GeoJSON, Shapefile, and CSV.

Example: Loading GeoJSON Data

geojson_data = load_geojson('path_to_your_file.geojson')

Example: Loading Shapefile Data

shapefile_data = load_shapefile('path_to_your_file.shp')

Example: Loading CSV Data

csv_data = load_csv('path_to_your_file.csv')

Using Sample Data

The package includes sample data files for testing and demonstration purposes.

Example: Loading Sample GeoJSON Data

geojson_gdf = load_sample_geojson()
geojson_gdf['area'] = geojson_gdf.geometry.area
sample_land_use_areas = geojson_gdf.groupby('use')['area'].sum().to_dict()
print(sample_land_use_areas)

Example: Loading Sample Shapefile Data

shapefile_gdf = load_sample_shapefile()
shapefile_gdf['area'] = shapefile_gdf.geometry.area  # Ensure the CRS is in a metric format for accurate area calculation 
sample_land_use_areas = shapefile_gdf.groupby('use')['area'].sum().to_dict()
print(sample_land_use_areas)

Example: Loading Sample CSV Data

sample_land_use_areas = sample_csv.set_index('use')['area'].to_dict()
print(sample_land_use_areas)

Indices Description

  • Entropy Index:

The entropy index (ENT) is a measure of diversity in land use types within a given area. It is calculated using the following formula:

$$ \mathrm{ENT}=-\frac{\left[\sum_{i=1}^k P_i \ln \left(P_i\right)\right]}{\ln (k)} $$

Here's an explanation of the parameters in this formula:

$P_i$: This represents the proportion of the total area that is occupied by the ith land use type. It is calculated by dividing the area of the ith land use type by the total area.

$ln(P_i)$: This is the natural logarithm of P_i.

$\sum$: This is the sum operator. It sums the product of P_i and ln(P_i) for all land use types from i = 1 to i = k.

$k$: This is the total number of different land use types.

$ln(k)$: This is the natural logarithm of k.

The ENT value will be between 0 and 1. A higher ENT value indicates a more diverse mix of land use types, while a lower ENT value indicates a less diverse mix.

  • Herfindahl-Hirschman Index (HHI):

The Herfindahl-Hirschman Index (HHI) is a measure of the concentration of land use types within a given area. It is calculated using the following formula:

$$ \mathrm{HHI}=\sum_{i=1}^k\left(100 \times P_i\right)^2 $$

Here's an explanation of the parameters in this formula:

$P_i$: This represents the proportion of the total area that is occupied by the ith land use type. It is calculated by dividing the area of the ith land use type by the total area.

$100 x P_i$: This is the proportion of the ith land use type, expressed as a percentage.

$(100 x P_i)^2$: This squares the percentage proportion of the ith land use type.

$\sum$: This is the sum operator. It sums the squared percentage proportions for all land use types from i = 1 to i = k.

The HHI value will be between 0 and 10000 (if expressed as a percentage). A higher HHI value indicates a less diverse mix of land use types (i.e., a higher concentration of certain types), while a lower HHI value indicates a more diverse mix.

For more detailed documentation, please visit our ReadTheDocs page.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact

For any questions or support, please reach out to akyol.mehmet@metu.edu.tr.

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

landusemix-0.1.3.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

landusemix-0.1.3-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file landusemix-0.1.3.tar.gz.

File metadata

  • Download URL: landusemix-0.1.3.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for landusemix-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1a39c0bebaf09007ff9fc1df98cc3ba3e12deba7e0c8e124c7c48461436093b5
MD5 37a08a4681006b6deab3a733d7e641b5
BLAKE2b-256 4916b68368ea5e6e3abbfd383297d741b442a30780a13df3aa1e32dac055cd2b

See more details on using hashes here.

File details

Details for the file landusemix-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: landusemix-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for landusemix-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f862942e7fe9d1862751fd460281cd60f6ee06afeea88b941e45fb7e04789f4a
MD5 cdef2883fa68c1acb745ec4d8167d208
BLAKE2b-256 530ec86dead793dc116849b1230a66a41462b9b3c4757adf1b06191a27e8d3a0

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