# Buggy code
def from_dataset(cls, dataset, map_crs="epsg:4326"):
    if dataset.crs is None:
        return IdentityCRSTransformer()
    transform = dataset.transform
    image_crs = dataset.crs["init"]
    return cls(transform, image_crs, map_crs)


# Traceback (KeyError)
Checking for existing output  [####################################]  100%
Saving command configuration to /opt/data/rv_root/chip/xview-object_detection/command-config.json...
Saving command configuration to /opt/data/rv_root/train/xview-object-detection-mobilenet/command-config.json...
Saving command configuration to /opt/data/rv_root/bundle/xview-object-detection-mobilenet/command-config.json...
Saving command configuration to /opt/data/rv_root/predict/xview-object-detection-mobilenet/command-config.json...
Saving command configuration to /opt/data/rv_root/eval/xview-object-detection-mobilenet/command-config.json...
python -m rastervision  run_command /opt/data/rv_root/chip/xview-object_detection/command-config.json
Making training chips...
2019-03-20 16:00:47:rastervision.utils.files: INFO - Downloading s3://azavea-nyc-ml/cogs/000227.tif to /tmp/tmp98w0p7cl/tmpypmuuz6t/tmpqbscq03c/s3/azavea-nyc-ml/cogs/000227.tif
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/src/rastervision/__main__.py", line 17, in <module>
rv.main()
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/opt/src/rastervision/cli/main.py", line 253, in run_command
rv.runner.CommandRunner.run(command_config_uri)
File "/opt/src/rastervision/runner/command_runner.py", line 11, in run
CommandRunner.run_from_proto(msg)
File "/opt/src/rastervision/runner/command_runner.py", line 17, in run_from_proto
command.run()
File "/opt/src/rastervision/command/chip_command.py", line 22, in run
map(lambda s: s.create_scene(cc.task, tmp_dir), cc.train_scenes))
File "/opt/src/rastervision/command/chip_command.py", line 22, in <lambda>
map(lambda s: s.create_scene(cc.task, tmp_dir), cc.train_scenes))
File "/opt/src/rastervision/data/scene_config.py", line 36, in create_scene
raster_source = self.raster_source.create_source(tmp_dir)
File "/opt/src/rastervision/data/raster_source/geotiff_source_config.py", line 70, in create_source
y_shift_meters=y_shift_meters)
File "/opt/src/rastervision/data/raster_source/geotiff_source.py", line 46, in __init__
super().__init__(raster_transformers, temp_dir, channel_order)
File "/opt/src/rastervision/data/raster_source/rasterio_source.py", line 47, in __init__
with self.activate():
File "/opt/src/rastervision/data/activate_mixin.py", line 21, in __enter__
self.activate()
File "/opt/src/rastervision/data/activate_mixin.py", line 54, in do_activate
self._activate()
File "/opt/src/rastervision/data/raster_source/geotiff_source.py", line 104, in _activate
super()._activate()
File "/opt/src/rastervision/data/raster_source/rasterio_source.py", line 106, in _activate
self._set_crs_transformer()
File "/opt/src/rastervision/data/raster_source/geotiff_source.py", line 56, in _set_crs_transformer
self.image_dataset)
File "/opt/src/rastervision/data/crs_transformer/rasterio_crs_transformer.py", line 59, in from_dataset
image_crs = dataset.crs['init']
File "/usr/lib/python3.5/collections/__init__.py", line 986, in __getitem__
raise KeyError(key)
KeyError: 'init'
/tmp/tmpkon0yhf2/tmpyysq6a82/Makefile:6: recipe for target '0' failed
make: *** [0] Error 1

# Fixed code
def from_dataset(cls, dataset, map_crs="epsg:4326"):
    if dataset.crs is None:
        return IdentityCRSTransformer()
    transform = dataset.transform
    image_crs = dataset.crs
    return cls(transform, image_crs, map_crs)