AntonelloDN / ShrimpGIS

A basic plugin for Grasshopper to read and write shapefile and geojson (GPL)
GNU General Public License v3.0
17 stars 3 forks source link

shrimp plugin help #2

Closed martin8smith closed 3 years ago

martin8smith commented 3 years ago

Hi Antonello,

Thank you for the help! The Read GEOJSON component seems to work fine with files that don't have a lot of data (i.e. datasets that just have polylines for city parks, or street center lines). But when I try to use .geojson files for building polygons and such, it seems to not like it and gives me that error. I can't really crop the .geojson file for just a specific area because A. I'm not sure how to do that (not a GIS wizard), and B. I really don't know what to crop yet (i'm using this for urban studies, so I would like to start analysis at a city scale)

Here's a screenshot showing the error:

2020-10-01T11_36_05

And the .geojson file i'm trying to use:

https://we.tl/t-AlZ05PjZR3

Thanks Antonello!! I hope I can get this to work; your plugin seems amazing.

AntonelloDN commented 3 years ago

Hi @martin8smith ,

Thanks for your kind words. Here is my debug:

pygeoj.py is an external module that I have integrated in ShrimpGIS: https://pypi.org/project/PyGeoj/

there is a problem with pygeoj.py when you have "geometry: null". Basically, there are some empty geometry in your geojson and pygeoj goes in error (I need a double check but this is at the first look) So you can run a raw script like this to remove all "geometry: null"

source = <ABSOLUTE PATH OF YOUR SOURCE FILE>
target = <ABSOLUTE PATH OF TARGET FILE>
to_search = '"geometry": null'

text = []
with open(source, 'r') as f:
    lines = f.readlines()
    for l in lines:
        if to_search in l:
            continue
        else:
            text.append(l)

with open(target, 'w') as f:
    for l in text:
        f.write(l)

There is a second problem, pygeo.py library supports only [X, Y] coordinates and not [X, Y, Z], like it is reported here: https://tools.ietf.org/html/rfc7946#section-3.1.7

So I have hacked the module in this simple way:

  1. go to %appdata%
  2. go to shrimp_gis/io/pygeoj.py
  3. go to line 232 and add a third loop variable _z for example image

... and this is the results. image I think there are too many brep objects (218332) so Rhino will not run smoothly. If you need just few of them, you can trim the file with QGIS firstly.

Contact me on Linkedin if you need the "clean" geojson.

Best, Antonello

martin8smith commented 3 years ago

Thanks a lot, Antonello! I will give this a try. I really need to learn QGIS to clip files...

BTW, do you know if these building polygon shapes have the Z coordinates attached to them for building height values? That would be pretty intense information (I didn't think the city of Minneapolis even recorded all of that, but it could be a new thing).

AntonelloDN commented 3 years ago

@martin8smith here is a possible method to crop a vector file. DVnNPRH0oT It seems that all z values are 0.0. Z value is used to set the height of the footprint on the terrain usually, whilst the height of the building should be part of the db, but that field seems to be missing image image

Best, Antonello

AntonelloDN commented 3 years ago

Hi @martin8smith I close this issue. I hope the explanation is clear. So the problem is related to this standard RFC7946 and the PyGeoj library.