Skip to content

Commit

Permalink
v0.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-yuchen committed Apr 12, 2024
1 parent 2dd05e2 commit dd693e9
Show file tree
Hide file tree
Showing 21 changed files with 802 additions and 64 deletions.
39 changes: 26 additions & 13 deletions GeoHD.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: GeoHD
Version: 0.2.4
Version: 0.2.5
Summary: A Python toolkit for geospatial hotspot detection, Avisualization, and analysis using urban data
Home-page: https://github.com/yan-yuchen/GeoHD
Author: Yuchen Yan
Expand All @@ -18,8 +18,8 @@ Requires-Dist: h3
# GeoHD

![python](https://img.shields.io/badge/python-3.11-black)
![GitHub release](https://img.shields.io/badge/release-v0.2.4-blue)
![pypi](https://img.shields.io/badge/pypi-v0.2.4-orange)
![GitHub release](https://img.shields.io/badge/release-v0.2.5-blue)
![pypi](https://img.shields.io/badge/pypi-v0.2.5-orange)
![license](https://img.shields.io/badge/license-GNU%20AGPLv3-green)

[**Getting Started**](#getting-started)
Expand All @@ -40,6 +40,10 @@ The main functions of GeoHD are fast visualization and hotspot detection based o

## Getting Started

### Documentation

We recommend starting your GeoHD journey with the [documentation](https://geohd.readthedocs.io/en/latest/).

### Install with pip

The package is available in PyPi and requires [Python 3.11](https://www.python.org/downloads/) or higher. It can be installed using:
Expand All @@ -50,14 +54,23 @@ $ pip install GeoHD

### Usage

A case-testing approach:

```bash
$ cd test
$ python -m test_automation
```

You can also run `test.ipynb` in jupyter notebook

Visualization of hotspots on real maps:

```python
visualize_shapefile('data.shp', output_image_path='custom_image.png')
```

<p align="center">
<img src="./doc/1.png" width="400" height="300"/>
<img src="./picture/1.png" width="400" height="300"/>
</p>


Expand All @@ -68,7 +81,7 @@ plot_g_function('data.shp')
```

<p align="center">
<img src="./doc/2.png" width="400" height="300"/>
<img src="./picture/2.png" width="400" height="300"/>
</p>

The study area was divided into a quadrilateral (hexagonal) grid and fast visualization was achieved based on the density of point data within the divided area.
Expand All @@ -81,13 +94,13 @@ create_hexagonal_heatmap(area_file, crash_file)
```

<p align="center">
<img src="./doc/3.png" width="400" height="300"/>
<img src="./doc/4.png" width="400" height="300"/>
<img src="./picture/3.png" width="400" height="300"/>
<img src="./picture/4.png" width="400" height="300"/>
</p>

<p align="center">
<img src="./doc/5.png" width="400" height="300"/>
<img src="./doc/6.png" width="400" height="300"/>
<img src="./picture/5.png" width="400" height="300"/>
<img src="./picture/6.png" width="400" height="300"/>
</p>

Realization of kernel density analysis with fixed bandwidth:
Expand All @@ -104,7 +117,7 @@ adaptiveKDE(shp_file,output_data_path)
```

<p align="center">
<img src="./doc/8.png" width="400" height="300"/>
<img src="./picture/8.png" width="400" height="300"/>
</p>


Expand All @@ -116,7 +129,7 @@ visualize_hotspots(np.load(density_data_path), hotspots)
```

<p align="center">
<img src="./doc/9.png" width="400" height="300"/>
<img src="./picture/9.png" width="400" height="300"/>
</p>


Expand All @@ -137,8 +150,8 @@ The authors of the GeoHD package welcome external contributions to the source co
## Citation




## Authors

* Yuchen Yan
* Yuxin Wang
* Wei Quan
2 changes: 1 addition & 1 deletion GeoHD.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ setup.py
GeoHD/AKDE.py
GeoHD/__init__.py
GeoHD/analyze.py
GeoHD/clustering.py
GeoHD/process.py
GeoHD/utils.py
GeoHD/visualize.py
Expand All @@ -14,4 +13,5 @@ GeoHD.egg-info/SOURCES.txt
GeoHD.egg-info/dependency_links.txt
GeoHD.egg-info/requires.txt
GeoHD.egg-info/top_level.txt
test/test_automation.py
test_local/__init__.py
23 changes: 17 additions & 6 deletions GeoHD/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,20 @@ def plot_l_function(data_path):
plt.show()

# Example usage:
# Replace './data/crash.shp' with the path to your shapefile
# plot_g_function('./data/crash.shp')
# plot_f_function('./data/crash.shp')
# plot_j_function('./data/crash.shp')
# plot_k_function('./data/crash.shp')
# plot_l_function('./data/crash.shp')
if __name__ == "__main__":
import os
# Define the name of the folder to be created
folder_name = 'output'
# Check if the folder exists, if not, create it
if not os.path.exists(folder_name):
os.makedirs(folder_name)
print(f"Folder '{folder_name}' has been created.")
else:
print(f"Folder '{folder_name}' already exists.")
# Example usage:
# Replace './data/crash.shp' with the path to your shapefile
plot_g_function('./data/crash.shp')
plot_f_function('./data/crash.shp')
plot_j_function('./data/crash.shp')
plot_k_function('./data/crash.shp')
plot_l_function('./data/crash.shp')
10 changes: 0 additions & 10 deletions GeoHD/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,13 +991,3 @@ def check_shapefile(filename):
print("Error:", e)
return False # The file is not a valid GeoDataFrame






# Example usage:
if __name__ == "__main__":
density_data_path = './output/AKDE_density_grid.npy'
hotspots = extract_hotspots(density_data_path)
visualize_hotspots(np.load(density_data_path), hotspots)
36 changes: 23 additions & 13 deletions GeoHD/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,26 @@ def create_hexagonal_heatmap(area_file, crash_file, resolution=8):
plt.ylabel('Latitude')
plt.show()



# Example usage
# create_cell_zones('./data/area.shp', './data/crash.shp')

# Example usage
# create_hex_grid_zones('./data/area.shp', './data/crash.shp')

# Example usage
# create_cell_heatmap('./data/area.shp', './data/crash.shp')

# Example usage
# create_hexagonal_heatmap('./data/area.shp', './data/crash.shp')
# Example usage:
if __name__ == "__main__":
import os
# Define the name of the folder to be created
folder_name = 'output'
# Check if the folder exists, if not, create it
if not os.path.exists(folder_name):
os.makedirs(folder_name)
print(f"Folder '{folder_name}' has been created.")
else:
print(f"Folder '{folder_name}' already exists.")

# Example usage
create_cell_zones('./data/area.shp', './data/crash.shp')

# Example usage
create_hex_grid_zones('./data/area.shp', './data/crash.shp')

# Example usage
create_cell_heatmap('./data/area.shp', './data/crash.shp')

# Example usage
create_hexagonal_heatmap('./data/area.shp', './data/crash.shp')
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# GeoHD

![python](https://img.shields.io/badge/python-3.11-black)
![GitHub release](https://img.shields.io/badge/release-v0.2.4-blue)
![pypi](https://img.shields.io/badge/pypi-v0.2.4-orange)
![GitHub release](https://img.shields.io/badge/release-v0.2.5-blue)
![pypi](https://img.shields.io/badge/pypi-v0.2.5-orange)
![license](https://img.shields.io/badge/license-GNU%20AGPLv3-green)

[**Getting Started**](#getting-started)
Expand Down Expand Up @@ -37,6 +37,15 @@ $ pip install GeoHD

### Usage

A case-testing approach:

```bash
$ cd test
$ python -m test_automation
```

You can also run `test.ipynb` in jupyter notebook

Visualization of hotspots on real maps:

```python
Expand Down Expand Up @@ -127,3 +136,5 @@ The authors of the GeoHD package welcome external contributions to the source co
## Authors

* Yuchen Yan
* Yuxin Wang
* Wei Quan
Binary file removed dist/GeoHD-0.2.4-py3-none-any.whl
Binary file not shown.
Binary file removed dist/GeoHD-0.2.4.tar.gz
Binary file not shown.
Binary file added dist/GeoHD-0.2.5-py3-none-any.whl
Binary file not shown.
Binary file added dist/GeoHD-0.2.5.tar.gz
Binary file not shown.
Loading

0 comments on commit dd693e9

Please sign in to comment.