Données carroyées#

Links: notebook, html, PDF, python, slides, GitHub

Les données carroyées sont des données économiques agrégées sur tout le territoire français sur des carrés de 200m de côté.

from jyquickhelper import add_notebook_menu
add_notebook_menu()

Département de la réunion#

Le code suivant utilise les données de la réunion disponible sur le site de l’INSEE : Données carroyées à 200 mètres. Voir aussi la fonction load_carreau_from_zip et aussi la fonction from_file du module geopandas.

from papierstat.datasets import load_carreau_from_zip
dfcar, shpcar, dfrect, shprect = load_carreau_from_zip()
dfcar.head()
id idINSPIRE idk ind_c nbcar
0 UTM40S200M_N38171E01797 CRS2975RES200mN7634200E0359400 N38171E01797-N38172E01797 16.0 2.0
1 UTM40S200M_N38172E01779 CRS2975RES200mN7634400E0355800 N38172E01779-N38172E01779 40.0 1.0
2 UTM40S200M_N38172E01780 CRS2975RES200mN7634400E0356000 N38172E01780-N38172E01780 64.0 1.0
3 UTM40S200M_N38172E01781 CRS2975RES200mN7634400E0356200 N38172E01781-N38172E01782 106.0 2.0
4 UTM40S200M_N38172E01782 CRS2975RES200mN7634400E0356400 N38172E01781-N38172E01782 6.0 2.0
shpcar.head()
idINSPIRE id geometry
0 CRS2975RES200mN7634200E0359400 UTM40S200M_N38171E01797 POLYGON ((359400.000 7634200.000, 359600.000 7...
1 CRS2975RES200mN7634400E0355800 UTM40S200M_N38172E01779 POLYGON ((355800.000 7634400.000, 356000.000 7...
2 CRS2975RES200mN7634400E0356000 UTM40S200M_N38172E01780 POLYGON ((356000.000 7634400.000, 356200.000 7...
3 CRS2975RES200mN7634400E0356200 UTM40S200M_N38172E01781 POLYGON ((356200.000 7634400.000, 356400.000 7...
4 CRS2975RES200mN7634400E0356400 UTM40S200M_N38172E01782 POLYGON ((356400.000 7634400.000, 356600.000 7...
dfrect.head().T
0 1 2 3 4
idk N38171E01797-N38172E01797 N38172E01779-N38172E01779 N38172E01780-N38172E01780 N38172E01781-N38172E01782 N38172E01798-N38173E01798
men 32 15 39 44 14
men_surf 2263 1202 2605 3103 1379
men_occ5 17 8 3 21 14
men_coll 12 0 0 1 0
men_5ind 7 2 2 6 1
men_1ind 7 3 22 14 1
i_1ind 0 0 0 0 0
men_prop 17 10 8 22 11
i_prop 0 0 2 0 1
men_basr 15 4 20 16 0
i_basr 0 0 0 0 0
ind_r 101 40 64 112 38
ind_age1 7 3 4 7 1
ind_age2 2 1 1 3 0
ind_age3 6 5 0 12 2
ind_age4 5 2 2 5 3
ind_age5 8 0 0 4 3
ind_age6 62 26 55 69 26
ind_age7 3 7 34 14 4
i_age7 0 0 0 0 0
ind_age8 1 2 12 9 1
i_age8 0 0 0 0 0
ind_srf 1.01807e+06 459078 536160 1.09746e+06 687108
nbcar 2 1 1 2 2
shprect.head()
idk geometry
0 N38171E01797-N38172E01797 POLYGON ((359400.000 7634200.000, 359600.000 7...
1 N38172E01779-N38172E01779 POLYGON ((355800.000 7634400.000, 356000.000 7...
2 N38172E01780-N38172E01780 POLYGON ((356000.000 7634400.000, 356200.000 7...
3 N38172E01781-N38172E01782 POLYGON ((356200.000 7634400.000, 356600.000 7...
4 N38172E01798-N38173E01798 POLYGON ((359600.000 7634400.000, 359800.000 7...

Il faut lire la page Données carroyées à 200 mètres pour découvrir le système de coordonnées utilisée sur la Réunion et plus précisément Saint-Denis (-20.887090, 55.451716).

import warnings
warnings.simplefilter("ignore", (FutureWarning, DeprecationWarning))
from pyproj import Proj, transform

p1 = Proj(init='epsg:4326')  # longitude / latidude
p2 = Proj(init='epsg:2975')  #
coor = transform(p1, p2, 55.451716, -20.887090)
coor
(338953.2627389685, 7689572.419008633)
from shapely.geometry import Point
sd = Point(coor)
jardin = shprect[shprect.geometry.contains(sd)]
jardin
idk geometry
7217 N38447E01694-N38447E01694 POLYGON ((338800.000 7689400.000, 339000.000 7...

Conversion du geodataframe en un autre référenciel#

jardinll = jardin.to_crs({'init':'epsg:4326'})
jardinll
idk geometry
7217 N38447E01694-N38447E01694 POLYGON ((55.45023 -20.88863, 55.45215 -20.888...

Premier carreau avec folium#

La carte suivante le carreau sur la carte d’OpenStreetMap.

import folium
map_osm = folium.Map(location=[-20.887090, 55.451716], zoom_start=16)
folium.GeoJson(jardinll).add_to(map_osm)

map_osm