Example #1
0
def test_to_transform_iter():
    transform = Affine(30.0, 0.0, -2102235.0, 0.0, -30.0, 1939455.0)
    # test as a list / tuple / np.ndarray
    assert convert.to_transform(list(transform)) == transform
    assert convert.to_transform(tuple(transform)) == transform
    assert convert.to_transform(np.array(transform)) == transform
    # with "from_gdal"
    geotransform = transform.to_gdal()
    assert convert.to_transform(geotransform, from_gdal=True) == transform
Example #2
0
def test_create_grid_mapping_utm(crs, attrs, name):
    transform = Affine(30, 0, -130,
                       0, -30, 170)
    gridmap = conventions.create_grid_mapping(crs, transform, name)

    assert gridmap.name == name

    if crs.to_epsg():
        assert gridmap.item() == crs.to_epsg()

    for k, v in attrs.items():
        assert k in gridmap.attrs
        assert gridmap.attrs[k] == v

    # Check GDAL attributes
    assert gridmap.attrs['spatial_ref'] == crs.wkt
    assert np.array_equal(gridmap.attrs['GeoTransform'],
                          transform.to_gdal())