pointset


Namepointset JSON
Version 0.1.7 PyPI version JSON
download
home_page
SummaryPython package for simple EPSG transformations using PyProj
upload_time2024-02-02 17:20:49
maintainer
docs_urlNone
authorGereon Tombrink
requires_python>=3.8,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python PointSet Class
This package includes a class for handling point-coordinates and their datum using EPSG codes. For datum transformations, this package makes use of the `PyProj` package. It meant to simplify coordinate transformations between EPSG codes.

# Installation
```Console
python3 -m pip install pointset
```

# Usage
The `PointSet` class wraps `pyproj` in order to allow coordinate transformations. In the following, the functionality of the class is explained.

Define PointSet with random numbers

```python 
from pointset import PointSet

xyz = np.random.randn(10000, 3) * 20
point_set = PointSet(xyz=xyz)
```
print the point set to see the EPSG code and the coordinates:
```python 
print(point_set)
```
Output (for example):
```console
EPSG: 0
Coordinates:
[[  2.61185114  26.86022378  24.16762049]
 [-13.10880044  -0.59031669  25.03318095]
 [ 11.7225511   -8.60815889   8.14436657]
 ...
 [  2.92442258 -24.89119898  -2.17729086]
 [  1.45229968  24.66663312  21.73038683]
 [ 15.90327212  28.88909949   4.56549931]]
```
Because we only provided the numpy array and no other parameters,
this PointSet has no datum information. The positions are assumed
to be in a local unknown frame, which is denoted with an EPSG code
of 0.
Therefore, we will get an error if we try to change the EPSG code to
some global frame, e.g. EPSG: 4937
```python 
try:
    point_set.to_epsg(4937)
except PointSetError as e:
    print(e)
```
Output:
```console
Unable to recover from local frame since definition is unknown!
```
However, we can still do some data operations like computing the mean of
the point_set (which will also be a PointSet):
```python
mean_pos = point_set.mean()
```
We can access the raw values of the PointSet coordinates using `x` `y` `z` or `xyz`
```python
print(f"Mean: {mean_pos.xyz}, x = {mean_pos.x:.3f}, y = {mean_pos.y:.3f}, z = {mean_pos.z:.3f}")
```
Output:
```console
Mean: [[-0.03867169  0.21157332  0.0836462 ]], x = -0.039, y = 0.212, z = 0.084
```
It also possible to change the values in this way:
```python
mean_pos.y = 10
print(f"Changed y-value to: {mean_pos.y:.3f}")
```
Output:
```console
Changed y-value to: 10.000
```
To add / substract two PointSets, use normal operators:
```python
added_point_set = point_set + mean_pos
```

You can create a deep copy of the PointSet using .copy():
```python
copied_point_set = point_set.copy()
```

## PointSet with Datum information
In the example above we just generated random positions without any datum information. However the main feature of this class is datum transformations.

First, we define some points in UTM 32N (EPSG: 25832)
```python
xyz_utm = np.array(
    [
        [364938.4000, 5621690.5000, 110.0000],
        [364895.2146, 5621150.5605, 107.4668],
        [364834.6853, 5621114.0750, 108.1602],
        [364783.4349, 5621127.6695, 108.2684],
        [364793.5793, 5621220.9659, 108.1232],
        [364868.9891, 5621310.2283, 107.9929],
        [364937.1665, 5621232.2154, 107.9581],
        [364919.0140, 5621153.6880, 107.8130],
        [364906.8750, 5621199.2600, 108.0610],
        [364951.9350, 5621243.4890, 106.9560],
        [364992.5600, 5621229.7440, 106.7330],
        [365003.7740, 5621203.8200, 106.7760],
        [364987.8850, 5621179.5160, 107.8890],
        [364950.1180, 5621148.5770, 107.9120],
    ]
)

utm_point_set = PointSet(xyz=xyz_utm, epsg=25832)
```
transform point set to another EPSG:
```python
utm_point_set.to_epsg(4936)
print(utm_point_set.mean())
```
Output:
```console
EPSG: 4936
Coordinates:
[[4014743.91215813  499064.14065106 4914468.86763503]]
```
As you can see, the coordinates are now given in a global cartesian frame (EPSG: 4936).
## Local Coordinate Frame
You can transform the coordinates of a pointset in a local ellipsoidal
coordinate frame tangential to the GRS80 ellipsoid for local investigations
using `.to_local()` or `.to_epsg(0)`
```python
utm_point_set.to_local()
print(utm_point_set.mean())
```
Output:
```console
EPSG: 0
Coordinates:
[[-6.15055943e-11 -5.61509442e-10  2.01357074e-10]]
```
Note, that the mean of the PointSet will be zero in local coordinates.
Internally, a `local_transformer` object is created, that takes care of the
transformation to local coordinates.
Especially for comparing PointSets, it might be useful to analyze both
PointSets in the same local coordinate frame. You can do this by setting the
`local_transformer` variable either during instance creation or later:
```python
point_set.local_transformer = utm_point_set.local_transformer
point_set = PointSet(xyz=xyz, epsg=0, local_transformer=utm_point_set.local_transformer)
```
Now, the randomly created points from the beginning have the same datum
information as the utm-coordinates. Therefore, we can transform them into
any EPSG:
```python
point_set.to_epsg(25832)
```
If we transform our utm_point_set from local back to utm, we can plot PointSets in UTM
```python
utm_point_set.to_epsg(25832)

plt.figure()
plt.xlabel("x [m]")
plt.ylabel("y [m]")
plt.grid()
plt.plot(point_set.x, point_set.y, ".")
plt.plot(utm_point_set.x, utm_point_set.y, ".r")
plt.axis("equal")
plt.show()
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pointset",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Gereon Tombrink",
    "author_email": "tombrink@igg.uni-bonn.de",
    "download_url": "https://files.pythonhosted.org/packages/38/3c/8aa09100218d6b1ded7f6c5cc8e4eac7f5f9c1fcdb9eb0c930225cc6ac91/pointset-0.1.7.tar.gz",
    "platform": null,
    "description": "# Python PointSet Class\nThis package includes a class for handling point-coordinates and their datum using EPSG codes. For datum transformations, this package makes use of the `PyProj` package. It meant to simplify coordinate transformations between EPSG codes.\n\n# Installation\n```Console\npython3 -m pip install pointset\n```\n\n# Usage\nThe `PointSet` class wraps `pyproj` in order to allow coordinate transformations. In the following, the functionality of the class is explained.\n\nDefine PointSet with random numbers\n\n```python \nfrom pointset import PointSet\n\nxyz = np.random.randn(10000, 3) * 20\npoint_set = PointSet(xyz=xyz)\n```\nprint the point set to see the EPSG code and the coordinates:\n```python \nprint(point_set)\n```\nOutput (for example):\n```console\nEPSG: 0\nCoordinates:\n[[  2.61185114  26.86022378  24.16762049]\n [-13.10880044  -0.59031669  25.03318095]\n [ 11.7225511   -8.60815889   8.14436657]\n ...\n [  2.92442258 -24.89119898  -2.17729086]\n [  1.45229968  24.66663312  21.73038683]\n [ 15.90327212  28.88909949   4.56549931]]\n```\nBecause we only provided the numpy array and no other parameters,\nthis PointSet has no datum information. The positions are assumed\nto be in a local unknown frame, which is denoted with an EPSG code\nof 0.\nTherefore, we will get an error if we try to change the EPSG code to\nsome global frame, e.g. EPSG: 4937\n```python \ntry:\n    point_set.to_epsg(4937)\nexcept PointSetError as e:\n    print(e)\n```\nOutput:\n```console\nUnable to recover from local frame since definition is unknown!\n```\nHowever, we can still do some data operations like computing the mean of\nthe point_set (which will also be a PointSet):\n```python\nmean_pos = point_set.mean()\n```\nWe can access the raw values of the PointSet coordinates using `x` `y` `z` or `xyz`\n```python\nprint(f\"Mean: {mean_pos.xyz}, x = {mean_pos.x:.3f}, y = {mean_pos.y:.3f}, z = {mean_pos.z:.3f}\")\n```\nOutput:\n```console\nMean: [[-0.03867169  0.21157332  0.0836462 ]], x = -0.039, y = 0.212, z = 0.084\n```\nIt also possible to change the values in this way:\n```python\nmean_pos.y = 10\nprint(f\"Changed y-value to: {mean_pos.y:.3f}\")\n```\nOutput:\n```console\nChanged y-value to: 10.000\n```\nTo add / substract two PointSets, use normal operators:\n```python\nadded_point_set = point_set + mean_pos\n```\n\nYou can create a deep copy of the PointSet using .copy():\n```python\ncopied_point_set = point_set.copy()\n```\n\n## PointSet with Datum information\nIn the example above we just generated random positions without any datum information. However the main feature of this class is datum transformations.\n\nFirst, we define some points in UTM 32N (EPSG: 25832)\n```python\nxyz_utm = np.array(\n    [\n        [364938.4000, 5621690.5000, 110.0000],\n        [364895.2146, 5621150.5605, 107.4668],\n        [364834.6853, 5621114.0750, 108.1602],\n        [364783.4349, 5621127.6695, 108.2684],\n        [364793.5793, 5621220.9659, 108.1232],\n        [364868.9891, 5621310.2283, 107.9929],\n        [364937.1665, 5621232.2154, 107.9581],\n        [364919.0140, 5621153.6880, 107.8130],\n        [364906.8750, 5621199.2600, 108.0610],\n        [364951.9350, 5621243.4890, 106.9560],\n        [364992.5600, 5621229.7440, 106.7330],\n        [365003.7740, 5621203.8200, 106.7760],\n        [364987.8850, 5621179.5160, 107.8890],\n        [364950.1180, 5621148.5770, 107.9120],\n    ]\n)\n\nutm_point_set = PointSet(xyz=xyz_utm, epsg=25832)\n```\ntransform point set to another EPSG:\n```python\nutm_point_set.to_epsg(4936)\nprint(utm_point_set.mean())\n```\nOutput:\n```console\nEPSG: 4936\nCoordinates:\n[[4014743.91215813  499064.14065106 4914468.86763503]]\n```\nAs you can see, the coordinates are now given in a global cartesian frame (EPSG: 4936).\n## Local Coordinate Frame\nYou can transform the coordinates of a pointset in a local ellipsoidal\ncoordinate frame tangential to the GRS80 ellipsoid for local investigations\nusing `.to_local()` or `.to_epsg(0)`\n```python\nutm_point_set.to_local()\nprint(utm_point_set.mean())\n```\nOutput:\n```console\nEPSG: 0\nCoordinates:\n[[-6.15055943e-11 -5.61509442e-10  2.01357074e-10]]\n```\nNote, that the mean of the PointSet will be zero in local coordinates.\nInternally, a `local_transformer` object is created, that takes care of the\ntransformation to local coordinates.\nEspecially for comparing PointSets, it might be useful to analyze both\nPointSets in the same local coordinate frame. You can do this by setting the\n`local_transformer` variable either during instance creation or later:\n```python\npoint_set.local_transformer = utm_point_set.local_transformer\npoint_set = PointSet(xyz=xyz, epsg=0, local_transformer=utm_point_set.local_transformer)\n```\nNow, the randomly created points from the beginning have the same datum\ninformation as the utm-coordinates. Therefore, we can transform them into\nany EPSG:\n```python\npoint_set.to_epsg(25832)\n```\nIf we transform our utm_point_set from local back to utm, we can plot PointSets in UTM\n```python\nutm_point_set.to_epsg(25832)\n\nplt.figure()\nplt.xlabel(\"x [m]\")\nplt.ylabel(\"y [m]\")\nplt.grid()\nplt.plot(point_set.x, point_set.y, \".\")\nplt.plot(utm_point_set.x, utm_point_set.y, \".r\")\nplt.axis(\"equal\")\nplt.show()\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python package for simple EPSG transformations using PyProj",
    "version": "0.1.7",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd07209c42ff31a476a54436a6c45213d0b2b5ee4a29144c0d36f90703115040",
                "md5": "31e10328122d5cffec54d2dd2bd04a95",
                "sha256": "6e893d5f8302d22e40b890b6536947ac2995ff6b116e59f6f4df032807d98f37"
            },
            "downloads": -1,
            "filename": "pointset-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "31e10328122d5cffec54d2dd2bd04a95",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 8067,
            "upload_time": "2024-02-02T17:20:47",
            "upload_time_iso_8601": "2024-02-02T17:20:47.336377Z",
            "url": "https://files.pythonhosted.org/packages/cd/07/209c42ff31a476a54436a6c45213d0b2b5ee4a29144c0d36f90703115040/pointset-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "383c8aa09100218d6b1ded7f6c5cc8e4eac7f5f9c1fcdb9eb0c930225cc6ac91",
                "md5": "ddf8883673d228608feba61e08e8b1fd",
                "sha256": "f15aa0a0e9b615edef321322d7b7ae2972c3c87959684df0c1d28187524af061"
            },
            "downloads": -1,
            "filename": "pointset-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "ddf8883673d228608feba61e08e8b1fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 7371,
            "upload_time": "2024-02-02T17:20:49",
            "upload_time_iso_8601": "2024-02-02T17:20:49.099240Z",
            "url": "https://files.pythonhosted.org/packages/38/3c/8aa09100218d6b1ded7f6c5cc8e4eac7f5f9c1fcdb9eb0c930225cc6ac91/pointset-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-02 17:20:49",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pointset"
}
        
Elapsed time: 0.23631s