From 35d2e6cc480510e25c1d8e01b9533a0499c3915b Mon Sep 17 00:00:00 2001 From: Peter Killick Date: Thu, 6 May 2021 11:07:36 +0100 Subject: [PATCH] Add setup script (#1) * Add setup script * Add install instructions to README --- README.md | 19 +++++++++++++++++++ setup.py | 28 ++++++++++++++++++++++++++++ shapecutter/cutter.py | 2 -- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 setup.py diff --git a/README.md b/README.md index 991dd40..9391a49 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f198f90 --- /dev/null +++ b/setup.py @@ -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" + ] +) \ No newline at end of file diff --git a/shapecutter/cutter.py b/shapecutter/cutter.py index 354b7d3..01bf836 100644 --- a/shapecutter/cutter.py +++ b/shapecutter/cutter.py @@ -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 @@ -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