jwass / geojsonio.py

Open GeoJSON data on geojson.io
BSD 2-Clause "Simplified" License
121 stars 25 forks source link

problems with display('file.geojson') #5

Open Magdalena88 opened 8 years ago

Magdalena88 commented 8 years ago

Hi.

I'm trying to open my geojson file containing some polygons, applying exactly the code reported but the tool opens the browser without showing my data. If I manually upload my data on geojson.io they are correctly visualized.

Can you help me? thanks

jwass commented 8 years ago

Hi @Magdalena88,

I noticed the issue title is display('file.geojson'), is that how your code is using geojsonio? If so, you first have to read the contents, then call display. Would this code from the README work?

with open('file.geojson') as f:
    contents = f.read()
    display(contents)

Does that work?

Magdalena88 commented 8 years ago

Thanks for your fast replay :) Yes, I already tried that code and the issue is related to it. :(

jwass commented 8 years ago

Would you feel comfortable posting the polygon data you're using somewhere along with the code that will reproduce the bug?

My guess is that when the data is too big, we can't use geojson.io this way - the Python library creates an anonymous Github gist then tells geojson.io to download it. When it's too big geojson.io can't download the entire gist. But it works when uploading the file locally. That's just a guess though.

Magdalena88 commented 8 years ago

Yes of course. The code I'm using is:

from geojsonio import display

with open('AOI.geojson') as f: contents = f.read() display(contents) f.close()

I have the same issue also when trying to open a single polygon. I'm copying you the polygon data below:

{ "type": "FeatureCollection", "features": [ { "geometry": { "type": "Polygon", "coordinates": [ [ [ 30.84825076017768, 29.84449235157097 ], [ 31.59090692089696, 29.83395854639918 ], [ 31.58332490917348, 30.21149316913375 ], [ 30.89876172494296, 30.24098056978401 ], [ 30.84825076017768, 29.84449235157097 ] ] ] }, "type": "Feature", "properties": { "Name": "AOI", "Description": "" }, "id": 0 } ] }

jwass commented 8 years ago

@Magdalena88 Hmm...

Here are the contents of my script.py and AOI.geojson:

Running $python script.py opens up the window with a small rectangle in Egypt. I noticed your code has f.close() which isn't needed because of the with but it shouldn't affect the rest of the script. Can you confirm that this doesn't work on your end?

from geojsonio import display

with open('AOI.geojson') as f:
    contents = f.read()
    display(contents)

AOI.geojson:

{
"type": "FeatureCollection",
"features": [
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
30.84825076017768,
29.84449235157097
],
[
31.59090692089696,
29.83395854639918
],
[
31.58332490917348,
30.21149316913375
],
[
30.89876172494296,
30.24098056978401
],
[
30.84825076017768,
29.84449235157097
]
]
]
},
"type": "Feature",
"properties": {
"Name": "AOI",
"Description": ""
},
"id": 0
}
]
}
jwass commented 8 years ago

P.S. if it still doesn't work, what OS and browser+version are you using?

Magdalena88 commented 8 years ago

my OS is Windoes 7 and I use Chrome 50.0.2661.102 :)

2016-05-18 16:19 GMT+02:00 Jacob Wasserman notifications@github.com:

P.S. if it still doesn't work, what OS and browser+version are you using?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/jwass/geojsonio.py/issues/5#issuecomment-220040637