Repository: cogeotiff/rio-cogeo

Issue:
Rename `YCbCR` profile to `JPEG`
https://github.com/mapbox/rio-cogeo/blob/dc48a99b23fa1c538cb8b81747c5217fc1f996b7/rio_cogeo/profiles.py#L6

I think using `jpeg` instead of `ycbcr` will make more sense for a profile name 

cc @perrygeo @sgillies 

Comments:

Patch:
diff --git a/CHANGES.txt b/CHANGES.txt
index 5c30828..99752e8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,12 @@
+Next release
+------------
+- Renamed "ycbcr" profile's name to "jpeg" to reflect the compression name.
+  "ycbcr" profile will raise a "DeprecationWarning" (#44)
+- "webp" profile has been added to COG profiles. Exploitation of this new
+  compression mode will require GDAL 2.4 (#27)
+- Rio-cogeo can calculate the overview level based on the internal tile size
+  and the dataset width/height (#37)
+
 1.0dev8 (2018-10-02)
 --------------------
 - write tags in output file (#31)
diff --git a/README.rst b/README.rst
index be79c05..b24078f 100644
--- a/README.rst
+++ b/README.rst
@@ -43,11 +43,13 @@ Usage
 
   Options:
     -b, --bidx BIDX                 Band index to copy
-    -p, --cog-profile [ycbcr|zstd|lzw|deflate|packbits|raw]
-                                    CloudOptimized GeoTIFF profile (default: ycbcr)
+    -p, --cog-profile [ycbcr|jpeg|webp|zstd|lzw|deflate|packbits|raw]
+                                    CloudOptimized GeoTIFF profile (default: jpeg)
     --nodata INTEGER                Force mask creation from a given nodata value
     --alpha INTEGER                 Force mask creation from a given alpha band number
-    --overview-level INTEGER        Overview level (default: 6)
+    --overview-level INTEGER        Overview level
+                                    (if not provided, appropriate overview level will be selected until the
+                                    smallest overview is smaller than the internal block size)
     --overview-resampling [nearest|bilinear|cubic|cubic_spline|lanczos|average|mode|gauss] Resampling algorithm.
     --threads INTEGER
     --co, --profile NAME=VALUE      Driver specific creation options.See the
@@ -60,8 +62,8 @@ Examples
 
 .. code-block:: console
 
-  # Create a COGEO with YCbCR profile and the first 3 bands of the data
-  $ rio cogeo mydataset.tif mydataset_ycbcr.tif -b 1,2,3
+  # Create a COGEO with JPEG profile and the first 3 bands of the data
+  $ rio cogeo mydataset.tif mydataset_jpeg.tif -b 1,2,3
 
   # Create a COGEO without compression and with 1024x1024 block size
   $ rio cogeo mydataset.tif mydataset_raw.tif --co BLOCKXSIZE=1024 --co BLOCKYSIZE=1024 --cog-profile raw
@@ -71,7 +73,14 @@ Default COGEO profiles
 
 Profiles can be extended by providing '--co' option in command line (e.g: rio cogeo mydataset.tif mydataset_zstd.tif -b 1,2,3 --profile deflate --co "COMPRESS=ZSTD" )
 
-**YCbCr**
+**YCbCr** *DEPRECATED in 1.0*
+
+- JPEG compression
+- PIXEL interleave
+- YCbCr colorspace
+- limited to uint8 datatype and 3 bands data
+
+**JPEG**
 
 - JPEG compression
 - PIXEL interleave
@@ -115,8 +124,10 @@ Profiles can be extended by providing '--co' option in command line (e.g: rio co
 
 Default profiles are tiled with 512x512 blocksizes.
 
-Contribution & Devellopement
-============================
+Contribution & Development
+==========================
+
+The rio-cogeo project was begun at Mapbox and has been transferred in January 2019.
 
 Issues and pull requests are more than welcome.
 
diff --git a/rio_cogeo/errors.py b/rio_cogeo/errors.py
new file mode 100644
index 0000000..f0da547
--- /dev/null
+++ b/rio_cogeo/errors.py
@@ -0,0 +1,5 @@
+"""Rio-Cogeo Errors and Warnings."""
+
+
+class DeprecationWarning(UserWarning):
+    """Rio-cogeo module deprecations warning."""
diff --git a/rio_cogeo/profiles.py b/rio_cogeo/profiles.py
index cf9e9b4..02a4e03 100644
--- a/rio_cogeo/profiles.py
+++ b/rio_cogeo/profiles.py
@@ -1,5 +1,7 @@
 """rio_cogeo.profiles: CloudOptimized profiles."""
 
+import warnings
+from rio_cogeo.errors import DeprecationWarning
 from rasterio.profiles import Profile
 
 
@@ -17,6 +19,20 @@ class YCbCrProfile(Profile):
     }
 
 
+class JPEGProfile(Profile):
+    """Tiled, pixel-interleaved, JPEG-compressed, YCbCr colorspace, 8-bit GTiff."""
+
+    defaults = {
+        "driver": "GTiff",
+        "interleave": "pixel",
+        "tiled": True,
+        "blockxsize": 512,
+        "blockysize": 512,
+        "compress": "JPEG",
+        "photometric": "YCbCr",
+    }
+
+
 class WEBPProfile(Profile):
     """Tiled, pixel-interleaved, WEBP-compressed, 8-bit GTiff."""
 
@@ -105,6 +121,7 @@ class COGProfiles(dict):
         self.update(
             {
                 "ycbcr": YCbCrProfile(),
+                "jpeg": JPEGProfile(),
                 "webp": WEBPProfile(),
                 "zstd": ZSTDProfile(),
                 "lzw": LZWProfile(),
@@ -116,6 +133,12 @@ class COGProfiles(dict):
 
     def get(self, key):
         """Like normal item access but error."""
+        if key == "ycbcr":
+            warnings.warn(
+                "'ycbcr' profile will be removed in 1.0, use 'jpeg' instead",
+                DeprecationWarning,
+            )
+
         if key not in (self.keys()):
             raise KeyError("{} is not a valid COG profile name".format(key))
 
diff --git a/rio_cogeo/scripts/cli.py b/rio_cogeo/scripts/cli.py
index d0c3442..b2b56b8 100644
--- a/rio_cogeo/scripts/cli.py
+++ b/rio_cogeo/scripts/cli.py
@@ -43,8 +43,8 @@ class CustomType:
     "-p",
     "cogeo_profile",
     type=click.Choice(cog_profiles.keys()),
-    default="ycbcr",
-    help="CloudOptimized GeoTIFF profile (default: ycbcr)",
+    default="jpeg",
+    help="CloudOptimized GeoTIFF profile (default: jpeg)",
 )
 @click.option(
     "--nodata", type=int, help="Force mask creation from a given nodata value"


Test patch:
diff --git a/tests/test_profile.py b/tests/test_profile.py
index 4926f81..6783e38 100644
--- a/tests/test_profile.py
+++ b/tests/test_profile.py
@@ -1,13 +1,25 @@
 """tests rio_cogeo.profiles."""
 
 import pytest
-
+from rio_cogeo.errors import DeprecationWarning
 from rio_cogeo.profiles import cog_profiles
 
 
 def test_profiles_ycbcr():
-    """Should work as expected (return ycbcr profile)."""
-    profile = cog_profiles.get("ycbcr")
+    """Should work as expected (return ycbcr profile and raise warning)."""
+    with pytest.warns(DeprecationWarning):
+        profile = cog_profiles.get("ycbcr")
+        assert profile["tiled"]
+        assert profile["compress"] == "JPEG"
+        assert profile["blockxsize"] == 512
+        assert profile["blockysize"] == 512
+        assert profile["photometric"] == "YCbCr"
+        assert profile["interleave"] == "pixel"
+
+
+def test_profiles_jpeg():
+    """Should work as expected (return jpeg profile)."""
+    profile = cog_profiles.get("jpeg")
     assert profile["tiled"]
     assert profile["compress"] == "JPEG"
     assert profile["blockxsize"] == 512