Hi Tõnis, I don't have much experience with DGN files, but it looks like there are a bunch of limitations and caveats listed at http://www.gdal.org/drv_dgn.html. The "seed file" in particular looks like something to investigate. Remember that creation options can be passed into fiona.open as kwargs like
with fiona.open('example.dgn', 'w', driver='DGN', schema=schema, crs=crs, seed='seed.dgn') as dst: ... Hope this helps, and happy new year! On Wed, Dec 31, 2014 at 12:01 AM, tõnis kärdi <tonis.ka...@gmail.com> wrote: > > Hi, > > I can't seem to get writing dgn files with fiona to work - it results in > "ValueError: Null layer". The same script works fine for writing shapefiles > and MI tabs. > I managed to create a DGN file using QGIS and then read it using fiona. I > don't know much about CAD files in general so I'm sure there's something > I've missed totally, any pointers much appreciated. > > Here's how it goes: > > C:\>ogr2ogr --version > GDAL 1.11.0, released 2014/04/16 > C:\>python > Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] > on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import fiona > >>> print fiona.__version__ > 1.1.6 > >>> > > schema and properties read from the file created in QGIS > except for schema['geometry'] which was set manually to LineString > as fiona reports it as 'Unknown' when reading: > > >>> schema = {'geometry': 'LineString', 'properties': > fiona.OrderedDict([(u'Type', 'int:2'), (u'Level', 'int:2'), > (u'GraphicGroup', 'int:4'), (u'ColorIndex', 'int:3'), (u'Weight', 'int:2'), > (u'Style', 'int:1'), (u'EntityNum', 'int'), (u'MSLink', 'int'), (u'Text', > 'str')])} > >>> properties = {u'Style': 0, u'ColorIndex': 0, u'Weight': 0, u'Level': > 0, u'Text': None, u'MSLink': None, u'GraphicGroup': 0, u'EntityNum': None, > u'Type': 14} > >>> crs = {'lon_0': 24, 'no_defs': True, 'x_0': 500000, 'lat_2': 58, > 'lat_1': 59.33333333333334, 'towgs84': '0,0,0,0,0,0,0', 'ellps': 'GRS80', > 'y_0': 6375000, 'proj': 'lcc', 'units': 'm', 'lat_0': 57.51755393055556} > >>> > > [...] > > >>> with fiona.open( > ... 'd:/tmp/nna.dgn', > ... 'w', > ... 'DGN', > ... schema=schema, > ... crs=crs) as sink: > ... sink.write( > ... {'geometry': { > ... 'type': 'LineString', > ... 'coordinates': [ > ... [658513.3899922734, 6475203.499964565], > ... [658467.8400262331, 6475236.229952499], > ... [658486.4300012367, 6475258.259991983], > ... [658528.96998106, 6475228.000044374], > ... [658513.3899922734, 6475203.499964565]] > ... }, > ... 'type': 'Feature', > ... 'properties': properties}) > ... > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > with fiona.open('d:/tmp/nna.dgn', 'w', 'DGN', schema=schema, crs=crs) > as sink: > File "C:\Python27\lib\site-packages\fiona\__init__.py", line 156, in open > encoding=encoding, layer=layer, vsi=vsi, archive=archive) > File "C:\Python27\lib\site-packages\fiona\collection.py", line 132, in > __init__ > self.session.start(self, **kwargs) > File "ogrext.pyx", line 960, in fiona.ogrext.WritingSession.start > (src/fiona/ogrext.c:15730) > ValueError: Null layer > >>> > > All the best, > Tõnis > > p.s. tried writing DGN also using osgeo.ogr. For whatever reason the > .CreateLayer(...) method always returns None... > > _______________________________________________ > Community mailing list > Community@lists.gispython.org > http://lists.gispython.org/mailman/listinfo/community > > -- Sean Gillies
_______________________________________________ Community mailing list Community@lists.gispython.org http://lists.gispython.org/mailman/listinfo/community