diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3eb64408..a3f60e90 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,6 @@ name: Test Python package -on: - - push +on: [push, pull_request] jobs: test: @@ -50,4 +49,3 @@ jobs: run: tox -e format - name: Test with tox run: tox -e test - diff --git a/environment.yaml b/environment.yaml index 20b1f0af..8aeae2d7 100644 --- a/environment.yaml +++ b/environment.yaml @@ -14,7 +14,7 @@ dependencies: - pyproj>=2.1 - PyYAML>=5.4 - rasterio>=1.0.23 - - requests==2.22.0 + - requests>=2.27.1 - rtree>=0.9.3 - scikit-image>=0.16.2 - scipy>=1.3.2 diff --git a/requirements-test.txt b/requirements-test.txt index a2d2c963..17788914 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -17,9 +17,9 @@ shapely>=1.8.0 tqdm>=4.40.0 urllib3<1.26 # testing requirements -black +black==22.1.0 pytest -tox -isort -flake8 -pre-commit \ No newline at end of file +tox==3.24.5 +isort==5.10.1 +flake8==4.0.1 +pre-commit diff --git a/solaris/__init__.py b/solaris/__init__.py index cb4bdf79..8df9926e 100644 --- a/solaris/__init__.py +++ b/solaris/__init__.py @@ -1,4 +1,4 @@ -from . import data, utils, vector # noqa: F401 +from . import data, tile, utils, vector # noqa: F401 # data, eval, preproc, raster, tile, have gdal in them need to replace with rasterio -__version__ = "0.0.1" +__version__ = "0.5.0" diff --git a/solaris/tile/raster_tile.py b/solaris/tile/raster_tile.py index ea7a3dd2..4c118569 100644 --- a/solaris/tile/raster_tile.py +++ b/solaris/tile/raster_tile.py @@ -511,8 +511,8 @@ def save_tile(self, tile_data, mask, profile, dest_fname_base=None): if self.proj_unit not in ["meter", "metre"]: dest_fname = "{}_{}_{}.tif".format( dest_fname_root, - np.round(profile["transform"][2], 3), - np.round(profile["transform"][5], 3), + np.round(profile["transform"][2], 6), + np.round(profile["transform"][5], 6), ) else: dest_fname = "{}_{}_{}.tif".format( @@ -537,7 +537,6 @@ def save_tile(self, tile_data, mask, profile, dest_fname_base=None): dest.write(mask, profile["count"] + 1) dest.close() - return dest_path # if self.cog_output: diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.003_41.774.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.002861_41.773516.tif similarity index 99% rename from tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.003_41.774.tif rename to tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.002861_41.773516.tif index fa3742d9..a61a5e1a 100644 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.003_41.774.tif and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.002861_41.773516.tif differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.044_41.691.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.04413_41.690969.tif similarity index 96% rename from tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.044_41.691.tif rename to tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.04413_41.690969.tif index 75a7fbd4..0f216369 100644 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.044_41.691.tif and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.04413_41.690969.tif differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.044_41.732.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.04413_41.732243.tif similarity index 73% rename from tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.044_41.732.tif rename to tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.04413_41.732243.tif index 7a8b0f12..4ea67ca5 100644 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.044_41.732.tif and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.04413_41.732243.tif differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.044_41.774.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.04413_41.773516.tif similarity index 77% rename from tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.044_41.774.tif rename to tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.04413_41.773516.tif index a6d3bc9e..f6e3630a 100644 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.044_41.774.tif and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.04413_41.773516.tif differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.085_41.691.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.0854_41.690969.tif similarity index 79% rename from tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.085_41.691.tif rename to tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.0854_41.690969.tif index ce461694..617b2c33 100644 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.085_41.691.tif and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.0854_41.690969.tif differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.0854_41.732243.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.0854_41.732243.tif new file mode 100644 index 00000000..e2265d2b Binary files /dev/null and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.0854_41.732243.tif differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.085_41.774.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.0854_41.773516.tif similarity index 82% rename from tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.085_41.774.tif rename to tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.0854_41.773516.tif index 41e84e29..77ae5db5 100644 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.085_41.774.tif and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.0854_41.773516.tif differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.085_41.732.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.085_41.732.tif deleted file mode 100644 index 9b8c2fe1..00000000 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.085_41.732.tif and /dev/null differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.127_41.691.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.12667_41.690969.tif similarity index 76% rename from tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.127_41.691.tif rename to tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.12667_41.690969.tif index f9bcefb2..e4a665ec 100644 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.127_41.691.tif and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.12667_41.690969.tif differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.127_41.732.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.12667_41.732243.tif similarity index 74% rename from tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.127_41.732.tif rename to tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.12667_41.732243.tif index 8def1a5c..66d5574d 100644 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.127_41.732.tif and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.12667_41.732243.tif differ diff --git a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.127_41.774.tif b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.12667_41.773516.tif similarity index 85% rename from tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.127_41.774.tif rename to tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.12667_41.773516.tif index 033d472b..c8958882 100644 Binary files a/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.127_41.774.tif and b/tests/data/rastertile_test_fill_nodata_expected/aoi_restricted_nebraska_landsat5_with_nodata_wgs84_-101.12667_41.773516.tif differ diff --git a/tests/test_tile/test_tile.py b/tests/test_tile/test_tile.py index db308406..40bc6a29 100644 --- a/tests/test_tile/test_tile.py +++ b/tests/test_tile/test_tile.py @@ -18,19 +18,13 @@ def test_tiler(self): os.path.join(data_dir, "rastertile_test_result"), src_tile_size=(90, 90) ) raster_tiler.tile(src=os.path.join(data_dir, "sample_geotiff.tif")) - raster_tiling_result_files = os.listdir( - os.path.join(data_dir, "rastertile_test_result") - ) + raster_tiling_result_files = os.listdir(os.path.join(data_dir, "rastertile_test_result")) assert len(raster_tiling_result_files) == len( os.listdir(os.path.join(data_dir, "rastertile_test_expected")) ) for f in raster_tiling_result_files: - result = skimage.io.imread( - os.path.join(data_dir, "rastertile_test_result", f) - ) - expected = skimage.io.imread( - os.path.join(data_dir, "rastertile_test_expected", f) - ) + result = skimage.io.imread(os.path.join(data_dir, "rastertile_test_result", f)) + expected = skimage.io.imread(os.path.join(data_dir, "rastertile_test_expected", f)) assert np.array_equal(result, expected) os.remove(os.path.join(data_dir, "rastertile_test_result", f)) os.rmdir(os.path.join(data_dir, "rastertile_test_result")) @@ -38,17 +32,13 @@ def test_tiler(self): vector_tiler.tile( os.path.join(data_dir, "geotiff_labels.geojson"), raster_tiler.tile_bounds ) - vector_tiling_result_files = os.listdir( - os.path.join(data_dir, "vectortile_test_result") - ) + vector_tiling_result_files = os.listdir(os.path.join(data_dir, "vectortile_test_result")) assert len(vector_tiling_result_files) == len( os.listdir(os.path.join(data_dir, "vectortile_test_expected")) ) for f in vector_tiling_result_files: result = gpd.read_file(os.path.join(data_dir, "vectortile_test_result", f)) - expected = gpd.read_file( - os.path.join(data_dir, "vectortile_test_expected", f) - ) + expected = gpd.read_file(os.path.join(data_dir, "vectortile_test_expected", f)) if len(result) == 0: assert len(expected) == 0 else: @@ -80,9 +70,7 @@ def test_tiler_custom_proj(self): assert np.array_equal(result, expected) os.remove(os.path.join(data_dir, "rastertile_test_custom_proj_result", f)) os.rmdir(os.path.join(data_dir, "rastertile_test_custom_proj_result")) - vector_tiler = VectorTiler( - os.path.join(data_dir, "vectortile_test_custom_proj_result") - ) + vector_tiler = VectorTiler(os.path.join(data_dir, "vectortile_test_custom_proj_result")) vector_tiler.tile( os.path.join(data_dir, "geotiff_custom_proj_labels.geojson"), raster_tiler.tile_bounds, @@ -94,9 +82,7 @@ def test_tiler_custom_proj(self): os.listdir(os.path.join(data_dir, "vectortile_test_custom_proj_expected")) ) for f in vector_tiling_result_files: - result = gpd.read_file( - os.path.join(data_dir, "vectortile_test_custom_proj_result", f) - ) + result = gpd.read_file(os.path.join(data_dir, "vectortile_test_custom_proj_result", f)) expected = gpd.read_file( os.path.join(data_dir, "vectortile_test_custom_proj_expected", f) ) @@ -124,9 +110,7 @@ def test_tiler_fill_nodata(self): restrict_to_aoi=True, ) - vector_tiler = VectorTiler( - os.path.join(data_dir, "vectortile_test_nonfilled_result") - ) + vector_tiler = VectorTiler(os.path.join(data_dir, "vectortile_test_nonfilled_result")) vector_tiler.tile( os.path.join(data_dir, "nebraska_wgs84_with_nodata_labels.geojson"), @@ -177,9 +161,7 @@ def test_tiler_fill_nodata(self): assert np.array_equal(result, expected) for f in vector_tiling_result_files: - result = skimage.io.imread( - os.path.join(data_dir, "vectortile_test_filled_result", f) - ) + result = skimage.io.imread(os.path.join(data_dir, "vectortile_test_filled_result", f)) expected = skimage.io.imread( os.path.join(data_dir, "vectortile_test_filled_expected", f) )