# Reshaper
Splits and recombines shapefiles based on lat-long data.
## Installation
conda install -c conda-forge gdal
pip install reshaper
## Usage
To split a state map based on a branch list, use:
reshaper state.shp branch.csv output.shp \
--id <ID column> \
--lat <Latitude column> \
--lng <Longitude column> \
--col <Any additional columns to add>
The arguments are:
- `state.shp`: path to the original shapefile
- `branch.csv`: path to the CSV file with points data. The output shapefile will
have one shape per row of this file
- `output.shp`: path to the output shapefile
- `--id branchname`: indicates that the `branchname` column holds the branch
identifier. The values in this column must be unique
- `--lat col1`: the `col1` column holds the latitude in degrees
- `--lng col2`: the `col2` column holds the longitude in degrees
- `--col col3`: add `col3` column to the Shapefile attributes. You can specify
multiple columns via `--col`
The CSV file should have at least these 3 columns: ID, latitude and longitude.
The program splits and re-combines shapes based the following logic:
- If a state does not have a branch, assign it fully to the nearest branch
- If a state has only one branch, assign it fully to that branch
- If a state has multiple branches, split it between the branches and assign each broken state to the respective branch
The output shapefile attributes include the `--id` column and any other columns
specified via `--col`.
## Release
Change the `"version"` in `setup.py` to `"x.x.x"`, commit and tag:
```bash
git commit . -m"Describe features / bug fixes"
git tag -a vx.x.x -m"one-line summary of release"
```
To [distribute](https://packaging.python.org/en/latest/distributing.html), run:
```bash
rm -rf build dist
flake8 .
python setup.py test
python setup.py sdist bdist_wheel --universal
twine upload dist/*
```
Raw data
{
"_id": null,
"home_page": "https://github.com/sanand0/reshaper",
"name": "reshaper",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "reshaper",
"author": "S Anand",
"author_email": "root.node@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d0/4b/77de0215aa8060ca9de5b8f90c1783aa33f90d71785e0df045aef79b1001/reshaper-1.1.1.tar.gz",
"platform": null,
"description": "# Reshaper\r\n\r\nSplits and recombines shapefiles based on lat-long data.\r\n\r\n## Installation\r\n\r\n conda install -c conda-forge gdal\r\n pip install reshaper\r\n\r\n## Usage\r\n\r\nTo split a state map based on a branch list, use:\r\n\r\n reshaper state.shp branch.csv output.shp \\\r\n --id <ID column> \\\r\n --lat <Latitude column> \\\r\n --lng <Longitude column> \\\r\n --col <Any additional columns to add>\r\n\r\nThe arguments are:\r\n\r\n- `state.shp`: path to the original shapefile\r\n- `branch.csv`: path to the CSV file with points data. The output shapefile will\r\n have one shape per row of this file\r\n- `output.shp`: path to the output shapefile\r\n- `--id branchname`: indicates that the `branchname` column holds the branch\r\n identifier. The values in this column must be unique\r\n- `--lat col1`: the `col1` column holds the latitude in degrees\r\n- `--lng col2`: the `col2` column holds the longitude in degrees\r\n- `--col col3`: add `col3` column to the Shapefile attributes. You can specify\r\n multiple columns via `--col`\r\n\r\nThe CSV file should have at least these 3 columns: ID, latitude and longitude.\r\n\r\nThe program splits and re-combines shapes based the following logic:\r\n\r\n- If a state does not have a branch, assign it fully to the nearest branch\r\n- If a state has only one branch, assign it fully to that branch\r\n- If a state has multiple branches, split it between the branches and assign each broken state to the respective branch\r\n\r\nThe output shapefile attributes include the `--id` column and any other columns\r\nspecified via `--col`.\r\n\r\n## Release\r\n\r\nChange the `\"version\"` in `setup.py` to `\"x.x.x\"`, commit and tag:\r\n\r\n```bash\r\ngit commit . -m\"Describe features / bug fixes\"\r\ngit tag -a vx.x.x -m\"one-line summary of release\"\r\n```\r\n\r\nTo [distribute](https://packaging.python.org/en/latest/distributing.html), run:\r\n\r\n```bash\r\nrm -rf build dist\r\nflake8 .\r\npython setup.py test\r\npython setup.py sdist bdist_wheel --universal\r\ntwine upload dist/*\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "# Reshaper",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/sanand0/reshaper"
},
"split_keywords": [
"reshaper"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "835978dc17fd16f4bb81a0e5b28a198aba8822da6357e4691ae93ef7bf1cb447",
"md5": "d47bad6777a904db55408346d064218e",
"sha256": "34a4afc989ae30e2e3a4c6c5dd9f0cd310b712ff53f25d3caa05589b7d467e4c"
},
"downloads": -1,
"filename": "reshaper-1.1.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "d47bad6777a904db55408346d064218e",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 4842,
"upload_time": "2024-12-25T12:09:36",
"upload_time_iso_8601": "2024-12-25T12:09:36.870163Z",
"url": "https://files.pythonhosted.org/packages/83/59/78dc17fd16f4bb81a0e5b28a198aba8822da6357e4691ae93ef7bf1cb447/reshaper-1.1.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d04b77de0215aa8060ca9de5b8f90c1783aa33f90d71785e0df045aef79b1001",
"md5": "82ba6dc2d9deae6eae567d5756e9c318",
"sha256": "d950db11bbfb8b3b2210809df43fbe7889b822c835339881d3afa44ceccd6be4"
},
"downloads": -1,
"filename": "reshaper-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "82ba6dc2d9deae6eae567d5756e9c318",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4782,
"upload_time": "2024-12-25T12:09:39",
"upload_time_iso_8601": "2024-12-25T12:09:39.152012Z",
"url": "https://files.pythonhosted.org/packages/d0/4b/77de0215aa8060ca9de5b8f90c1783aa33f90d71785e0df045aef79b1001/reshaper-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-25 12:09:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sanand0",
"github_project": "reshaper",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "reshaper"
}