4

Just wondering how to write a non spatial (aspatial) table to geopackage using python. I have attempted using Fiona,

geopackage = 'some_geo.gpkg'    
layer = 'test_layer'
schema = {'geometry': {'type': 'aspatial'}, 'properties': [('filename', 'str')]}

with fiona.open(geopackage, 'w', layer=layer, driver='GPKG', schema=schema) as db:
    record = {'geometry': {'type': 'aspatial'},
              'properties': {'filename': filename[:-4]}}
    db.write(record)

This comes up with a Attribute Error because its trying to strip a dict, but I dont think thats the real issue here.

0

Regular SQLITE3 you can use the .dump command to copy data from one database to another.

| improve this answer | |
0

Yes looks like 'aspatial' was deprecated in geopackage v1.2 https://gdal.org/drivers/vector/geopackage_aspatial.html

Have you tried simply not specifying the geometry field.

geopackage = 'some_geo.gpkg'    
layer = 'test_layer'
schema = {'properties': [('filename', 'str')]}

with fiona.open(geopackage, 'w', layer=layer, driver='GPKG', schema=schema) as db:
    record = {'properties': {'filename': filename[:-4]}}
    db.write(record)

Also here https://fiona.readthedocs.io/en/latest/manual.html#records under the 'writing records from scratch' section, it suggests using the output_driver = geojson maybe in your instance you need to specify json ? geojson my force a geometry field name in the record.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.