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.
- 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).
You can install the package using pip:
pip install landusemix
Here's how you can use the landusemix
package to calculate the entropy and HHI indices.
from landusemix import LandUseMixIndices
To import the utility functions of the package:
from landusemix.utils import *
# 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.
geojson_data = load_geojson('path_to_your_file.geojson')
shapefile_data = load_shapefile('path_to_your_file.shp')
csv_data = load_csv('path_to_your_file.csv')
The package includes sample data files for testing and demonstration purposes.
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)
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)
sample_land_use_areas = sample_csv.set_index('use')['area'].to_dict()
print(sample_land_use_areas)
- 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:
Here's an explanation of the parameters in this formula:
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:
Here's an explanation of the parameters in this formula:
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.
This project is licensed under the MIT License. See the LICENSE
file for more details.
For any questions or support, please reach out to [email protected].