Code Monkey home page Code Monkey logo

geojsonio.py's People

Contributors

carsonfarmer avatar jwass avatar msabramo avatar themiurgo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geojsonio.py's Issues

GitHub removed support for anonymous gists

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?

Could not parse JSON error: Empty FeatureCollection

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.

401 Requires authentication

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

problems with display('file.geojson')

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

github3.exceptions.AuthenticationFailed: 401 Requires authentication

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?

geojsonio.embed redirects me to geojson.io instead of embedding an Iframe in the notebook.

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 issues

embed command doesn't embed the plot inside jupyter notebook instead it opens the link (GeoJSON) and displays nothing.

KeyError: 'owner' / IncompleteResponse: None

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.

ValueError: startfile: filepath too long for Windows

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.