gmaps icon indicating copy to clipboard operation
gmaps copied to clipboard

Additional GeoJSON files

Open pbugnion opened this issue 8 years ago • 9 comments

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

  • GeoJSON files should be between 1MB and 3MB. If your file is larger than that, you can use mapshaper to simplify it.

  • The license needs to match that of GMaps: the file should either be in the public domain, or it should be MIT or Apache licensed.

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.

pbugnion avatar Mar 09 '17 07:03 pbugnion

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

zhukov-msu avatar Mar 13 '17 12:03 zhukov-msu

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

pbugnion avatar Mar 13 '17 13:03 pbugnion

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

zhukov-msu avatar Mar 13 '17 13:03 zhukov-msu

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

pbugnion avatar Mar 13 '17 13:03 pbugnion

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

zhukov-msu avatar Mar 13 '17 13:03 zhukov-msu

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

pbugnion avatar Mar 13 '17 15:03 pbugnion

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?

Quantonomist avatar Apr 02 '17 22:04 Quantonomist

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.

pbugnion avatar Apr 03 '17 05:04 pbugnion

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

Quantonomist avatar Apr 03 '17 05:04 Quantonomist