jwass / geojsonio.py Goto Github PK
View Code? Open in Web Editor NEWOpen GeoJSON data on geojson.io
License: BSD 2-Clause "Simplified" License
Open GeoJSON data on geojson.io
License: BSD 2-Clause "Simplified" License
I kept getting GitHubError: 422 Validation Failed
from github3.py
when running geojsonio.display(json, force_gist=True)
. Then I found issue 795 on the github3.py repo. Are there any plans already in the works to pass GitHub account info for pushing geojsons to authorized gists?
For Now , we have to reload maps to add new markers...
I need to update the markers in Geojson without reloading..is there any way to achieve that
Thank you for your contribution, the tool is pretty cool and simple.
I tried to reproduce an example using geopandas
as in the README but I got an error message once the browser opens: "Could not parse JSON" on the top left, and an empty FeatureCollection on the right.
import geopandas as gpd
import geojsonio
gdf = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
geojsonio.display(gdf.to_json())
geojsonio.display(gdf.iloc[:2].to_json()) # Worked
After investigation, I found that in fact the problem depends on the size of the URL request, as the geojson loaded is big.
I manage to get it worked if I take the first 4 rows of the GeoDataFrame, but it can't make it above 7.
I bet it is a restriction on geojson.io side, but I wonder if you had a solution to bypass ?
Maybe login or run it local somehow, I am not sure.
Hello, after using display() there is mistake with authentication:
gist = ghapi.create_gist(description, files)
174 return gist
File ~\AppData\Local\anaconda3\lib\site-packages\github3\decorators.py:32, in requires_auth..auth_wrapper(self, *args, **kwargs)
28 # Mock a 401 response
29 r = generate_fake_error_response(
30 '{"message": "Requires authentication"}'
31 )
---> 32 raise error_for(r)
Can somebody help, please
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
When I try to visualize a bigger geojson, I get:
Traceback (most recent call last):
File "/home/math/.local/bin/geojsonio", line 11, in <module>
sys.exit(main())
File "/home/math/.local/lib/python3.5/site-packages/geojsonio/geojsonio.py", line 214, in main
url = make_url(contents, args.domain)
File "/home/math/.local/lib/python3.5/site-packages/geojsonio/geojsonio.py", line 93, in make_url
gist = _make_gist(contents)
File "/home/math/.local/lib/python3.5/site-packages/geojsonio/geojsonio.py", line 172, in _make_gist
gist = ghapi.create_gist(description, files)
File "/home/math/.local/lib/python3.5/site-packages/github3/decorators.py", line 37, in auth_wrapper
raise error_for(r)
github3.exceptions.AuthenticationFailed: 401 Requires authentication
How can I authenticate?
Could you please make a mention of the gem posting data publicly on GitHub somewhere?
I'm trying to embed a map in my Jupyter notebook. When I try to run the geojsonio.embed(geojson) function, the browser window is redirected to the geojson.io site. However when I embed any other site in an Iframe, it works fine.
This try's to redirect me.
import geojsonio, json
geojson = { "type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
[100.0, 1.0], [100.0, 0.0] ]
]
},
"properties": {
"prop0": "value0",
}
}
]
}
#redirects me to a geojsonio site
url = geojsonio.embed(json.dumps(geojson))
Using another URL the iframe functionality works as expected.
from IPython.display import IFrame
url0 = 'http://donkeycar.com'
IFrame(url, width='100%', height=500)
embed
command doesn't embed the plot inside jupyter notebook instead it opens the link (GeoJSON) and displays nothing.
Hi,
Following this tutorial: https://www.twilio.com/blog/2017/08/geospatial-analysis-python-geojson-geopandas.html
When I get to the geojsonio.display() line, I get the following error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/temp-venv/lib/python3.6/site-packages/github3/models.py in __init__(self, json, session)
47 try:
---> 48 self._update_attributes(json)
49 except KeyError as kerr:
~/temp-venv/lib/python3.6/site-packages/github3/gists/gist.py in _update_attributes(self, gist)
324 def _update_attributes(self, gist):
--> 325 super(Gist, self)._update_attributes(gist)
326 self.commits_url = gist['commits_url']
~/temp-venv/lib/python3.6/site-packages/github3/gists/gist.py in _update_attributes(self, gist)
50 self.id = gist['id']
---> 51 self.owner = users.ShortUser(gist['owner'], self)
52 self.public = gist['public']
KeyError: 'owner'
During handling of the above exception, another exception occurred:
IncompleteResponse Traceback (most recent call last)
<ipython-input-12-9a29351e3f24> in <module>()
----> 1 geojsonio.display(precincts)
~/temp-venv/lib/python3.6/site-packages/geojsonio/geojsonio.py in display(contents, domain, force_gist)
34
35 """
---> 36 url = make_url(contents, domain, force_gist)
37 webbrowser.open(url)
38 return url
~/temp-venv/lib/python3.6/site-packages/geojsonio/geojsonio.py in make_url(contents, domain, force_gist, size_for_gist)
91 url = data_url(contents, domain)
92 else:
---> 93 gist = _make_gist(contents)
94 url = gist_url(gist.id, domain)
95
~/temp-venv/lib/python3.6/site-packages/geojsonio/geojsonio.py in _make_gist(contents, description, filename)
170 ghapi = github3.GitHub()
171 files = {filename: {'content': contents}}
--> 172 gist = ghapi.create_gist(description, files)
173
174 return gist
~/temp-venv/lib/python3.6/site-packages/github3/github.py in create_gist(self, description, files, public)
303 url = self._build_url('gists')
304 json = self._json(self._post(url, data=new_gist), 201)
--> 305 return self._instance_or_null(gists.Gist, json)
306
307 @requires_auth
~/temp-venv/lib/python3.6/site-packages/github3/models.py in _instance_or_null(self, instance_class, json)
144 return None
145
--> 146 return instance_class(json, self)
147
148 def _json(self, response, expected_status_code, include_cache_info=True):
~/temp-venv/lib/python3.6/site-packages/github3/models.py in __init__(self, json, session)
48 self._update_attributes(json)
49 except KeyError as kerr:
---> 50 raise exceptions.IncompleteResponse(json, kerr)
51
52 def _update_attributes(self, json):
IncompleteResponse: None The library was expecting more data in the response (KeyError('owner',)). Either GitHub modified it's response body, or your token is not properly scoped to retrieve this information.
When running:
from geojsonio import display
with open('map.geojson') as f:
contents = f.read()
display(contents)
with data from Google in the file map.geojson I receive the following error:
ValueError Traceback (most recent call last)
<ipython-input-6-cd14c4214ce4> in <module>()
3 with open('map.geojson') as f:
4 contents = f.read()
----> 5 display(contents)
C:\ProgramData\Anaconda3\lib\site-packages\geojsonio\geojsonio.py in display(contents, domain, force_gist)
35 """
36 url = make_url(contents, domain, force_gist)
---> 37 webbrowser.open(url)
38 return url
39 # display() used to be called to_geojsonio. Keep it around for now...
C:\ProgramData\Anaconda3\lib\webbrowser.py in open(url, new, autoraise)
58 for name in _tryorder:
59 browser = get(name)
---> 60 if browser.open(url, new, autoraise):
61 return True
62 return False
C:\ProgramData\Anaconda3\lib\webbrowser.py in open(self, url, new, autoraise)
511 def open(self, url, new=0, autoraise=True):
512 try:
--> 513 os.startfile(url)
514 except OSError:
515 # [Error 22] No application is associated with the specified
ValueError: startfile: filepath too long for Windows
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.