object-oriented spherical geometry
Project description
sphersgeo
object-oriented spherical geometry
[!IMPORTANT]
sphersgeois still in development and does NOT currently implement all of the functionality provided by other geo packages such asgeoor Shapely.
[!NOTE] Intersections between geometries are NOT rigorous; the
.intersection()function will ONLY return the lower order of geometry being compared, and does NOT handle degenerate cases / touching geometries.
Installation
pip install sphersgeo
Usage
Euclidean geometry packages classify geometries into points, linestrings, and polygons (along with multi-variations: multipoints, multilinestrings, and multipolygons). Spherical geometry analogues are spherical points, arcstrings, and spherical polygons.
Full class definitions can be found in src/sphersgeo.pyi.
Points on a sphere
Spherical points are represented internally as 3-dimensional Euclidean points (X, Y, Z) relative to the origin of the unit sphere.
import sphersgeo
# define a point on the sphere in angular coordinates (longitude and latitude)
a = sphersgeo.SphericalPoint((60.0, 30.0))
b = sphersgeo.SphericalPoint((60.0, 0.0))
c = sphersgeo.SphericalPoint((-30.0, -30.0))
# ... or in Euclidean coordinates (X, Y, Z)
a = sphersgeo.SphericalPoint((0.43301270189221946, 0.75, 0.5))
b = sphersgeo.SphericalPoint((0.5, 0.8660254037844386, 0.0))
c = sphersgeo.SphericalPoint((0.75, -0.4330127018922193, -0.5))
d = sphersgeo.SphericalPoint((0.0, 0.0, 1.0))
e = sphersgeo.SphericalPoint((0.0, 0.0, -1.0))
# collate multiple points together by passing lists of angular or Euclidean coordinates
ab = sphersgeo.MultiSphericalPoint([(60.0, 30.0), (60.0, 0.0)])
ab = sphersgeo.MultiSphericalPoint(
[(0.43301270189221946, 0.75, 0.5), (0.5, 0.8660254037844386, 0.0)]
)
de = sphersgeo.MultiSphericalPoint(
[
(0.0, 0.0, 1.0),
(0.0, 0.0, -1.0),
]
)
# ... or a Numpy array of coordinates
import numpy as np
ab = sphersgeo.MultiSphericalPoint(np.array([(60.0, 30.0), (60.0, 0.0)]))
ab = sphersgeo.MultiSphericalPoint(
np.array([(0.43301270189221946, 0.75, 0.5), (0.5, 0.8660254037844386, 0.0)])
)
# ... or a list of SphericalPoint objects
abcde = sphersgeo.MultiSphericalPoint([a, b, c, d, e])
Strings of great circle arcs on a sphere
A great circle arcs is the shortest geodesic distance over the surface of the sphere between any two points. Arcstrings are comprised of an ordered collection of spherical points. Arcstrings can also be closed, in which case the final point is considered as connected back to the first point.
import sphersgeo
# define an arcstring on the sphere by passing angular or Euclidean coordinates
abc = sphersgeo.ArcString([(60.0, 0.0), (60.0, 30.0), (-30.0, -30.0)])
de = sphersgeo.ArcString(
[
(0.0, 0.0, 1.0),
(0.0, 0.0, -1.0),
]
)
# ... or a list of SphericalPoint objects
abc = sphersgeo.ArcString(
[
sphersgeo.SphericalPoint((60.0, 0.0)),
sphersgeo.SphericalPoint((60.0, 30.0)),
sphersgeo.SphericalPoint((-30.0, -30.0)),
],
closed=True,
)
de = sphersgeo.ArcString(
[
sphersgeo.SphericalPoint((0.0, 0.0, 1.0)),
sphersgeo.SphericalPoint((0.0, 0.0, -1.0)),
]
)
# collate arcstrings into a MultiArcString by passing the same inputs you would to the individual objects
abc_de = sphersgeo.MultiArcString(
[
[(60.0, 0.0), (60.0, 30.0), (-30.0, -30.0)],
[
(0.0, 0.0, 1.0),
(0.0, 0.0, -1.0),
],
]
)
# ... or a list of ArcString objects
abc_de = sphersgeo.MultiArcString([abc, de])
Polygons on a sphere
Spherical polygons are comprised of
- closed arcstring that represents the outer boundary, and
- a sample point that defines which side of the closed spherical region is "inside" the boundary.
If the "inside point" is not given, the smaller of the two regions split by the boundary will be assigned to be the "inside".
[!NOTE] Polygons in
sphersgeodo NOT have holes.
import sphersgeo
# define a spherical polygon by passing angular or Euclidean coordinates to form the boundary
abc = sphersgeo.SphericalPolygon([(60.0, 0.0), (60.0, 30.0), (-30.0, -30.0)])
abc = sphersgeo.SphericalPolygon(
[
(0.43301270189221946, 0.75, 0.5),
(0.5, 0.8660254037844386, 0.0),
(0.75, -0.4330127018922193, -0.5),
]
)
# ... or pass an ArcString object (the arcstring is assumed to be closed)
abc = sphersgeo.SphericalPolygon(
sphersgeo.ArcString([(60.0, 0.0), (60.0, 30.0), (-30.0, -30.0)])
)
# collate multiple polygons into a MultiSphericalPolygon by passing the same inputs you would to the individual objects
abc_def = sphersgeo.MultiSphericalPolygon(
[
[(60.0, 30.0), (60.0, 0.0), (-30.0, -30.0)],
[
(0.0, 0.0, 1.0),
(0.0, 0.0, -1.0),
(1.0, 1.0, 0.0),
],
]
)
# ... or a list of SphericalPolygon objects
abc_def = sphersgeo.MultiSphericalPolygon(
[
sphersgeo.SphericalPolygon([(60.0, 30.0), (60.0, 0.0), (-30.0, -30.0)]),
sphersgeo.SphericalPolygon(
[
(0.0, 0.0, 1.0),
(0.0, 0.0, -1.0),
(1.0, 1.0, 0.0),
]
),
]
)
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphersgeo-0.0.2.tar.gz.
File metadata
- Download URL: sphersgeo-0.0.2.tar.gz
- Upload date:
- Size: 7.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ee7c00a30d1e810c550c16340da5697f80dabee3efedf7229811e7412075241
|
|
| MD5 |
2243393a64bda81025cac51b6800f5f0
|
|
| BLAKE2b-256 |
c2f188cec7c48a053fafdf9797bf3b4322a5af45b9c7652bc99dceea27a92022
|
Provenance
The following attestation bundles were made for sphersgeo-0.0.2.tar.gz:
Publisher:
build.yml on spacetelescope/sphersgeo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphersgeo-0.0.2.tar.gz -
Subject digest:
0ee7c00a30d1e810c550c16340da5697f80dabee3efedf7229811e7412075241 - Sigstore transparency entry: 1412477609
- Sigstore integration time:
-
Permalink:
spacetelescope/sphersgeo@bf4b2d4025f303e0096a301b5207d37e69b08e14 -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/spacetelescope
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@bf4b2d4025f303e0096a301b5207d37e69b08e14 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sphersgeo-0.0.2-cp311-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: sphersgeo-0.0.2-cp311-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 671.6 kB
- Tags: CPython 3.11+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
709e3d0fa06927888804dbc1b68bb139d86a152f6aa95107ea482a32439158e4
|
|
| MD5 |
166539f11fbf22c20c125595726f73e3
|
|
| BLAKE2b-256 |
734273a8235080a00c8dfb448c4c2dabc5617150419cc170d14cb3d609c51b7d
|
Provenance
The following attestation bundles were made for sphersgeo-0.0.2-cp311-abi3-musllinux_1_2_x86_64.whl:
Publisher:
build.yml on spacetelescope/sphersgeo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphersgeo-0.0.2-cp311-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
709e3d0fa06927888804dbc1b68bb139d86a152f6aa95107ea482a32439158e4 - Sigstore transparency entry: 1412477653
- Sigstore integration time:
-
Permalink:
spacetelescope/sphersgeo@bf4b2d4025f303e0096a301b5207d37e69b08e14 -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/spacetelescope
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@bf4b2d4025f303e0096a301b5207d37e69b08e14 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sphersgeo-0.0.2-cp311-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: sphersgeo-0.0.2-cp311-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 598.6 kB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eee066078a1eba141ef2c0fb3bf2f0dd11bf40c00abd1c30cba3ae24096d0c05
|
|
| MD5 |
688a4a852356c6061b284e6f9baed30c
|
|
| BLAKE2b-256 |
4a8430c03abebb3eb7d8b7041e226bbb210e4826c7e6265830099d33c19c217f
|
Provenance
The following attestation bundles were made for sphersgeo-0.0.2-cp311-abi3-manylinux_2_28_x86_64.whl:
Publisher:
build.yml on spacetelescope/sphersgeo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphersgeo-0.0.2-cp311-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
eee066078a1eba141ef2c0fb3bf2f0dd11bf40c00abd1c30cba3ae24096d0c05 - Sigstore transparency entry: 1412477735
- Sigstore integration time:
-
Permalink:
spacetelescope/sphersgeo@bf4b2d4025f303e0096a301b5207d37e69b08e14 -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/spacetelescope
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@bf4b2d4025f303e0096a301b5207d37e69b08e14 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sphersgeo-0.0.2-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: sphersgeo-0.0.2-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 545.2 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93c17d00d369231cad4d932eb9099556fa4dd2ff1494b53482d868fa8723e5f2
|
|
| MD5 |
f079c4757bfc19fc3fef55c4f0edf38e
|
|
| BLAKE2b-256 |
02a78c00c76ea291514417352f7f5c8ea83218e44c11ec881817610b55dadf95
|
Provenance
The following attestation bundles were made for sphersgeo-0.0.2-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
build.yml on spacetelescope/sphersgeo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphersgeo-0.0.2-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
93c17d00d369231cad4d932eb9099556fa4dd2ff1494b53482d868fa8723e5f2 - Sigstore transparency entry: 1412477702
- Sigstore integration time:
-
Permalink:
spacetelescope/sphersgeo@bf4b2d4025f303e0096a301b5207d37e69b08e14 -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/spacetelescope
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@bf4b2d4025f303e0096a301b5207d37e69b08e14 -
Trigger Event:
release
-
Statement type: