scikit-spatial
Spatial objects and computations based on NumPy arrays.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.1%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Spatial objects and computations based on NumPy arrays.
Basic Info
- Host: GitHub
- Owner: ajhynes7
- License: other
- Language: Python
- Default Branch: master
- Homepage: https://scikit-spatial.readthedocs.io
- Size: 2.18 MB
Statistics
- Stars: 98
- Watchers: 6
- Forks: 13
- Open Issues: 2
- Releases: 0
Topics
Metadata Files
README.md
Introduction
This package provides spatial objects based on NumPy arrays, as well as computations using these objects. The package includes computations for 2D, 3D, and higher-dimensional space.
The following spatial objects are provided:
- Point
- Points
- Vector
- Line
- LineSegment
- Plane
- Circle
- Sphere
- Triangle
- Cylinder
Most of the computations fall into the following categories:
- Measurement
- Comparison
- Projection
- Intersection
- Fitting
- Transformation
All spatial objects are equipped with plotting methods based on
matplotlib. Both 2D and 3D plotting are supported. Spatial
computations can be easily visualized by plotting multiple objects at
once.
Why this instead of scipy.spatial or sympy.geometry?
This package has little to no overlap with the functionality of
scipy.spatial. It can be viewed as an object-oriented extension.
While similar spatial objects and computations exist in the
sympy.geometry module, scikit-spatial is based on NumPy rather than
symbolic math. The primary objects of scikit-spatial (Point,
Points, and Vector) are actually subclasses of the NumPy ndarray.
This gives them all the regular functionality of the ndarray, plus
additional methods from this package.
```py
from skspatial.objects import Vector
vector = Vector([2, 0, 0])
```
Behaviour inherited from NumPy:
```py
vector.size 3
vector.mean().round(3) np.float64(0.667)
```
Additional methods from scikit-spatial:
```py
vector.norm() np.float64(2.0)
vector.unit() Vector([1., 0., 0.])
```
Because Point and Vector are both subclasses of ndarray, a Vector can be added to a Point. This produces a new Point.
```py
from skspatial.objects import Point
Point([1, 2]) + Vector([3, 4]) Point([4, 6])
```
Point and Vector are based on a 1D NumPy array, and Points is
based on a 2D NumPy array, where each row represents a point in space.
The Line and Plane objects have Point and Vector objects as
attributes.
Note that most methods inherited from NumPy return a regular NumPy object, instead of the spatial object class.
```py
vector.sum() np.int64(2)
```
This is to avoid getting a spatial object with a forbidden shape, like a
zero dimension Vector. Trying to convert this back to a Vector
causes an exception.
```py
Vector(vector.sum()) Traceback (most recent call last): ValueError: The array must be 1D.
```
Because the computations of scikit-spatial are also based on NumPy,
keyword arguments can be passed to NumPy functions. For example, a
tolerance can be specified while testing for collinearity. The tol
keyword is passed to numpy.linalg.matrix_rank.
```py
from skspatial.objects import Points
points = Points([[1, 2, 3], [4, 5, 6], [7, 8, 8]])
points.are_collinear() False
points.are_collinear(tol=1) True
```
Installation
The package can be installed with pip.
```bash $ pip install scikit-spatial
```
It can also be installed with conda.
```bash $ conda install scikit-spatial -c conda-forge
```
The matplotlib dependency is optional. To enable plotting, you can install scikit-spatial with the extra plotting.
```bash $ pip install 'scikit-spatial[plotting]'
```
Example Usage
Measurement
Measure the cosine similarity between two vectors.
```py
from skspatial.objects import Vector
Vector([1, 0]).cosine_similarity([1, 1]).round(3) np.float64(0.707)
```
Comparison
Check if multiple points are collinear.
```py
from skspatial.objects import Points
points = Points([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
points.are_collinear() True
```
Projection
Project a point onto a line.
```py
from skspatial.objects import Line
line = Line(point=[0, 0, 0], direction=[1, 1, 0])
line.project_point([5, 6, 7]) Point([5.5, 5.5, 0. ])
```
Intersection
Find the intersection of two planes.
```py
from skspatial.objects import Plane
planea = Plane(point=[0, 0, 0], normal=[0, 0, 1]) planeb = Plane(point=[5, 16, -94], normal=[1, 0, 0])
planea.intersectplane(plane_b) Line(point=Point([5., 0., 0.]), direction=Vector([0, 1, 0]))
```
An error is raised if the computation is undefined.
```py
plane_b = Plane(point=[0, 0, 1], normal=[0, 0, 1])
planea.intersectplane(plane_b) Traceback (most recent call last): ValueError: The planes must not be parallel.
```
Fitting
Find the plane of best fit for multiple points.
```py
points = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0]]
Plane.best_fit(points) Plane(point=Point([0.5, 0.5, 0. ]), normal=Vector([0., 0., 1.]))
```
Transformation
Transform multiple points to 1D coordinates along a line.
```py
line = Line(point=[0, 0, 0], direction=[1, 2, 0]) points = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
line.transform_points(points).round(3) array([ 2.236, 6.261, 10.286])
```
Acknowledgment
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Owner
- Name: Andrew Hynes
- Login: ajhynes7
- Kind: user
- Location: St. John's NL, Canada
- Company: CoLab Software
- Repositories: 4
- Profile: https://github.com/ajhynes7
Citation (CITATION.cff)
cff-version: 1.2.0
title: "scikit-spatial: Spatial objects and computations based on NumPy arrays"
message: "If you use this software, please cite it using the metadata from this file."
type: software
authors:
- given-names: Andrew
family-names: Hynes
email: andrewjhynes@gmail.com
license: BSD-3-Clause
url: https://scikit-spatial.readthedocs.io
repository-code: https://github.com/ajhynes7/scikit-spatial
GitHub Events
Total
- Issues event: 8
- Watch event: 9
- Delete event: 2
- Issue comment event: 39
- Push event: 20
- Pull request review event: 2
- Pull request event: 7
- Create event: 6
Last Year
- Issues event: 8
- Watch event: 9
- Delete event: 2
- Issue comment event: 39
- Push event: 20
- Pull request review event: 2
- Pull request event: 7
- Create event: 6
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Andrew Hynes | a****s@y****m | 725 |
| Andrew Hynes | a****s@g****m | 403 |
| pyup-bot | g****t@p****o | 86 |
| pre-commit-ci[bot] | 6****] | 8 |
| Cristiano Pizzamiglio | c****o@g****m | 5 |
| Louis Lac | l****5@g****m | 2 |
| volkoshkursk | 3****k | 1 |
| martxelo | m****z@g****m | 1 |
| dependabot[bot] | 4****] | 1 |
| EdYazbec | 1****c | 1 |
Issues and Pull Requests
Last synced: 5 months ago
All Time
- Total issues: 44
- Total pull requests: 84
- Average time to close issues: 20 days
- Average time to close pull requests: 11 days
- Total issue authors: 30
- Total pull request authors: 11
- Average comments per issue: 3.93
- Average comments per pull request: 2.14
- Merged pull requests: 65
- Bot issues: 0
- Bot pull requests: 22
Past Year
- Issues: 8
- Pull requests: 7
- Average time to close issues: 21 days
- Average time to close pull requests: 18 days
- Issue authors: 7
- Pull request authors: 2
- Average comments per issue: 3.25
- Average comments per pull request: 2.29
- Merged pull requests: 6
- Bot issues: 0
- Bot pull requests: 2
Top Authors
Issue Authors
- CristianoPizzamiglio (5)
- typhoon71 (5)
- pauljurczak (4)
- maxim0815 (2)
- croemheld (2)
- jmspereira (2)
- seirios (1)
- MikiGrit (1)
- 3DMiller (1)
- mrrezaie (1)
- pvtoan (1)
- akuznetsov1 (1)
- AlfredQin (1)
- ArenaGrenade (1)
- garyvdm (1)
Pull Request Authors
- ajhynes7 (59)
- pre-commit-ci[bot] (20)
- CristianoPizzamiglio (5)
- dependabot[bot] (4)
- laclouis5 (4)
- EdYazbec (2)
- pauljurczak (2)
- martxelo (1)
- volkoshkursk (1)
- Yeok-c (1)
- yamila-moreno (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 53,267 last-month
- Total docker downloads: 412
-
Total dependent packages: 14
(may contain duplicates) -
Total dependent repositories: 33
(may contain duplicates) - Total versions: 46
- Total maintainers: 1
pypi.org: scikit-spatial
Spatial objects and computations based on NumPy arrays.
- Documentation: https://scikit-spatial.readthedocs.io/
- License: BSD-3-Clause
-
Latest release: 9.0.1
published 8 months ago
Rankings
Maintainers (1)
conda-forge.org: scikit-spatial
- Homepage: https://github.com/ajhynes7/scikit-spatial
- License: BSD-3-Clause
-
Latest release: 6.5.0
published over 3 years ago
Rankings
Dependencies
- Sphinx 4.2.0
- hypothesis 6.8.1
- importlib-metadata ~1
- matplotlib ^3
- numpy ^1.20
- numpydoc 1.1.0
- pre-commit 2.11.1
- pytest 7.1.1
- pytest-cov 2.11.1
- python ^3.7
- sphinx-bootstrap-theme 0.8.0
- sphinx-gallery 0.9.0
- JRubics/poetry-publish v1.8 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- codecov/codecov-action v1.2.1 composite
- snok/install-poetry v1.3.1 composite
- Sphinx ==5.3.0
- numpydoc ==1.5.0
- sphinx-bootstrap-theme ==0.8.1
- sphinx-gallery ==0.9.0