Skip to content

Commit

Permalink
Add setup script (#1)
Browse files Browse the repository at this point in the history
* Add setup script

* Add install instructions to README
  • Loading branch information
DPeterK authored May 6, 2021
1 parent 2a1f5a3 commit 35d2e6c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# shapecutter
Cut data out of raster arrays based on Shapely Polygons


## Install

Download the source or clone from GitHub, navigate to the downloaded source then use pip to run the local setup script directly:

```bash
cd shapecutter
pip install -e .
```

**Note:** this will install dependencies from pip. During testing there were some issues installing Cartopy 0.19.0 from pip. To work around this you might be better pre-installing the dependencies directly, for example by using conda:

```bash
conda create -n shapecutter -c conda-forge iris shapely geopandas
conda activate shapecutter
```

And then install shapecutter, as above.
28 changes: 28 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import setuptools


with open("README.md", "r") as fh:
long_description = fh.read()

setuptools.setup(
name="shapecutter",
version="0.0.1",
author="Peter Killick",
author_email="peter.killick@informaticslab.co.uk",
description="Cut data out of raster arrays around shapely geometries",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/informatics-lab/shapecutter",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: OS Independent",
],
python_requires=">=3.7",
install_requires=[
"geopandas>=0.9.0",
"scitools-iris>=2.4.0",
"Shapely>=1.7.0"
]
)
2 changes: 0 additions & 2 deletions shapecutter/cutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def _cut_to_boundary(self, subset, geometry_ref):
else:
raise
else:
print(f"[_boundary] - subset shape: {subset.shape}, mask shape: {mask_2d.shape}")
result = self.data_provider.apply_mask(subset, mask_2d, dims_2d)
return result

Expand All @@ -141,7 +140,6 @@ def cut_dataset(self, geometry_ref, to="bbox"):
"""
# 1. extract subset to the shapefile's bounding box.
subset = self.geometry_bbox_dataset(geometry_ref)
print(f"[cut_dataset] - subset shape: {subset.shape}")

if to == "bbox":
result = subset
Expand Down

0 comments on commit 35d2e6c

Please sign in to comment.