.. and for whatever reason I was thinking that a hexagon has 8 sides. So
just discard my previous message, hexa can't be achieved with a buffer as
easily. :S

sorry for the mixup.

t;

2014-10-17 18:06 GMT+03:00 tõnis kärdi <tonis.ka...@gmail.com>:

> Hi. Not sure if this will do exactly what You need, but maybe try creating
> a grid of points and then buffer each point using a different resolution (
> http://toblerity.org/shapely/manual.html#object.buffer) than the default
> 16.
>
> something in the line of:
>
> >>> from shapely.geometry import Point
> >>> node = lambda x,y: (x, y)
> >>> coords = [[node(x, y) for x in range(10)] for y in range(10)]
> >>> hexgrid = [Point(*c).buffer(0.1, resolution=2) for c in coords]
> >>> import json
> >>> json.dumps(a[0].__geo_interface__)
> '{"type": "Polygon", "coordinates": [[[0.1, 0.0], [0.07071067811865482,
> -0.07071067811865471], [1.6155445744325868e-16, -0.1],
> [-0.0707106781186546, -0.07071067811865492], [-0.1,
> -3.2310891488651737e-16], [-0.07071067811865504, 0.07071067811865446],
> [-4.624589118372729e-16, 0.1], [0.07071067811865436, 0.07071067811865515],
> [0.1, 0.0]]]}'
>
> You'd have to work out the proper range for grid definition and figure out
> the right buffer distance aswell.
>
> Hope this helps.
>
> All the best,
> Tõnis
>
> 2014-10-17 17:33 GMT+03:00 Stephan Hügel <ursch...@gmail.com>:
>
>> Apologies for the general question, but I’m wondering if anyone’s got a
>> recipe to generate a grid of hexagon polygons (or any tessellating shape!)
>> for given coordinate bounds, using Shapely.
>> Essentially I want to emulate the MMQGIS “Create Grid Layer” function…
>>
>> Pointers and suggestions gladly accepted.
>> --
>> s
>>
>


-- 
--
skype: tonis.kardi
_______________________________________________
Community mailing list
Community@lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community

Reply via email to