tablegis


Nametablegis JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryA powerful Python library for geospatial data processing, analysis and conversion - integrating pandas with GIS operations
upload_time2025-10-20 10:44:28
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2025 Non-existent987 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords gis geospatial pandas geopandas shapefile kml geojson spatial-analysis geographic geometry mapping
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tablegis

`tablegis` is a Python package for geospatial data processing and analysis, built on `geopandas`, `pandas`, `shapely`, and `pyproj`. It provides a series of utility functions to simplify common GIS operations.

## Features

*   **Distance Calculation**: Efficiently compute the nearest distance between DataFrames.
*   **Spatial Analysis**: Create buffers (input in meters), Voronoi polygons, Delaunay triangulations, etc.
*   **Format Conversion**: Easily convert between `GeoDataFrame` and formats like `Shapefile`, `KML`, etc.
*   **Coordinate Aggregation**: Provides tools for aggregating coordinate points into grids.
*   **Geometric Operations**: Includes merging polygons, calculating centroids, adding sectors, etc.

## Installation

1、You can install `tablegis` from PyPI:

```bash
pip install tablegis
```

2、Or, install the latest version directly from the GitHub repository:

```bash
pip install git+https://github.com/Non-existent987/tablegis.git
```
3、After downloading the project, it is convenient to import from local files for modification.
```bash
import sys
import pandas as pd
# Find the file path of the tablegis you downloaded.
sys.path.insert(0, r'C:\Users\Administrator\Desktop\tablegis')
# Now it can be imported.
import tablegis as tg
```
## Quick Start

Here is a simple example of how to use `tablegis`:

### 1. Find the nearest point (in df2) for each point in df1 and add its ID, longitude, latitude, and distance.

```python
import pandas as pd
import tablegis as tg

# Create two example DataFrames
df1 = pd.DataFrame({
    'id': [1, 2, 3],
    'lon1': [116.404, 116.405, 116.406],
    'lat1': [39.915, 39.916, 39.917]
})

df2 = pd.DataFrame({
    'id': ['A', 'B', 'C', 'D'],
    'lon2': [116.403, 116.407, 116.404, 116.408],
    'lat2': [39.914, 39.918, 39.916, 39.919]
})

# Calculate the nearest 1 point
result = tg.min_distance_twotable(df1, df2, lon1='lon1', lat1='lat1', lon2='lon2', lat2='lat2', df2_id='id', n=1)
# Calculate the nearest 2 points
result2 = tg.min_distance_twotable(df1, df2, lon1='lon1', lat1='lat1', lon2='lon2', lat2='lat2', df2_id='id', n=2)

print("\nExample result (distance in meters):")
print(result)
print(result2)
```

**Result Display:**

<table>
<tr>
<td style="vertical-align: top; padding-right: 50px;">

**Table df1:**

| id | lon1  | lat1 |
|----|-------|------|
| A  | 114.0 | 30.0 |
| B  | 114.1 | 30.1 |

</td>
<td style="vertical-align: top;">

**Table df2:**

| id | lon2   | lat2  |
|----|--------|-------|
| p1 | 114.01 | 30.01 |
| p2 | 114.05 | 30.05 |
| p3 | 114.12 | 30.12 |

</td>
</tr>
</table>

**Nearest 1 point:**

| id | lon1  | lat1 | nearest1_id | nearest1_lon2 | nearest1_lat2 | nearest1_distance |
|----|-------|------|-------------|---------------|---------------|-------------------|
| A  | 114.0 | 30.0 | p1          | 114.01        | 30.01         | 1470.515926       |
| B  | 114.1 | 30.1 | p3          | 114.12        | 30.12         | 2939.507557       |

**Nearest 2 points:**

| id | lon1  | lat1 | nearest1_id | nearest1_lon2 | nearest1_lat2 | nearest1_distance | nearest2_id | nearest2_lon2 | nearest2_lat2 | nearest2_distance | mean_distance |
|----|-------|------|-------------|---------------|---------------|-------------------|-------------|---------------|---------------|-------------------|---------------|
| A  | 114.0 | 30.0 | p1          | 114.01        | 30.01         | 1470.515926       | p2          | 114.05        | 30.05         | 7351.852775       | 4411.184351   |
| B  | 114.1 | 30.1 | p3          | 114.12        | 30.12         | 2939.507557       | p2          | 114.05        | 30.05         | 7350.037700       | 5144.772629   |

### 2. Find the nearest point for each point within the same table and add its ID, longitude, latitude, and distance.

```python
import pandas as pd
import tablegis as tg

# Create an example DataFrame
df2 = pd.DataFrame({
    'id': ['A', 'B', 'C', 'D'],
    'lon2': [116.403, 116.407, 116.404, 116.408],
    'lat2': [39.914, 39.918, 39.916, 39.919]
})

# Calculate the nearest 1 point
result = tg.min_distance_onetable(df2, 'lon2', 'lat2', idname='id', n=1)
# Calculate the nearest 2 points
result2 = tg.min_distance_onetable(df2, 'lon2', 'lat2', idname='id', n=2)

print("\nExample result (distance in meters):")
print(result)
print(result2)
```

**Result Display:**

**Table df2:**

| id | lon2   | lat2  |
|----|--------|-------|
| p1 | 114.01 | 30.01 |
| p2 | 114.05 | 30.05 |
| p3 | 114.12 | 30.12 |

**Nearest 1 point:**

|    | id | lon2   | lat2  | nearest1_id | nearest1_lon2 | nearest1_lat2 | nearest1_distance |
|---:|----|--------|-------|-------------|---------------|---------------|-------------------|
|  0 | p1 | 114.01 | 30.01 | p2          | 114.05        | 30.05         | 5881.336911       |
|  1 | p2 | 114.05 | 30.05 | p1          | 114.01        | 30.01         | 5881.336911       |
|  2 | p3 | 114.12 | 30.12 | p2          | 114.05        | 30.05         | 10289.545038      |

**Nearest 2 points:**

|    | id | lon2   | lat2  | nearest1_id | nearest1_lon2 | nearest1_lat2 | nearest1_distance | nearest2_id | nearest2_lon2 | nearest2_lat2 | nearest2_distance | mean_distance |
|---:|----|--------|-------|-------------|---------------|---------------|-------------------|-------------|---------------|---------------|-------------------|---------------|
|  0 | p1 | 114.01 | 30.01 | p2          | 114.05        | 30.05         | 5881.336911       | p3          | 114.12        | 30.12         | 16170.880987      | 11026.108949  |
|  1 | p2 | 114.05 | 30.05 | p1          | 114.01        | 30.01         | 5881.336911       | p3          | 114.12        | 30.12         | 10289.545038      | 8085.440974   |
|  2 | p3 | 114.12 | 30.12 | p2          | 114.05        | 30.05         | 10289.545038      | p1          | 114.01        | 30.01         | 16170.880987      | 13230.213012  |

## Contributing

Contributions in all forms are welcome, including feature requests, bug reports, and code contributions.

## License

This project is licensed under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tablegis",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "gis, geospatial, pandas, geopandas, shapefile, kml, geojson, spatial-analysis, geographic, geometry, mapping",
    "author": null,
    "author_email": "Non-existent987 <jiaqi0425_000@163.com>",
    "download_url": "https://files.pythonhosted.org/packages/44/a3/62d5b79ef05a98a67bbdfe8ac75966d4cff15bfb22649985c5efae8cd93b/tablegis-0.0.1.tar.gz",
    "platform": null,
    "description": "# tablegis\r\n\r\n`tablegis` is a Python package for geospatial data processing and analysis, built on `geopandas`, `pandas`, `shapely`, and `pyproj`. It provides a series of utility functions to simplify common GIS operations.\r\n\r\n## Features\r\n\r\n*   **Distance Calculation**: Efficiently compute the nearest distance between DataFrames.\r\n*   **Spatial Analysis**: Create buffers (input in meters), Voronoi polygons, Delaunay triangulations, etc.\r\n*   **Format Conversion**: Easily convert between `GeoDataFrame` and formats like `Shapefile`, `KML`, etc.\r\n*   **Coordinate Aggregation**: Provides tools for aggregating coordinate points into grids.\r\n*   **Geometric Operations**: Includes merging polygons, calculating centroids, adding sectors, etc.\r\n\r\n## Installation\r\n\r\n1\u3001You can install `tablegis` from PyPI:\r\n\r\n```bash\r\npip install tablegis\r\n```\r\n\r\n2\u3001Or, install the latest version directly from the GitHub repository:\r\n\r\n```bash\r\npip install git+https://github.com/Non-existent987/tablegis.git\r\n```\r\n3\u3001After downloading the project, it is convenient to import from local files for modification.\r\n```bash\r\nimport sys\r\nimport pandas as pd\r\n# Find the file path of the tablegis you downloaded.\r\nsys.path.insert(0, r'C:\\Users\\Administrator\\Desktop\\tablegis')\r\n# Now it can be imported.\r\nimport tablegis as tg\r\n```\r\n## Quick Start\r\n\r\nHere is a simple example of how to use `tablegis`:\r\n\r\n### 1. Find the nearest point (in df2) for each point in df1 and add its ID, longitude, latitude, and distance.\r\n\r\n```python\r\nimport pandas as pd\r\nimport tablegis as tg\r\n\r\n# Create two example DataFrames\r\ndf1 = pd.DataFrame({\r\n    'id': [1, 2, 3],\r\n    'lon1': [116.404, 116.405, 116.406],\r\n    'lat1': [39.915, 39.916, 39.917]\r\n})\r\n\r\ndf2 = pd.DataFrame({\r\n    'id': ['A', 'B', 'C', 'D'],\r\n    'lon2': [116.403, 116.407, 116.404, 116.408],\r\n    'lat2': [39.914, 39.918, 39.916, 39.919]\r\n})\r\n\r\n# Calculate the nearest 1 point\r\nresult = tg.min_distance_twotable(df1, df2, lon1='lon1', lat1='lat1', lon2='lon2', lat2='lat2', df2_id='id', n=1)\r\n# Calculate the nearest 2 points\r\nresult2 = tg.min_distance_twotable(df1, df2, lon1='lon1', lat1='lat1', lon2='lon2', lat2='lat2', df2_id='id', n=2)\r\n\r\nprint(\"\\nExample result (distance in meters):\")\r\nprint(result)\r\nprint(result2)\r\n```\r\n\r\n**Result Display:**\r\n\r\n<table>\r\n<tr>\r\n<td style=\"vertical-align: top; padding-right: 50px;\">\r\n\r\n**Table df1:**\r\n\r\n| id | lon1  | lat1 |\r\n|----|-------|------|\r\n| A  | 114.0 | 30.0 |\r\n| B  | 114.1 | 30.1 |\r\n\r\n</td>\r\n<td style=\"vertical-align: top;\">\r\n\r\n**Table df2:**\r\n\r\n| id | lon2   | lat2  |\r\n|----|--------|-------|\r\n| p1 | 114.01 | 30.01 |\r\n| p2 | 114.05 | 30.05 |\r\n| p3 | 114.12 | 30.12 |\r\n\r\n</td>\r\n</tr>\r\n</table>\r\n\r\n**Nearest 1 point:**\r\n\r\n| id | lon1  | lat1 | nearest1_id | nearest1_lon2 | nearest1_lat2 | nearest1_distance |\r\n|----|-------|------|-------------|---------------|---------------|-------------------|\r\n| A  | 114.0 | 30.0 | p1          | 114.01        | 30.01         | 1470.515926       |\r\n| B  | 114.1 | 30.1 | p3          | 114.12        | 30.12         | 2939.507557       |\r\n\r\n**Nearest 2 points:**\r\n\r\n| id | lon1  | lat1 | nearest1_id | nearest1_lon2 | nearest1_lat2 | nearest1_distance | nearest2_id | nearest2_lon2 | nearest2_lat2 | nearest2_distance | mean_distance |\r\n|----|-------|------|-------------|---------------|---------------|-------------------|-------------|---------------|---------------|-------------------|---------------|\r\n| A  | 114.0 | 30.0 | p1          | 114.01        | 30.01         | 1470.515926       | p2          | 114.05        | 30.05         | 7351.852775       | 4411.184351   |\r\n| B  | 114.1 | 30.1 | p3          | 114.12        | 30.12         | 2939.507557       | p2          | 114.05        | 30.05         | 7350.037700       | 5144.772629   |\r\n\r\n### 2. Find the nearest point for each point within the same table and add its ID, longitude, latitude, and distance.\r\n\r\n```python\r\nimport pandas as pd\r\nimport tablegis as tg\r\n\r\n# Create an example DataFrame\r\ndf2 = pd.DataFrame({\r\n    'id': ['A', 'B', 'C', 'D'],\r\n    'lon2': [116.403, 116.407, 116.404, 116.408],\r\n    'lat2': [39.914, 39.918, 39.916, 39.919]\r\n})\r\n\r\n# Calculate the nearest 1 point\r\nresult = tg.min_distance_onetable(df2, 'lon2', 'lat2', idname='id', n=1)\r\n# Calculate the nearest 2 points\r\nresult2 = tg.min_distance_onetable(df2, 'lon2', 'lat2', idname='id', n=2)\r\n\r\nprint(\"\\nExample result (distance in meters):\")\r\nprint(result)\r\nprint(result2)\r\n```\r\n\r\n**Result Display:**\r\n\r\n**Table df2:**\r\n\r\n| id | lon2   | lat2  |\r\n|----|--------|-------|\r\n| p1 | 114.01 | 30.01 |\r\n| p2 | 114.05 | 30.05 |\r\n| p3 | 114.12 | 30.12 |\r\n\r\n**Nearest 1 point:**\r\n\r\n|    | id | lon2   | lat2  | nearest1_id | nearest1_lon2 | nearest1_lat2 | nearest1_distance |\r\n|---:|----|--------|-------|-------------|---------------|---------------|-------------------|\r\n|  0 | p1 | 114.01 | 30.01 | p2          | 114.05        | 30.05         | 5881.336911       |\r\n|  1 | p2 | 114.05 | 30.05 | p1          | 114.01        | 30.01         | 5881.336911       |\r\n|  2 | p3 | 114.12 | 30.12 | p2          | 114.05        | 30.05         | 10289.545038      |\r\n\r\n**Nearest 2 points:**\r\n\r\n|    | id | lon2   | lat2  | nearest1_id | nearest1_lon2 | nearest1_lat2 | nearest1_distance | nearest2_id | nearest2_lon2 | nearest2_lat2 | nearest2_distance | mean_distance |\r\n|---:|----|--------|-------|-------------|---------------|---------------|-------------------|-------------|---------------|---------------|-------------------|---------------|\r\n|  0 | p1 | 114.01 | 30.01 | p2          | 114.05        | 30.05         | 5881.336911       | p3          | 114.12        | 30.12         | 16170.880987      | 11026.108949  |\r\n|  1 | p2 | 114.05 | 30.05 | p1          | 114.01        | 30.01         | 5881.336911       | p3          | 114.12        | 30.12         | 10289.545038      | 8085.440974   |\r\n|  2 | p3 | 114.12 | 30.12 | p2          | 114.05        | 30.05         | 10289.545038      | p1          | 114.01        | 30.01         | 16170.880987      | 13230.213012  |\r\n\r\n## Contributing\r\n\r\nContributions in all forms are welcome, including feature requests, bug reports, and code contributions.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License.\r\n",
    "bugtrack_url": null,
    "license": "MIT License\r\n        \r\n        Copyright (c) 2025 Non-existent987\r\n        \r\n        Permission is hereby granted, free of charge, to any person obtaining a copy\r\n        of this software and associated documentation files (the \"Software\"), to deal\r\n        in the Software without restriction, including without limitation the rights\r\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n        copies of the Software, and to permit persons to whom the Software is\r\n        furnished to do so, subject to the following conditions:\r\n        \r\n        The above copyright notice and this permission notice shall be included in all\r\n        copies or substantial portions of the Software.\r\n        \r\n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n        SOFTWARE.\r\n        ",
    "summary": "A powerful Python library for geospatial data processing, analysis and conversion - integrating pandas with GIS operations",
    "version": "0.0.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/Non-existent987/tablegis/issues",
        "Homepage": "https://github.com/Non-existent987/tablegis",
        "Repository": "https://github.com/Non-existent987/tablegis.git"
    },
    "split_keywords": [
        "gis",
        " geospatial",
        " pandas",
        " geopandas",
        " shapefile",
        " kml",
        " geojson",
        " spatial-analysis",
        " geographic",
        " geometry",
        " mapping"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "304038fe805e1233744a31714b4d912dc5b58f1bb532e758edad3838ce409fd0",
                "md5": "158825037a2d09d9c77df1f195bcaf83",
                "sha256": "e48afeac0f9bca108ad287b5e392fb775f4aeefa4279e4e30d7236e637a170ad"
            },
            "downloads": -1,
            "filename": "tablegis-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "158825037a2d09d9c77df1f195bcaf83",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 10209,
            "upload_time": "2025-10-20T10:44:27",
            "upload_time_iso_8601": "2025-10-20T10:44:27.166072Z",
            "url": "https://files.pythonhosted.org/packages/30/40/38fe805e1233744a31714b4d912dc5b58f1bb532e758edad3838ce409fd0/tablegis-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "44a362d5b79ef05a98a67bbdfe8ac75966d4cff15bfb22649985c5efae8cd93b",
                "md5": "ae95b4a6b027958e18b1af4f569d4c61",
                "sha256": "2717f04d44330b43dbb487afa7d345bb08cc4bad8d27d7e2aefe42f6ff1a6863"
            },
            "downloads": -1,
            "filename": "tablegis-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ae95b4a6b027958e18b1af4f569d4c61",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 13309,
            "upload_time": "2025-10-20T10:44:28",
            "upload_time_iso_8601": "2025-10-20T10:44:28.511752Z",
            "url": "https://files.pythonhosted.org/packages/44/a3/62d5b79ef05a98a67bbdfe8ac75966d4cff15bfb22649985c5efae8cd93b/tablegis-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-20 10:44:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Non-existent987",
    "github_project": "tablegis",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tablegis"
}
        
Elapsed time: 1.89659s