I'm glad it did! I fixed linemerge, too. Details at https://github.com/Toblerity/Shapely/issues/135. I don't have the next Shapely release scheduled, but there's nothing much blocking it, so maybe the end of the week.
On Tue, Jun 10, 2014 at 9:52 AM, Ari Simmons <ari.ucb.f...@gmail.com> wrote: > Hi Sean. > > Thanks, that worked like a charm. > > Sooo...something I am trying to wrap my head around here...it seems that > in my 'input_schema' whether I put 'LineString' or 'MultiLineString' the > result is always the same (which is: a 'MultiLineString'). > > For ex: I was expecting if I put 'LineString' in as the ( 'geometry': > 'LineString' ) that the lines (**if they were geometrically connected and > of course had the same key**) would be dissolved into a single feature (as > oppose to a 'MultiLineString'). > > Also...same thing happened when I used linemerge() in place of > > cascaded_union() .. > > >> > > def dissolve(inFile, outFile): > # dictionary for union > > uniqueRefs = {} > > with fiona.open(inFile, 'r', encoding='utf-8') as input: > input_driver = input.driver > input_crs = input.crs > # it seems whether this is a 'LineString' or a 'MultiLineString' it > will always > > # return a 'MultiLineString' > input_schema = {'geometry': 'LineString','properties': > {'ref'.encode("utf-8"): 'str:254'}} > > with fiona.open(outFile, 'w', driver=input_driver, crs=input_crs, > schema=input_schema, encoding='utf-8') as output: > > for item in input: > > # extract the key > key = item['properties']['ref'] > > geom = shape(item['geometry']) > > if not geom.type.startswith('Multi'): > > geom = [geom] > for g in geom: > if key in uniqueRefs: > uniqueRefs[key].append(g) > else: > uniqueRefs[key] = [g] > > for key in uniqueRefs: > dissolve_feat = cascaded_union(uniqueRefs[key]) > output.write({'geometry':mapping(dissolve_feat), > 'properties': {'ref': key}}) > > > _______________________________________________ > 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