pbugnion / gmaps

Google maps for Jupyter notebooks
https://jupyter-gmaps.readthedocs.io/en/stable/
Other
760 stars 146 forks source link

Additional GeoJSON files #112

Open pbugnion opened 7 years ago

pbugnion commented 7 years ago

Gmaps bundles useful GeoJSON geometries to save users the work of having to find them from the Internet. There are currently a handful of geometries included. Adding new geometries is a very useful way to contribute to gmaps. If you use gmaps with your own GeoJSON file, chances are that other people would also find it useful. Contributing the file back to gmaps is a meaningful way to contribute to the project.

What makes a good GeoJSON file

How to contribute GeoJSON files

If you have a way to share your file on the Internet (either by putting it on Amazon S3, or through a Dropbox link, or by putting it on a web server), then do this and add the link to the geojson_geometries) module. We will probably copy the file onto the Amazon S3 bucket stored with gmaps and change the link that you submitted.

If you do not have a way to share the file, open an issue in GitHub and upload your file through that.

zhukov-msu commented 7 years ago

can you please tell how to install new version with geojson? pip says that 0.4.0 is last version tried to install by cloning and "setup.py install", but got a lot of problems like installing dev versions of ipywidgets etc. I use python 3 if it matters. thanks

pbugnion commented 7 years ago

There is a pre-release version on Pypi.

$ pip install gmaps==0.4.1-pre1
$ jupyter nbextension enable --py --sys-prefix widgetsnbextension

Edit: this is now moot. You should use the stable version 0.4.1.

$ pip install gmaps==0.4.1
$ jupyter nbextension enable --py --sys-prefix widgetsnbextension
zhukov-msu commented 7 years ago

Thanks, it works, but there's no method named 'geojson_geometries' like it's in readme...only 'geojson_layer'

pbugnion commented 7 years ago

It's a module -- you need to import it with import gmaps.geojson_geometries.

zhukov-msu commented 7 years ago

Oh, thanks, didn't notice. And please, last question: how to import geometry from custom json file? In your example only standart geometries.

pbugnion commented 7 years ago

Have a look at the loading your own GeoJSON section in the documentation.

Quantonomist commented 7 years ago

gmaps.geojson_geometries did not load on v0.4.0 I installed V0.4.1 and the module did import so thanks for this tip. Issue now is gmaps.geojson_layer....showing as not callable

`

 import gmaps

 import gmaps.geojson_geometries
 import gmaps.geojson_layer
 gmaps.configure(api_key="MY_KEY")
 countries_geojson = gmaps.geojson_geometries.load_geometry('countries')
 m = gmaps.Map()
 gini_layer = gmaps.geojson_layer(countries_geojson)
 m.add_layer(gini_layer)
 m

`

`TypeError Traceback (most recent call last)

in () 5 countries_geojson = gmaps.geojson_geometries.load_geometry('countries') 6 m = gmaps.Map() ----> 7 gini_layer = gmaps.geojson_layer(countries_geojson) 8 m.add_layer(gini_layer) 9 m TypeError: 'module' object is not callable` Any thoughts?
pbugnion commented 7 years ago

Thanks for the feedback!

gmaps.geojson_geometries did not load on v0.4.0. I installed V0.4.1 and the module did import[...]

GeoJSON support was added in v0.4.1, so anything before that wouldn't work.

Issue now is gmaps.geojson_layer....showing as not callable

In Python, you cannot import functions directly like this. You should do this:

import gmaps
import gmaps.geojson_geometries

countries_geojson = gmaps.geojson_geometries.load_geometry('countries')

m = gmaps.Map()
gini_layer = gmaps.geojson_layer(countries_geojson)
m.add_layer(gini_layer)
m

The reason your import didn't fail was because it clashed with an internal module name, which, in hindsight, adds a bit of confusion.

Quantonomist commented 7 years ago

Thank you for clearing up the confusion. That solved the issue.