This repository was archived by the owner on Sep 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: README.md
- Loading branch information
Showing
16 changed files
with
346 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,26 +29,64 @@ and usage of hexagonal raster grids. These tools rely on the | |
Future work includes the development of a Graphical User Interface (GUI) for | ||
these tools on QGIS, making the usage of hexagonal grids even simpler. | ||
|
||
|
||
This tool suite can be installed from the [PyPi repository](https://pypi.python.org/pypi/hex-utils). | ||
|
||
|
||
|
||
Software dependencies | ||
|
||
Installation Requirements | ||
------------------------------------------------------------------------------- | ||
|
||
The `hasc2gml` script requires the GDAL library. On Debian based systems it can | ||
be installed with the following command: | ||
The `hasc2gml` script requires the Python GDAL library; the `asc2hasc` script | ||
requires the `scipy` library. At this moment there are no functional universal | ||
Python packages available for these libraries. Therefore system specific | ||
packages are required in these cases. On Debian based systems they can be | ||
installed with the following command: | ||
|
||
`sudo apt install python3-gdal python3-scipy` | ||
|
||
The Python package manager is required to install dependencies; on Debian based | ||
systems it can be obtained like: | ||
|
||
`sudo apt install python3-pip` | ||
|
||
Installing from PyPi | ||
------------------------------------------------------------------------------- | ||
|
||
The easiest way to install `hex-utils` is through the universal package | ||
available from the Python Package Index (PyPi); an example again on Debian | ||
based systems: | ||
|
||
`sudo pip3 install hex-utils` | ||
|
||
Installing from GitHub | ||
------------------------------------------------------------------------------- | ||
|
||
Start by cloning the repository to your system: | ||
|
||
`git clone [email protected]:ldesousa/hex-utils.git` | ||
|
||
Change to the new folder: | ||
|
||
`cd hex-utils.git` | ||
|
||
It is possible to install directly from the `master` branch, but it is more | ||
advisable to use of the [tagged releases](https://github.com/ldesousa/hex-utils/releases), | ||
*e.g.*: | ||
|
||
`git checkout tags/v2.2` | ||
|
||
`apt install python-gdal` | ||
Then install the scripts system wide: | ||
|
||
It can also be installed from the PyPi repository (the best option for virtual | ||
environments): | ||
`sudo python3 setup.py install` | ||
|
||
`pip instal GDAL` | ||
Finally, install the remaining dependencies: | ||
|
||
`sudo pip3 install -r requirements.txt` | ||
|
||
Licence | ||
------------------------------------------------------------------------------- | ||
|
||
This suite of programmes is released under the EUPL 1.1 licence. For further | ||
details please consult the LICENCE file. | ||
This suite of programmes is released under the [EUPL 1.1 licence](https://joinup.ec.europa.eu/community/eupl/og_page/introduction-eupl-licence). | ||
For full details please consult the LICENCE file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/python3 | ||
# coding=utf8 | ||
# | ||
# Copyright (c) 2016 - Luís Moreira de Sousa | ||
# | ||
# Transforms ASCII encoded cartographic hexagonal grids [0] into GeoJSON. | ||
# A geometric hexagon is generated for each grid cell and encoded as a feature | ||
# in the output JSON file. The cell value is saved in the 'value' attribute of | ||
# the new feature. | ||
# | ||
# Author: Luís Moreira de Sousa (luis.de.sousa[@]protonmail.ch) | ||
# Date: 11-10-2016 | ||
# | ||
# [0] https://github.com/ldesousa/HexAsciiBNF | ||
|
||
import sys | ||
from hex_utils.hasc import HASC | ||
|
||
def wrongUsage(): | ||
|
||
print("This programme requires two arguments:\n" + | ||
" - path to an input HASC file \n" + | ||
" - path to the output GeoJSON file \n" + | ||
"Usage example: \n" | ||
" hasc2gml /path/to/input.hasc /path/to/output.json") | ||
sys.exit() | ||
|
||
|
||
def processArguments(args): | ||
|
||
global inputFile | ||
global outputFile | ||
|
||
if len(args) < 3: | ||
wrongUsage() | ||
else: | ||
inputFile = str(args[1]) | ||
outputFile = str(args[2]) | ||
|
||
|
||
# ----- Main ----- # | ||
def main(): | ||
|
||
processArguments(sys.argv) | ||
|
||
hexGrid = HASC() | ||
|
||
try: | ||
hexGrid.loadFromFile(inputFile) | ||
except (ValueError, IOError) as ex: | ||
print("Error loading the grid %s: %s" % (inputFile, ex)) | ||
sys.exit() | ||
print ("Loaded input HASC, converting...") | ||
|
||
try: | ||
hexGrid.saveAsGeoJSON(outputFile) | ||
except (ImportError, IOError) as ex: | ||
print("Error saving the grid %s: %s" % (inputFile, ex)) | ||
sys.exit() | ||
print ("Conversion successfully completed.") | ||
|
||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
''' | ||
Created on 12 Oct 2016 | ||
@author: desouslu | ||
''' | ||
|
||
import math | ||
import numpy as np | ||
from mpl_toolkits.mplot3d import Axes3D | ||
import matplotlib.pyplot as plt | ||
from surfaces.surface import Surface | ||
|
||
class Channel(Surface): | ||
|
||
angle = 30 | ||
slope = 0.25 | ||
centre_x = 5 | ||
centre_y = 5 | ||
centre_z = 5 | ||
radius = 0.5 | ||
depth = 1 | ||
|
||
|
||
def __init__(self, slope = None): | ||
|
||
if slope != None: | ||
self.slope = slope | ||
|
||
|
||
def fun(self, x, y): | ||
|
||
plane = ((self.centre_x - x) * self.slope + self.centre_z) * math.cos(math.radians(self.angle)) + \ | ||
((self.centre_y - y) * self.slope + self.centre_z) * math.sin(math.radians(self.angle)) | ||
|
||
centre = (x - self.centre_x) / math.sin(math.radians(90 - self.angle)) * \ | ||
math.sin(math.radians(self.angle)) | ||
|
||
if (y - self.centre_y) >= (centre - self.radius) and \ | ||
(y - self.centre_y) <= (centre + self.radius): | ||
return plane - self.depth | ||
else: | ||
return plane | ||
|
||
|
||
# Uncomment these lines to test a single pit. | ||
c = Channel() | ||
c.plotWireFrame() | ||
|
Oops, something went wrong.