How to get equivalent geographical data as us ones ?

Hello

I try to reproduce such plot example : texas.py — Bokeh 2.4.2 Documentation but for france.

Looking at the script and the contains of bokeh.sampledata.us_counties.data, if I well understand, the script do the following :

  • data contains for each council of each state the latitude and longitude of the council border
  • for each texas council, bokeh draw a shape according to latitude and longitude coordinates with a give color
    Thus what I need is the coordinates of french departement or region borders, right ?

If I am true, my question is where or how can I obtain such information ?

Thanks

Germain

Hey Germain,

General GIS questions are probably best asked at something like GIS StackExchange, there are way more GIS users to help you out, increasing your chances for a good answer.

That said, there are a few general (global sources you could look at), Natural Earth data or GADM for example:
http://www.naturalearthdata.com/
http://www.gadm.org/

Alternatively, the National Geographic Institute (IGN) offers a Shapefile at community level:
http://professionnels.ign.fr/geofla#tab-3

It contains department codes in the attributes so you can use GIS software to ‘dissolve’ it based on those attributes.

For as far as plotting geographical polygons with Bokeh, using the GeoJSONDataSource is probably the easiest way. Here is an example for the departments in France:
http://nbviewer.jupyter.org/gist/RutgerK/8ea51f0405f338f892d3dcc69f8cabdf

Regards,
Rutger

···

On Friday, November 18, 2016 at 12:26:35 PM UTC+1, [email protected] wrote:

Hello

I try to reproduce such plot example : http://bokeh.pydata.org/en/latest/docs/gallery/texas.html but for france.

Looking at the script and the contains of bokeh.sampledata.us_counties.data, if I well understand, the script do the following :

  • data contains for each council of each state the latitude and longitude of the council border
  • for each texas council, bokeh draw a shape according to latitude and longitude coordinates with a give color
    Thus what I need is the coordinates of french departement or region borders, right ?

If I am true, my question is where or how can I obtain such information ?

Thanks

Germain

Hello

Nice, thank you a lot for your example in the notebook.

Combining geopandas and shape file dowloaded here Contours des départements français issus d'OpenStreetMap - data.gouv.fr I think I am not far away the result.

Where did you download your geojson file ? On data.gouv.fr I find only shape file or other binary files.

Regards

Germain

···

Le lundi 21 novembre 2016 09:52:51 UTC+1, Rutger Kassies a écrit :

Hey Germain,

General GIS questions are probably best asked at something like GIS StackExchange, there are way more GIS users to help you out, increasing your chances for a good answer.

That said, there are a few general (global sources you could look at), Natural Earth data or GADM for example:
http://www.naturalearthdata.com/
http://www.gadm.org/

Alternatively, the National Geographic Institute (IGN) offers a Shapefile at community level:
http://professionnels.ign.fr/geofla#tab-3

It contains department codes in the attributes so you can use GIS software to ‘dissolve’ it based on those attributes.

For as far as plotting geographical polygons with Bokeh, using the GeoJSONDataSource is probably the easiest way. Here is an example for the departments in France:
http://nbviewer.jupyter.org/gist/RutgerK/8ea51f0405f338f892d3dcc69f8cabdf

Regards,
Rutger

On Friday, November 18, 2016 at 12:26:35 PM UTC+1, [email protected] wrote:

Hello

I try to reproduce such plot example : http://bokeh.pydata.org/en/latest/docs/gallery/texas.html but for france.

Looking at the script and the contains of bokeh.sampledata.us_counties.data, if I well understand, the script do the following :

  • data contains for each council of each state the latitude and longitude of the council border
  • for each texas council, bokeh draw a shape according to latitude and longitude coordinates with a give color
    Thus what I need is the coordinates of french departement or region borders, right ?

If I am true, my question is where or how can I obtain such information ?

Thanks

Germain

Hey Germain,
My geojson came from the IGN link which i posted below. They provide an ESRI Shapefile at community level which i dissolved (=groupby department) using QGIS. I’m not a GeoPandas user, so i cant comment that. But if you can export it to geosjon, you could use that to populate Bokeh’s GeoJSONDataSource object and follow my example from there.
If you use the Shapefile from your URL (data.gouv.fr), you should change some attribute references in my example, which uses attributes for coloring and the hover:
Change @NOM_DEPT to @nom, and ‘CODE_DEPT’ to 'code_insee’ for example.

Be aware that the Shapefile from your url also contains the oversee regions part of France. That might ruin the visualization a bit, you can specify a ‘x_range’ and ‘y_range’ when calling Bokeh’s figure. This sets a initial boundingbox allowing you to center the plot on a region of interest.

Regards,
Rutger

···

On Wednesday, November 23, 2016 at 12:22:41 AM UTC+1, [email protected] wrote:

Hello

Nice, thank you a lot for your example in the notebook.

Combining geopandas and shape file dowloaded here https://www.data.gouv.fr/en/datasets/contours-des-departements-francais-issus-d-openstreetmap/ I think I am not far away the result.

Where did you download your geojson file ? On data.gouv.fr I find only shape file or other binary files.

Regards

Germain

Le lundi 21 novembre 2016 09:52:51 UTC+1, Rutger Kassies a écrit :

Hey Germain,

General GIS questions are probably best asked at something like GIS StackExchange, there are way more GIS users to help you out, increasing your chances for a good answer.

That said, there are a few general (global sources you could look at), Natural Earth data or GADM for example:
http://www.naturalearthdata.com/
http://www.gadm.org/

Alternatively, the National Geographic Institute (IGN) offers a Shapefile at community level:
http://professionnels.ign.fr/geofla#tab-3

It contains department codes in the attributes so you can use GIS software to ‘dissolve’ it based on those attributes.

For as far as plotting geographical polygons with Bokeh, using the GeoJSONDataSource is probably the easiest way. Here is an example for the departments in France:
http://nbviewer.jupyter.org/gist/RutgerK/8ea51f0405f338f892d3dcc69f8cabdf

Regards,
Rutger

On Friday, November 18, 2016 at 12:26:35 PM UTC+1, [email protected] wrote:

Hello

I try to reproduce such plot example : http://bokeh.pydata.org/en/latest/docs/gallery/texas.html but for france.

Looking at the script and the contains of bokeh.sampledata.us_counties.data, if I well understand, the script do the following :

  • data contains for each council of each state the latitude and longitude of the council border
  • for each texas council, bokeh draw a shape according to latitude and longitude coordinates with a give color
    Thus what I need is the coordinates of french departement or region borders, right ?

If I am true, my question is where or how can I obtain such information ?

Thanks

Germain

Hello

As it is not my main activity I work on this when I have time …

I come back to your first link about IGN : http://professionnels.ign.fr/geofla#tab-3 and I dowloaded the shapefile directly with departements. Then I read it with geopandas and try to use the code you provided me. That is what I get :

http://nbviewer.jupyter.org/github/gvallverdu/cookbook/blob/master/departements.ipynb

It works !!! Why did you download “communes” level and then groupby departement ? Is there a reason or just you download it to do a test ?

What I still do not understand, is that if I do exactly the same operations (export to json) with the shape file that I get from data.gouv.fr I got an error such as

TypeError: <shapely.geometry.polygon.Polygon object at 0x10e4430b8> is not JSON serializable

I first assumed that it comes from Polygon and Mutlipolygon but both shape files contain both polygon and multypolygon objects… Thus I do not know from where come the problem.

I do not know if bokeh could work with geopandas data frame, but, a simple work flow could be to work on the geo data frame, then export it with the data you want to json and then read the json with GeoJsonDataSource …

Thanks again for your help

Germain

···

Le mercredi 23 novembre 2016 09:09:10 UTC+1, Rutger Kassies a écrit :

Hey Germain,
My geojson came from the IGN link which i posted below. They provide an ESRI Shapefile at community level which i dissolved (=groupby department) using QGIS. I’m not a GeoPandas user, so i cant comment that. But if you can export it to geosjon, you could use that to populate Bokeh’s GeoJSONDataSource object and follow my example from there.
If you use the Shapefile from your URL (data.gouv.fr), you should change some attribute references in my example, which uses attributes for coloring and the hover:
Change @NOM_DEPT to @nom, and ‘CODE_DEPT’ to 'code_insee’ for example.

Be aware that the Shapefile from your url also contains the oversee regions part of France. That might ruin the visualization a bit, you can specify a ‘x_range’ and ‘y_range’ when calling Bokeh’s figure. This sets a initial boundingbox allowing you to center the plot on a region of interest.

Regards,
Rutger

On Wednesday, November 23, 2016 at 12:22:41 AM UTC+1, [email protected] wrote:

Hello

Nice, thank you a lot for your example in the notebook.

Combining geopandas and shape file dowloaded here https://www.data.gouv.fr/en/datasets/contours-des-departements-francais-issus-d-openstreetmap/ I think I am not far away the result.

Where did you download your geojson file ? On data.gouv.fr I find only shape file or other binary files.

Regards

Germain

Le lundi 21 novembre 2016 09:52:51 UTC+1, Rutger Kassies a écrit :

Hey Germain,

General GIS questions are probably best asked at something like GIS StackExchange, there are way more GIS users to help you out, increasing your chances for a good answer.

That said, there are a few general (global sources you could look at), Natural Earth data or GADM for example:
http://www.naturalearthdata.com/
http://www.gadm.org/

Alternatively, the National Geographic Institute (IGN) offers a Shapefile at community level:
http://professionnels.ign.fr/geofla#tab-3

It contains department codes in the attributes so you can use GIS software to ‘dissolve’ it based on those attributes.

For as far as plotting geographical polygons with Bokeh, using the GeoJSONDataSource is probably the easiest way. Here is an example for the departments in France:
http://nbviewer.jupyter.org/gist/RutgerK/8ea51f0405f338f892d3dcc69f8cabdf

Regards,
Rutger

On Friday, November 18, 2016 at 12:26:35 PM UTC+1, [email protected] wrote:

Hello

I try to reproduce such plot example : http://bokeh.pydata.org/en/latest/docs/gallery/texas.html but for france.

Looking at the script and the contains of bokeh.sampledata.us_counties.data, if I well understand, the script do the following :

  • data contains for each council of each state the latitude and longitude of the council border
  • for each texas council, bokeh draw a shape according to latitude and longitude coordinates with a give color
    Thus what I need is the coordinates of french departement or region borders, right ?

If I am true, my question is where or how can I obtain such information ?

Thanks

Germain