Grasshopper

algorithmic modeling for Rhino

here is a python script that export vertex and attributes to GEOJSON format.

GEOJSON_export: A Plugin that export surfaces and its attributes to a GEOJSON file
 -----------------------------------
Need pygeoj.py It must be in your script's folder
by Karim Bahgat https://github.com/karimbahgat
-----------------------------------
TODO :
use something like : https://github.com/karimbahgat/PyCRS
-----------------------------------

 Copyright (c) 2015, Guillaume Meunier <alliages@gmail.com>
 GEOJSON_export is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
 
GEOJSON_export is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

GNU General Public License a href="http://www.gnu.org/licenses/&gt">http://www.gnu.org/licenses/&gt;.
 
@license GPL-3.0+ a href="http://spdx.org/licenses/GPL-3.0+&gt">http://spdx.org/licenses/GPL-3.0+&gt;

-

    Args:
        path: path where to export
        filename: filename of your JSON without its extension (GEOJSON added)
        using_keys: which key attributes to export, 'id' by default
        s_names: values of 'id' key
        s_keys: normally each surfaces user attributes' keys
        s_values: normally each surfaces user attributes' values
        s_vertex: vertex of each surfaces
        run: do the export
        
    Returns:
        out: various information
        coordiantes: coordinates in JSON format
        properties: properties in JSON format

VER 1.3

few bugfixes

31_5_2016

VER 1.2

create multipolygon (with holes and multiple objects)

23_3_2016

-----

VER 1.1

resolved problem with geometry check in qgis by closing completely polygon

5_1_2016

---

VER 1.0

3_12_2015

In Extra category

code is here : https://gist.github.com/Alliages/8dbfce7cdd24383342b0

Views: 2881

Attachments:

Replies to This Discussion

Hi Guillaume,

this is nice! It could go to the 'Sample and example files' section of the site.
You can move that yourself, if you want.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

thanks and done

updated version 1.1 that resolved problem with geometry check in qgis by closing completely polygon

updated to version 1.2 that now export all sorts of polygon, even multipolygon (polygon with hole or separated polygon)

Dear Guillaume,

thanks for providing this script! That's exactly what I was looking for.
Could you also upload the .gh file to understand better how you provide the input data?

Best regards

Reinhard

my GH file is a kind of a mess. The last script you see on the screenshot is a simple VB script that concat 2 trees.

Basically the script divide objects between geometries with or without holes (CapEx function)

if without, it only project coordinates using gHowl and Mosquito

if with, the main objective is to separate outer and inner edges then insert "inner, inner" and re-merge

Dear Guillaume,

many thanks for your reply. This helps a lot. 

Am I right, that the GeoJSON export works only if I provide Attributes and Keys as string per surface? I tried to use only a tree of vertexes as shown in your figure, but this is obviously not sufficient... so I need to create the corresponding strings, too?

Best regards

Reinhard

on my gist i add a bugfixe (version 1.3) https://gist.github.com/Alliages/8dbfce7cdd24383342b0

now you can use it without key and value but you still need names

i'll change files here this week

Updated version 1.3

2 bugfixes :

  • export without keys and values is possible
  • output corrected

just to make things a bit more clear

Thanks!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service