import fiona
import io
example_schema = {
'geometry': 'Point',
'properties': [('title', 'str')],
}
example_features = [
{
"geometry": {"type": "Point", "coordinates": [0.0, 0.0]},
"properties": {"title": "One"},
},
{
"geometry": {"type": "Point", "coordinates": [1.0, 2.0]},
"properties": {"title": "Two"},
},
{
"geometry": {"type": "Point", "coordinates": [3.0, 4.0]},
"properties": {"title": "Three"},
},
]
crs_wkt = (
'PROJCRS["WGS 84 / UTM zone 11N",'
'BASEGEOGCRS["WGS 84",'
'DATUM["World Geodetic System 1984",'
'ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],'
'PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],'
'ID["EPSG",4326]],'
'CONVERSION["UTM zone 11N",'
'METHOD["Transverse Mercator",ID["EPSG",9807]],'
'PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],'
'PARAMETER["Longitude of natural origin",-117,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],'
'PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],'
'PARAMETER["False easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],'
'PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],'
'CS[Cartesian,2],'
'AXIS["(E)",east,'
'ORDER[1],'
'LENGTHUNIT["metre",1]],'
'AXIS["(N)",north,'
'ORDER[2],'
'LENGTHUNIT["metre",1]],'
'USAGE['
'SCOPE["unknown"],'
'AREA["World - N hemisphere - 120掳W to 114掳W - by country"],'
'BBOX[0,-120,84,-114]],'
'ID["EPSG",32611]]'
)
with io.BytesIO() as fd:
with fiona.open(fd, 'w',
driver='GPKG',
schema=example_schema,
# crs=example_crs
crs_wkt=crs_wkt
) as dst:
dst.writerecords(example_features)
fd.seek(0)
with fiona.open(fd) as src:
assert src.crs
Actual behavior: assertion error
Expected behavior: everything ok
I think the issue is that crs_wkt is not being passed through to memfile.open on those lines:
Thanks @habibutsu @jorisvandenbossche for doing the investigation & having a really nice example.