{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Paris Remarkable Trees from 1700 to 2000" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
datasetidrecordidrecord_timestampfields.geom_x_yfields.libellefrancaisfields.objectidfields.idemplacementfields.arrondissementfields.circonferenceencmfields.hauteurenm...fields.stadedeveloppementfields.remarquablefields.idbasefields.genrefields.complementadressefields.typeemplacementfields.dateplantationgeometry.typegeometry.coordinatesfields.varieteoucultivar
0arbresremarquablesparisa236960f295288698ca57fdccfd9825547ffb4d02019-10-04T10:00:41.063000+00:00[48.8630096006, 2.2417737512]Pin49884000901001BOIS DE BOULOGNE241.030.0...M12002349.0Pinus16-08Arbre1882-01-01T00:09:21+00:00Point[2.2417737512, 48.8630096006]NaN
1arbresremarquablesparisd7635937c3636051c99963676d3a97dd4d9dd8c92019-10-04T10:00:41.063000+00:00[48.8731110898, 2.24886478886]Hêtre52761000701004BOIS DE BOULOGNE231.016.0...M12002354.0Fagus16-17Arbre1868-01-01T00:09:21+00:00Point[2.24886478886, 48.8731110898]''Pendula''
2arbresremarquablesparis460e8eccd3ebc816f16317702223bf406e7d75e62019-10-04T10:00:41.063000+00:00[48.8448875264, 2.35366916319]Hêtre6245600000075PARIS 5E ARRDT85.03.0...M1132669.0FagusNaNArbre1905-01-01T00:09:21+00:00Point[2.35366916319, 48.8448875264]''Tortuosa''
3arbresremarquablesparisb60b80e0f8327afba6d0c513b0b6b85639e516b62019-10-04T10:00:41.063000+00:00[48.8787029872, 2.30647417371]Erable6880100NO0144PARIS 8E ARRDT450.028.0...M1305507.0Acer08-01Arbre1700-01-01T00:09:21+00:00Point[2.30647417371, 48.8787029872]NaN
4arbresremarquablesparis47e163d6f0536bc9e26ba2993447c6f50b14a6f62019-10-04T10:00:41.063000+00:00[48.8671184424, 2.25294211329]Platane82341001201001BOIS DE BOULOGNE534.045.0...M12002389.0Platanus16-10Arbre1872-01-01T00:09:21+00:00Point[2.25294211329, 48.8671184424]NaN
\n", "

5 rows × 24 columns

\n", "
" ], "text/plain": [ " datasetid recordid \\\n", "0 arbresremarquablesparis a236960f295288698ca57fdccfd9825547ffb4d0 \n", "1 arbresremarquablesparis d7635937c3636051c99963676d3a97dd4d9dd8c9 \n", "2 arbresremarquablesparis 460e8eccd3ebc816f16317702223bf406e7d75e6 \n", "3 arbresremarquablesparis b60b80e0f8327afba6d0c513b0b6b85639e516b6 \n", "4 arbresremarquablesparis 47e163d6f0536bc9e26ba2993447c6f50b14a6f6 \n", "\n", " record_timestamp fields.geom_x_y \\\n", "0 2019-10-04T10:00:41.063000+00:00 [48.8630096006, 2.2417737512] \n", "1 2019-10-04T10:00:41.063000+00:00 [48.8731110898, 2.24886478886] \n", "2 2019-10-04T10:00:41.063000+00:00 [48.8448875264, 2.35366916319] \n", "3 2019-10-04T10:00:41.063000+00:00 [48.8787029872, 2.30647417371] \n", "4 2019-10-04T10:00:41.063000+00:00 [48.8671184424, 2.25294211329] \n", "\n", " fields.libellefrancais fields.objectid fields.idemplacement \\\n", "0 Pin 49884 000901001 \n", "1 Hêtre 52761 000701004 \n", "2 Hêtre 62456 00000075 \n", "3 Erable 68801 00NO0144 \n", "4 Platane 82341 001201001 \n", "\n", " fields.arrondissement fields.circonferenceencm fields.hauteurenm ... \\\n", "0 BOIS DE BOULOGNE 241.0 30.0 ... \n", "1 BOIS DE BOULOGNE 231.0 16.0 ... \n", "2 PARIS 5E ARRDT 85.0 3.0 ... \n", "3 PARIS 8E ARRDT 450.0 28.0 ... \n", "4 BOIS DE BOULOGNE 534.0 45.0 ... \n", "\n", " fields.stadedeveloppement fields.remarquable fields.idbase fields.genre \\\n", "0 M 1 2002349.0 Pinus \n", "1 M 1 2002354.0 Fagus \n", "2 M 1 132669.0 Fagus \n", "3 M 1 305507.0 Acer \n", "4 M 1 2002389.0 Platanus \n", "\n", " fields.complementadresse fields.typeemplacement fields.dateplantation \\\n", "0 16-08 Arbre 1882-01-01T00:09:21+00:00 \n", "1 16-17 Arbre 1868-01-01T00:09:21+00:00 \n", "2 NaN Arbre 1905-01-01T00:09:21+00:00 \n", "3 08-01 Arbre 1700-01-01T00:09:21+00:00 \n", "4 16-10 Arbre 1872-01-01T00:09:21+00:00 \n", "\n", " geometry.type geometry.coordinates fields.varieteoucultivar \n", "0 Point [2.2417737512, 48.8630096006] NaN \n", "1 Point [2.24886478886, 48.8731110898] ''Pendula'' \n", "2 Point [2.35366916319, 48.8448875264] ''Tortuosa'' \n", "3 Point [2.30647417371, 48.8787029872] NaN \n", "4 Point [2.25294211329, 48.8671184424] NaN \n", "\n", "[5 rows x 24 columns]" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas\n", "from pandas.io.json import json_normalize\n", "import json\n", "\n", "local_file_path = '../files/arbres_remarquables_paris.json'\n", "with open(local_file_path, 'r') as json_file:\n", " data_json = json.load(json_file)\n", "\n", "df = pandas.DataFrame(json_normalize(data_json['records']))\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
geometry_coordinateslonlat
0[2.2417737512, 48.8630096006]2.24177448.863010
1[2.24886478886, 48.8731110898]2.24886548.873111
2[2.35366916319, 48.8448875264]2.35366948.844888
3[2.30647417371, 48.8787029872]2.30647448.878703
4[2.25294211329, 48.8671184424]2.25294248.867118
............
177[2.38368012582, 48.8814687366]2.38368048.881469
178[2.35069308175, 48.8330296265]2.35069348.833030
179[2.32633191622, 48.8940926568]2.32633248.894093
180[2.43334109188, 48.8395251386]2.43334148.839525
181[2.33940394029, 48.857749011]2.33940448.857749
\n", "

182 rows × 3 columns

\n", "
" ], "text/plain": [ " geometry_coordinates lon lat\n", "0 [2.2417737512, 48.8630096006] 2.241774 48.863010\n", "1 [2.24886478886, 48.8731110898] 2.248865 48.873111\n", "2 [2.35366916319, 48.8448875264] 2.353669 48.844888\n", "3 [2.30647417371, 48.8787029872] 2.306474 48.878703\n", "4 [2.25294211329, 48.8671184424] 2.252942 48.867118\n", ".. ... ... ...\n", "177 [2.38368012582, 48.8814687366] 2.383680 48.881469\n", "178 [2.35069308175, 48.8330296265] 2.350693 48.833030\n", "179 [2.32633191622, 48.8940926568] 2.326332 48.894093\n", "180 [2.43334109188, 48.8395251386] 2.433341 48.839525\n", "181 [2.33940394029, 48.857749011] 2.339404 48.857749\n", "\n", "[182 rows x 3 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.columns = df.columns.str.replace(\".\", \"_\")\n", "df[['lon','lat']] = pandas.DataFrame(df['geometry_coordinates'].values.tolist(), index=df.index)\n", "df.loc[:, ['geometry_coordinates', 'lon', 'lat']]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
datasetidrecordidrecord_timestampfields_geom_x_yfields_libellefrancaisfields_objectidfields_idemplacementfields_arrondissementfields_circonferenceencmfields_hauteurenm...fields_genrefields_complementadressefields_typeemplacementfields_dateplantationgeometry_typegeometry_coordinatesfields_varieteoucultivarlonlatgeometry
0arbresremarquablesparisa236960f295288698ca57fdccfd9825547ffb4d02019-10-04T10:00:41.063000+00:00[48.8630096006, 2.2417737512]Pin49884000901001BOIS DE BOULOGNE241.030.0...Pinus16-08Arbre1882-01-01T00:09:21+00:00Point[2.2417737512, 48.8630096006]NaN2.24177448.863010POINT (2.24177 48.86301)
1arbresremarquablesparisd7635937c3636051c99963676d3a97dd4d9dd8c92019-10-04T10:00:41.063000+00:00[48.8731110898, 2.24886478886]Hêtre52761000701004BOIS DE BOULOGNE231.016.0...Fagus16-17Arbre1868-01-01T00:09:21+00:00Point[2.24886478886, 48.8731110898]''Pendula''2.24886548.873111POINT (2.24886 48.87311)
2arbresremarquablesparis460e8eccd3ebc816f16317702223bf406e7d75e62019-10-04T10:00:41.063000+00:00[48.8448875264, 2.35366916319]Hêtre6245600000075PARIS 5E ARRDT85.03.0...FagusNaNArbre1905-01-01T00:09:21+00:00Point[2.35366916319, 48.8448875264]''Tortuosa''2.35366948.844888POINT (2.35367 48.84489)
3arbresremarquablesparisb60b80e0f8327afba6d0c513b0b6b85639e516b62019-10-04T10:00:41.063000+00:00[48.8787029872, 2.30647417371]Erable6880100NO0144PARIS 8E ARRDT450.028.0...Acer08-01Arbre1700-01-01T00:09:21+00:00Point[2.30647417371, 48.8787029872]NaN2.30647448.878703POINT (2.30647 48.87870)
4arbresremarquablesparis47e163d6f0536bc9e26ba2993447c6f50b14a6f62019-10-04T10:00:41.063000+00:00[48.8671184424, 2.25294211329]Platane82341001201001BOIS DE BOULOGNE534.045.0...Platanus16-10Arbre1872-01-01T00:09:21+00:00Point[2.25294211329, 48.8671184424]NaN2.25294248.867118POINT (2.25294 48.86712)
\n", "

5 rows × 27 columns

\n", "
" ], "text/plain": [ " datasetid recordid \\\n", "0 arbresremarquablesparis a236960f295288698ca57fdccfd9825547ffb4d0 \n", "1 arbresremarquablesparis d7635937c3636051c99963676d3a97dd4d9dd8c9 \n", "2 arbresremarquablesparis 460e8eccd3ebc816f16317702223bf406e7d75e6 \n", "3 arbresremarquablesparis b60b80e0f8327afba6d0c513b0b6b85639e516b6 \n", "4 arbresremarquablesparis 47e163d6f0536bc9e26ba2993447c6f50b14a6f6 \n", "\n", " record_timestamp fields_geom_x_y \\\n", "0 2019-10-04T10:00:41.063000+00:00 [48.8630096006, 2.2417737512] \n", "1 2019-10-04T10:00:41.063000+00:00 [48.8731110898, 2.24886478886] \n", "2 2019-10-04T10:00:41.063000+00:00 [48.8448875264, 2.35366916319] \n", "3 2019-10-04T10:00:41.063000+00:00 [48.8787029872, 2.30647417371] \n", "4 2019-10-04T10:00:41.063000+00:00 [48.8671184424, 2.25294211329] \n", "\n", " fields_libellefrancais fields_objectid fields_idemplacement \\\n", "0 Pin 49884 000901001 \n", "1 Hêtre 52761 000701004 \n", "2 Hêtre 62456 00000075 \n", "3 Erable 68801 00NO0144 \n", "4 Platane 82341 001201001 \n", "\n", " fields_arrondissement fields_circonferenceencm fields_hauteurenm ... \\\n", "0 BOIS DE BOULOGNE 241.0 30.0 ... \n", "1 BOIS DE BOULOGNE 231.0 16.0 ... \n", "2 PARIS 5E ARRDT 85.0 3.0 ... \n", "3 PARIS 8E ARRDT 450.0 28.0 ... \n", "4 BOIS DE BOULOGNE 534.0 45.0 ... \n", "\n", " fields_genre fields_complementadresse fields_typeemplacement \\\n", "0 Pinus 16-08 Arbre \n", "1 Fagus 16-17 Arbre \n", "2 Fagus NaN Arbre \n", "3 Acer 08-01 Arbre \n", "4 Platanus 16-10 Arbre \n", "\n", " fields_dateplantation geometry_type geometry_coordinates \\\n", "0 1882-01-01T00:09:21+00:00 Point [2.2417737512, 48.8630096006] \n", "1 1868-01-01T00:09:21+00:00 Point [2.24886478886, 48.8731110898] \n", "2 1905-01-01T00:09:21+00:00 Point [2.35366916319, 48.8448875264] \n", "3 1700-01-01T00:09:21+00:00 Point [2.30647417371, 48.8787029872] \n", "4 1872-01-01T00:09:21+00:00 Point [2.25294211329, 48.8671184424] \n", "\n", " fields_varieteoucultivar lon lat geometry \n", "0 NaN 2.241774 48.863010 POINT (2.24177 48.86301) \n", "1 ''Pendula'' 2.248865 48.873111 POINT (2.24886 48.87311) \n", "2 ''Tortuosa'' 2.353669 48.844888 POINT (2.35367 48.84489) \n", "3 NaN 2.306474 48.878703 POINT (2.30647 48.87870) \n", "4 NaN 2.252942 48.867118 POINT (2.25294 48.86712) \n", "\n", "[5 rows x 27 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from geopandas import GeoDataFrame, points_from_xy\n", "\n", "gdf = GeoDataFrame(df, geometry=points_from_xy(df['lon'], df['lat']))\n", "gdf.head()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " None\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " Static map image\n", " \n", " \n", "
\n", "
\n", "
\n", " \n", " \n", "
\n", "
\n", "
\n", "\n", " \n", "\n", "
\n", "
\n", " :\n", "
\n", " \n", " \n", "
\n", "
\n", "\n", "
\n", " StackTrace\n", "
    \n", "
    \n", "
    \n", "\n", "\n", "\n", "\n", "\n", "\">\n", "\n", "" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cartoframes.viz import Layer\n", "\n", "Layer(gdf)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
    \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
    plantation_dateplantation_year
    01882-01-01 00:09:21+00:001882
    11868-01-01 00:09:21+00:001868
    21905-01-01 00:09:21+00:001905
    31700-01-01 00:09:21+00:001700
    41872-01-01 00:09:21+00:001872
    .........
    1771700-01-01 00:09:21+00:001700
    1781894-01-01 00:09:21+00:001894
    1791700-01-01 00:09:21+00:001700
    1801918-01-01 00:00:00+00:001918
    1811700-01-01 00:09:21+00:001700
    \n", "

    181 rows × 2 columns

    \n", "
    " ], "text/plain": [ " plantation_date plantation_year\n", "0 1882-01-01 00:09:21+00:00 1882\n", "1 1868-01-01 00:09:21+00:00 1868\n", "2 1905-01-01 00:09:21+00:00 1905\n", "3 1700-01-01 00:09:21+00:00 1700\n", "4 1872-01-01 00:09:21+00:00 1872\n", ".. ... ...\n", "177 1700-01-01 00:09:21+00:00 1700\n", "178 1894-01-01 00:09:21+00:00 1894\n", "179 1700-01-01 00:09:21+00:00 1700\n", "180 1918-01-01 00:00:00+00:00 1918\n", "181 1700-01-01 00:09:21+00:00 1700\n", "\n", "[181 rows x 2 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gdf['plantation_date'] = pandas.to_datetime(gdf['fields_dateplantation'], errors='coerce')\n", "gdf = gdf[gdf['plantation_date'].notnull()]\n", "gdf['plantation_year'] = pandas.to_numeric(gdf['plantation_date'].dt.strftime('%Y'))\n", "\n", "gdf.loc[:, ['plantation_date', 'plantation_year']]" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " None\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " Static map image\n", " \n", " \n", "
    \n", "
    \n", "
    \n", " \n", " \n", "
    \n", "
    \n", " \n", "\n", "
    \n", " \n", " \n", " \n", " \n", " \n", "
    \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
    \n", " \n", " \n", "
    \n", "
    \n", "
    \n", "
    \n", " \n", "
    \n", "
    \n", "
    \n", "\n", " \n", "\n", "
    \n", "
    \n", " :\n", "
    \n", " \n", " \n", "
    \n", "
    \n", "\n", "
    \n", " StackTrace\n", "
      \n", "
      \n", "
      \n", "\n", "\n", "\n", "\n", "\n", "\">\n", "\n", "" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cartoframes.viz import Layer, color_bins_style\n", "\n", "Layer(gdf, color_bins_style('plantation_year', breaks=[1700, 1800, 1900, 2000], palette='Mint'))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }