Automotive industry sites

[1]:
import geopandas
import pandas as pd
import numpy as np
import pyproj
from shapely.ops import transform

#%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib, descartes
import matplotlib.cm as cm
from matplotlib.offsetbox import AnchoredText

from pynsee import *
[2]:
# get activity list
naf5 = get_activity_list('NAF5')

# search data in SIRENE database
data = search_sirene(variable = "activitePrincipaleEtablissement",
                   pattern = '29.10Z', kind = 'siret', number=2000)
This function may return personal data, please check and comply with the legal framework relating to personal data protection !
[3]:
data.to_csv('sirene.csv')
[4]:
data.head()
[4]:
siren nic siret dateDebut dateCreationEtablissement dateCreationUniteLegale dateFin denominationUniteLegale nomUniteLegale prenomUsuelUniteLegale ... changementEnseigneEtablissement denominationUsuelleEtablissement changementDenominationUsuelleEtablissement nomenclatureActivitePrincipaleEtablissement changementActivitePrincipaleEtablissement caractereEmployeurEtablissement changementCaractereEmployeurEtablissement libelleCommuneEtranger2Etablissement codePaysEtranger2Etablissement libellePaysEtranger2Etablissement
0 006580195 00011 00658019500011 2008-01-01 1965-01-01 1965-01-01 None SOCIETE INDUSTRIELLE POUR LE DEVELOPPEMENT DE ... None None ... False None False NAFRev2 True O False None None None
1 085520195 00109 08552019500109 2022-09-01 2022-06-30 1955-01-01 None SAFRA None None ... False None False NAFRev2 True O False None None None
2 301692307 00020 30169230700020 2020-12-31 2014-08-15 1965-01-01 None GARAGE BEYRIS None None ... False None False NAFRev2 True N False None None None
3 302099890 00014 30209989000014 2023-10-31 1975-01-01 1975-01-01 None None IPERTI JEAN ... False None False NAFRev2 False N True None None None
4 302279229 00025 30227922900025 2014-07-25 1900-01-01 1975-01-01 None RAPIDO None None ... False RAPIDO-ESTEREL-ITINEO-CAMPEREVE-DREAMER True NAFRev2 False O False None None None

5 rows × 91 columns

[5]:
# keep only businesses with more then 100 employees
df = data.loc[data['effectifsMinEtablissement'] > 100]
df = df.reset_index(drop=True)
# find latitude and longitude of all businesses
df = df.get_location()
Getting location:   0%|          | 0/51 [00:00<?, ?it/s]For at least one point, exact location has not been found, city location has been given instead
Getting location: 100%|██████████| 51/51 [00:00<00:00, 241.51it/s]
[6]:
# make geodataframe
gdf = geopandas.GeoDataFrame(df)
gdf = gdf.reset_index(drop=True)
gdf = gdf.sort_values(by=['effectifsMinEtablissement'], ascending=False)
[7]:
# get map - departement limits
geodataList =  get_geodata_list()
mapdep = get_geodata('ADMINEXPRESS-COG-CARTO.LATEST:departement', update=True)
mapdep = mapdep.translate()

# conversion to geopandas df
mapdepgeo = geopandas.GeoDataFrame(mapdep)
mapdepgeo.head()
[7]:
id nom_m nom insee_dep insee_reg geometry crsCoord
0 DEPARTEM_GLP_00000000001 GUADELOUPE Guadeloupe 971 01 MULTIPOLYGON (((-739144.768 6296095.811, -7391... EPSG:3857
1 DEPARTEM_MTQ_00000000001 MARTINIQUE Martinique 972 02 MULTIPOLYGON (((-756752.387 6056818.795, -7567... EPSG:3857
2 DEPARTEM_REU_00000000001 LA REUNION La Réunion 974 04 MULTIPOLYGON (((-807376.954 5867965.281, -8072... EPSG:3857
3 DEPARTEM_GUF_00000000001 GUYANE Guyane 973 03 MULTIPOLYGON (((-650783.613 5681770.336, -6507... EPSG:3857
4 DEPARTEM_MYT_00000000001 MAYOTTE Mayotte 976 06 MULTIPOLYGON (((-553726.624 5453062.725, -5537... EPSG:3857
[8]:
# make cleaned labels
match_list = ['RENAULT SAS', 'ALPINE', 'BATILLY', 'MAUBEUGE CONSTRUCTION',
              'TOYOTA', 'STELLANTIS AUTO SAS', 'RENAULT TRUCKS']
other_string_list = '|'.join(['[^' + x + ']' for x in match_list])

conditions = [gdf['denominationUniteLegale'].str.contains(x) for x in match_list]
conditions += [gdf['denominationUniteLegale'].str.contains(other_string_list)]

values = ['RENAULT SAS', 'RENAULT SAS', 'RENAULT SAS', 'RENAULT SAS',
          'TOYOTA', 'STELLANTIS AUTO SAS', 'RENAULT TRUCKS', 'OTHER']

gdf['label'] = np.select(conditions, values)
[9]:
def _convert_polygon(geo, crs_in='EPSG:4326', crs_out='EPSG:3857'):

    if geo is not None:
        crsIn = pyproj.CRS(crs_in)
        crsOut = pyproj.CRS(crs_out)

        project = pyproj.Transformer.from_crs(crsIn, crsOut, always_xy=True).transform
        geo_converted = transform(project, geo)

        return geo_converted

# convert openstreetmap data from crs 4326 to crs 3857
gdf['geometry'] = gdf['geometry'].apply(lambda x: _convert_polygon(x))

gdf["crs"] = 'EPSG:3857'
[10]:
# annotation
txt = 'Circles are proportionate to the minimum of the employee number range'
txt += '\nIf headcount is missing in SIRENE database, some factories may not be displayed'

#plot
ax = mapdepgeo.plot(color='white', edgecolor='black', figsize = (15,7))
plt.title('Automotive industry sites in France')
gdf.plot(ax=ax,
         column = 'label',
         edgecolor='white',
         markersize=gdf.effectifsMinEtablissement/5,
         legend=True,
         legend_kwds={'bbox_to_anchor': (1.1,1),
                       'loc':1, 'borderaxespad': 0})

at = AnchoredText(txt, prop=dict(size=9), frameon=True, loc='lower left')
ax.add_artist(at)
ax.set_axis_off()
plt.show()
../_images/examples_example_automotive_industry_sirene_10_0.png
[11]:
gdf.rename(columns={'siren' : 'SIREN'})
[11]:
SIREN nic siret dateDebut dateCreationEtablissement dateCreationUniteLegale dateFin denominationUniteLegale nomUniteLegale prenomUsuelUniteLegale ... latitude longitude category crsCoord type importance exact_location geometry label crs
14 542065479 00140 54206547900140 2008-01-01 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... 47.513309 6.835445 highway EPSG:4326 primary 0.100010 True POINT (760918.234 6026265.337) STELLANTIS AUTO SAS EPSG:3857
41 780129987 03575 78012998703575 2008-01-01 1999-01-01 1900-01-01 None RENAULT SAS None None ... 48.755422 2.075766 highway EPSG:4326 tertiary 0.100010 True POINT (231073.170 6233463.094) RENAULT SAS EPSG:3857
15 542065479 00181 54206547900181 2008-01-01 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... 48.043241 -1.708237 boundary EPSG:4326 administrative NaN False POINT (-190160.062 6114051.547) STELLANTIS AUTO SAS EPSG:3857
17 542065479 00272 54206547900272 2008-01-01 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... 47.775299 7.405166 highway EPSG:4326 service 0.075010 True POINT (824339.342 6069553.658) STELLANTIS AUTO SAS EPSG:3857
16 542065479 00215 54206547900215 2008-01-01 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... 48.780950 2.190005 boundary EPSG:4326 administrative NaN False POINT (243790.264 6237774.529) STELLANTIS AUTO SAS EPSG:3857
38 780129987 01892 78012998701892 2008-01-01 1900-01-01 1900-01-01 None RENAULT SAS None None ... 48.977517 1.846397 highway EPSG:4326 unclassified 0.100010 True POINT (205539.974 6271047.445) RENAULT SAS EPSG:3857
37 780129987 01124 78012998701124 2008-01-01 1900-01-01 1900-01-01 None RENAULT SAS None None ... 50.382149 3.045206 boundary EPSG:4326 administrative NaN False POINT (338990.759 6512722.277) RENAULT SAS EPSG:3857
22 542065479 00686 54206547900686 2008-02-03 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... NaN NaN None EPSG:4326 None NaN False None STELLANTIS AUTO SAS EPSG:3857
25 542065479 00926 54206547900926 2008-01-01 2002-06-03 1954-01-01 None STELLANTIS AUTO SAS None None ... 48.933776 2.043911 place EPSG:4326 house 0.000010 True POINT (227527.132 6263632.028) STELLANTIS AUTO SAS EPSG:3857
20 542065479 00322 54206547900322 2008-01-01 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... 48.935383 2.044069 highway EPSG:4326 tertiary 0.100010 True POINT (227544.776 6263904.413) STELLANTIS AUTO SAS EPSG:3857
46 954506077 00120 95450607700120 2008-01-01 1989-12-20 1954-01-01 None RENAULT TRUCKS None None ... 45.704714 4.912001 place EPSG:4326 house 0.000010 True POINT (546801.506 5733155.045) RENAULT TRUCKS EPSG:3857
34 780129987 00902 78012998700902 2008-01-01 1900-01-01 1900-01-01 None RENAULT SAS None None ... 49.306455 1.027005 highway EPSG:4326 primary 0.100010 True POINT (114325.629 6327021.295) RENAULT SAS EPSG:3857
36 780129987 01074 78012998701074 2008-01-01 1900-01-01 1900-01-01 None RENAULT SAS None None ... 47.980863 0.178888 place EPSG:4326 house 0.000010 True POINT (19913.721 6103671.627) RENAULT SAS EPSG:3857
11 420559056 00031 42055905600031 2008-01-01 2000-06-26 1998-10-15 None TOYOTA MOTOR MANUFACTURING FRANCE None None ... 50.367220 3.616621 building EPSG:4326 manufacture 0.342718 True POINT (402600.379 6510116.430) TOYOTA EPSG:3857
10 419683818 00035 41968381800035 2008-01-01 1998-12-31 1998-07-23 None IVECO FRANCE None None ... 45.256690 4.670032 highway EPSG:4326 primary 0.100010 True POINT (519865.640 5662023.081) OTHER EPSG:3857
18 542065479 00280 54206547900280 2008-01-01 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... 47.616028 6.148136 place EPSG:4326 house 0.000010 True POINT (684407.369 6043211.651) STELLANTIS AUTO SAS EPSG:3857
5 350693586 00025 35069358600025 2008-01-01 2006-01-01 1989-04-01 None FPT POWERTRAIN TECHNOLOGIES FRANCE None None ... 46.623706 3.759588 highway EPSG:4326 primary 0.100010 True POINT (418515.411 5880868.090) OTHER EPSG:3857
42 780129987 03591 78012998703591 2008-01-01 2000-01-01 1900-01-01 None RENAULT SAS None None ... 48.831055 2.228058 place EPSG:4326 house 0.000010 True POINT (248026.293 6246243.430) RENAULT SAS EPSG:3857
4 319851408 00017 31985140800017 2008-01-01 1980-07-01 1980-07-01 None SOCIETE VEHICULES AUTOMOBILES BATILLY None None ... 49.172809 5.981256 landuse EPSG:4326 industrial 0.200010 True POINT (665830.397 6304234.445) RENAULT SAS EPSG:3857
49 954506077 00559 95450607700559 2008-01-01 1900-01-01 1954-01-01 None RENAULT TRUCKS None None ... 49.228321 -0.300348 boundary EPSG:4326 administrative 0.558446 True POINT (-33434.586 6313691.847) RENAULT TRUCKS EPSG:3857
21 542065479 00678 54206547900678 2008-01-01 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... 49.107515 6.226184 highway EPSG:4326 secondary 0.100010 True POINT (693095.610 6293124.186) STELLANTIS AUTO SAS EPSG:3857
35 780129987 01033 78012998701033 2008-01-01 1900-01-01 1900-01-01 None RENAULT SAS None None ... 49.496622 0.316745 boundary EPSG:4326 administrative NaN False POINT (35259.881 6359551.716) RENAULT SAS EPSG:3857
43 780129987 03708 78012998703708 2009-01-25 1979-06-01 1900-01-01 None RENAULT SAS None None ... 48.777321 2.241314 place EPSG:4326 house 0.000010 True POINT (249501.955 6237161.478) RENAULT SAS EPSG:3857
26 542065479 01353 54206547901353 2015-11-24 2015-11-24 1954-01-01 None STELLANTIS AUTO SAS None None ... 50.272914 3.346119 boundary EPSG:4326 administrative NaN False POINT (372488.230 6493674.595) STELLANTIS AUTO SAS EPSG:3857
50 954506077 01276 95450607701276 2019-06-01 2019-06-01 1954-01-01 None RENAULT TRUCKS None None ... 45.697711 4.885597 boundary EPSG:4326 administrative NaN False POINT (543862.126 5732038.806) RENAULT TRUCKS EPSG:3857
48 954506077 00377 95450607700377 2008-01-01 1900-01-01 1954-01-01 None RENAULT TRUCKS None None ... 46.199456 5.257274 place EPSG:4326 house 0.000010 True POINT (585237.054 5812369.999) RENAULT TRUCKS EPSG:3857
28 662018068 00046 66201806800046 2008-01-01 1995-11-30 1900-01-01 None DAIMLER BUSES FRANCE SASU None None ... 48.676240 5.325910 highway EPSG:4326 unclassified 0.100010 True POINT (592877.556 6220103.619) OTHER EPSG:3857
6 378442982 00021 37844298200021 2008-01-01 1991-11-08 1990-06-18 None SCANIA PRODUCTION ANGERS SAS None None ... 47.501605 -0.518263 highway EPSG:4326 tertiary 0.100010 True POINT (-57692.784 6024336.618) OTHER EPSG:3857
13 458502838 00071 45850283800071 2009-10-01 1989-12-21 1981-06-29 None TRIGANO VDL None None ... 45.068351 4.807905 place EPSG:4326 house 0.000010 True POINT (535213.559 5632288.331) OTHER EPSG:3857
23 542065479 00694 54206547900694 2020-04-09 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... 48.939765 2.036948 highway EPSG:4326 secondary 0.100010 True POINT (226752.025 6264646.982) STELLANTIS AUTO SAS EPSG:3857
40 780129987 03492 78012998703492 2008-04-01 1992-01-01 1900-01-01 None RENAULT SAS None None ... 48.817237 1.877881 place EPSG:4326 house 0.000010 True POINT (209044.757 6243907.043) RENAULT SAS EPSG:3857
39 780129987 02833 78012998702833 2008-01-01 1981-06-15 1900-01-01 None RENAULT SAS None None ... 49.025762 2.110295 highway EPSG:4326 tertiary 0.100010 True POINT (234916.976 6279233.831) RENAULT SAS EPSG:3857
47 954506077 00146 95450607700146 2019-06-01 1900-01-01 1954-01-01 None RENAULT TRUCKS None None ... 45.712890 4.898514 place EPSG:4326 house 0.000010 True POINT (545300.073 5734458.460) RENAULT TRUCKS EPSG:3857
8 403119431 00027 40311943100027 2022-07-08 1997-10-27 1995-11-28 None INEOS AUTOMOTIVE SAS None None ... 49.050646 7.042009 landuse EPSG:4326 industrial 0.200010 True POINT (783912.802 6283459.402) OTHER EPSG:3857
3 316696996 00032 31669699600032 2008-01-01 1980-12-01 1979-01-01 None HEULIEZ BUS None None ... 46.906202 -0.683591 place EPSG:4326 isolated_dwelling 0.200010 True POINT (-76097.035 5926777.317) OTHER EPSG:3857
45 872802780 00033 87280278000033 2010-01-25 2010-01-25 1972-01-01 None G P SAS None None ... 47.554676 -0.660882 highway EPSG:4326 bus_stop 0.000010 True POINT (-73569.070 6033086.047) OTHER EPSG:3857
29 662043405 00080 66204340500080 2018-07-05 2007-05-14 1900-01-01 None ARQUUS None None ... 48.784166 2.096185 place EPSG:4326 house 0.000010 True POINT (233346.247 6238317.950) OTHER EPSG:3857
44 872802780 00025 87280278000025 2008-01-01 1982-10-01 1972-01-01 None G P SAS None None ... 46.993490 -1.597054 boundary EPSG:4326 administrative NaN False POINT (-177783.249 5941011.507) OTHER EPSG:3857
9 419683818 00027 41968381800027 2008-01-01 1998-12-31 1998-07-23 None IVECO FRANCE None None ... 45.697711 4.885597 boundary EPSG:4326 administrative NaN False POINT (543862.126 5732038.806) OTHER EPSG:3857
2 306140807 00042 30614080700042 2022-12-31 1900-01-01 1900-01-01 None ALPINE RACING None None ... 48.661485 2.371756 place EPSG:4326 house 0.000010 True POINT (264022.626 6217616.532) RENAULT SAS EPSG:3857
1 302279229 00025 30227922900025 2014-07-25 1900-01-01 1975-01-01 None RAPIDO None None ... 48.308759 -0.642728 place EPSG:4326 house 0.000010 True POINT (-71548.143 6158375.910) OTHER EPSG:3857
19 542065479 00306 54206547900306 2008-01-01 1998-12-31 1954-01-01 None STELLANTIS AUTO SAS None None ... 47.644878 6.932566 boundary EPSG:4326 administrative 0.450608 True POINT (771729.672 6047977.176) STELLANTIS AUTO SAS EPSG:3857
32 662750074 00012 66275007400012 2022-01-28 1966-01-01 1966-01-01 None MANUFACTURE ALPINE DIEPPE JEAN REDELE None None ... 49.911038 1.084502 highway EPSG:4326 primary 0.100010 True POINT (120726.222 6430883.507) RENAULT SAS EPSG:3857
12 441480167 00010 44148016700010 2020-12-31 2002-04-02 2002-04-02 None ALPINE CARS None None ... 48.683573 2.202232 building EPSG:4326 office 0.000010 True POINT (245151.374 6221339.908) RENAULT SAS EPSG:3857
7 383039880 00018 38303988000018 2010-05-16 1991-09-13 1991-09-13 None PERIGORD VEHICULES DE LOISIRS SAS None None ... 45.378540 0.642806 highway EPSG:4326 primary 0.100010 True POINT (71556.848 5681312.999) OTHER EPSG:3857
0 006580195 00011 00658019500011 2008-01-01 1965-01-01 1965-01-01 None SOCIETE INDUSTRIELLE POUR LE DEVELOPPEMENT DE ... None None ... 47.292516 -2.194142 highway EPSG:4326 residential 0.100010 True POINT (-244250.759 5989951.567) OTHER EPSG:3857
33 712000272 00021 71200027200021 2014-07-01 2003-04-01 1985-12-19 None LIGIER GROUP None None ... 46.101692 3.428265 highway EPSG:4326 secondary 0.100010 True POINT (381632.725 5796660.485) OTHER EPSG:3857
24 542065479 00835 54206547900835 2017-04-28 2000-10-01 1954-01-01 None STELLANTIS AUTO SAS None None ... 48.785333 2.095085 place EPSG:4326 house 0.000010 True POINT (233223.773 6238515.115) STELLANTIS AUTO SAS EPSG:3857
31 662043405 00189 66204340500189 2015-12-01 2015-12-01 1900-01-01 None ARQUUS None None ... 48.786568 2.057307 place EPSG:4326 house 0.000010 True POINT (229018.368 6238723.740) OTHER EPSG:3857
27 662018068 00038 66201806800038 2021-01-15 1900-01-01 1900-01-01 None DAIMLER BUSES FRANCE SASU None None ... 48.987293 2.388507 highway EPSG:4326 unclassified 0.100010 True POINT (265887.350 6272705.608) OTHER EPSG:3857
30 662043405 00106 66204340500106 2011-06-01 2011-06-01 1900-01-01 None ARQUUS None None ... 47.051964 3.064556 highway EPSG:4326 tertiary 0.100010 True POINT (341144.791 5950560.032) OTHER EPSG:3857

51 rows × 101 columns