Copying Rasterio crs from input to output dataset


Luke
 

Hi all.  Congrats on the 1.0.0 release!  

Using rasterio 1.0.0 (installed from conda-forge in a fresh conda env). I'm having trouble copying the CRS from on dataset to another.  The output dataset CRS is None.

Simplified example demonstrating:

import rasterio as rio

inpath = r"test.tif"
outpath = r"testout.tif"

with rio.open(inpath) as inds:
    print(repr(inds.crs), inds.meta['crs'])
    with rio.open(outpath, 'w', **inds.meta) as outds:
        outds.write(inds.read())

with rio.open(outpath) as outds:
    print(repr(outds.crs), outds.meta['crs'])

The output of the above is:

CRS({'init': 'epsg:4326'}) +init=epsg:4326
None None

Dataset info:

rio info test.tif
{"blockxsize": 128, "blockysize": 128, "bounds": [143.22468138068513, -34.72000041269073, 146.20968138068514, -31.952500412690732], "colorinterp": ["grey", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined"], "count": 11, "crs": "EPSG:4326", "descriptions": [null, null, null, null, null, null, null, null, null, null, null], "driver": "GTiff", "dtype": "float32", "height": 1107, "indexes": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], "interleave": "pixel", "lnglat": [144.71718138068513, -33.33625041269073], "mask_flags": [["nodata"], ["nodata"], ["nodata"], ["nodata"], ["nodata"], ["nodata"], ["nodata"], ["nodata"], ["nodata"], ["nodata"], ["nodata"]], "nodata": -9999.0, "res": [0.0025000000000000113, 0.0024999999999999983], "shape": [1107, 1194], "tiled": true, "transform": [0.0025000000000000113, 0.0, 143.22468138068513, 0.0, -0.0024999999999999983, -31.952500412690732, 0.0, 0.0, 1.0], "units": [null, null, null, null, null, null, null, null, null, null, null], "width": 1194}

Is this user error (do I need to pass a crs string in?) or perhaps a bug?

Regards
Luke



Join main@rasterio.groups.io to automatically receive all group messages.