1

I have two Spatial Dataframe, the first one is the Paris Polling Stations from 2012, the other is the Polling Stations from 2017.

enter image description here

enter image description here

They almost have the same geography, it deffers for 20 polygons (2017 is more precies).

I would like to join them to obtain the "ID" column from 2012 in my data of 2017.

  • 2012
|                 | shape_leng         | shape_area    | ID        | geometry                     |                  |                  |                  |                  |                  |                  |                  |                  |                  |                  |
|-----------------|--------------------|---------------|-----------|------------------------------|------------------|------------------|------------------|------------------|------------------|------------------|------------------|------------------|------------------|------------------|
| 0               | 1268.93753701      | 61237.9735217 | 750060019 | list(list(c(650797.001122712 | 650901.22286339  | 650941.890428709 | 650936.081391855 | 651049.837827644 | 650989.843695742 | 650889.594294603 | 650738.750779362 | 650822.301455742 | 650825.312860794 | 650843.676612505 |
| 1               | 1401.95550187      | 88844.1877442 | 750060018 | list(list(c(650384.503148619 | 650511.307822879 | 650594.125993547 | 650614.961655171 | 650633.224074336 | 650745.583897904 | 650824.501386092 | 650821.694091766 | 650723.680506596 | 650576.013883853 | 650384.503148619 |
| 2               | 1484.61459417      | 105023.483141 | 750060003 | list(list(c(651476.287599881 | 651490.173923358 | 651545.42360236  | 651584.388002084 | 651651.296912767 | 651664.569855901 | 651759.199951992 | 651645.301788193 | 651609.299857791 | 651495.968098826 | 651493.37889212  |
| 6861536.5085517 | 6861580.6919048))) |               |           |                              |                  |                  |                  |                  |                  |                  |                  |                  |                  |                  |
| 3               | 1326.53694371      | 82224.2952129 | 750030011 | list(list(c(652712.879253193 | 652848.154625535 | 652908.587502407 | 652917.472384924 | 652954.738685714 | 653027.346780394 | 652915.837940049 | 652814.777949022 | 652570.089834746 | 652664.020246    | 652648.231791037 |
  • 2017
| OBJECTID | Nombre d’électeurs Français à cette adresse | Nombre d’électeurs européens pour les élections Municipales | Nombre d’électeurs européens pour les élections Européennes | Nombre d’électeurs à l’étranger | Validité | N° arrondissement | N° Bureau de vote | Identifiant du bureau de vote | SHAPE.AREA | SHAPE.LEN | geo_shape                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | geo_point_2d                 |
|----------|---------------------------------------------|-------------------------------------------------------------|-------------------------------------------------------------|---------------------------------|----------|-------------------|-------------------|-------------------------------|------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| 4        | 1267                                        | 14                                                          | 12                                                          | 0                               | oui      | 19                | 5                 | 19-5                          | 0.0        | 0.0       | {"type": "Polygon", "coordinates": [[[2.377124723311967, 48.880979291570846], [2.380297535533454, 48.88244083070407], [2.38146960629144, 48.88237974450333], [2.38146187973089, 48.88230648524515], [2.381494998459322, 48.88225825604293], [2.381659484454157, 48.882024924629825], [2.384186317888687, 48.87929911341413], [2.383718960900722, 48.87922604604269], [2.382473760954909, 48.87881477166197], [2.378478916733161, 48.878874415516265], [2.375638199265485, 48.8785646938985], [2.375803917296529, 48.87988659888862], [2.375824597111929, 48.88007075064349], [2.375547730086135, 48.880195395181616], [2.377124723311967, 48.880979291570846]]]}                                                                                                                                                                                                                                                                                                                                     | 48.8802264731, 2.37974843372 |
| 5        | 1331                                        | 6                                                           | 6                                                           | 0                               | oui      | 19                | 7                 | 19-7                          | 0.0        | 0.0       | {"type": "Polygon", "coordinates": [[[2.373847565324231, 48.88095478040867], [2.374267654795006, 48.88005272996709], [2.374333199504391, 48.87928756992368], [2.374158133038848, 48.878276693670216], [2.373517946266483, 48.878199596010234], [2.371360339623079, 48.879031818752665], [2.372773108997126, 48.88053184558171], [2.37286882907592, 48.88080425834157], [2.373234657786588, 48.8812404199206], [2.373847565324231, 48.88095478040867]]]}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | 48.8795423601, 2.37317680813 |
| 9        | 1454                                        | 23                                                          | 20                                                          | 0                               | oui      | 19                | 14                | 19-14                         | 0.0        | 0.0       | {"type": "Polygon", "coordinates": [[[2.376465188926868, 48.87339019295189], [2.377038598765818, 48.87378260121745], [2.376912177903809, 48.8740154762881], [2.377819342052652, 48.874164417754706], [2.3793465105744582, 48.87460931999016], [2.3794582031907, 48.87469753522808], [2.379846932420001, 48.87469738827229], [2.3799519980073303, 48.87412130239483], [2.379264690509619, 48.87400623788858], [2.379296246459345, 48.87386757193071], [2.379995974060414, 48.87389769736935], [2.380054021433946, 48.87351795844673], [2.382745569407017, 48.87361171088856], [2.382892291772651, 48.873472997256314], [2.381738186670566, 48.873273580386964], [2.379834334919815, 48.87286436675126], [2.377012576671528, 48.87208649320894], [2.376208366933412, 48.872834925526654], [2.376465188926868, 48.87339019295189]]]}                                                                                                                                                                    | 48.8733532181, 2.37865317187 |
| 10       | 1400                                        | 29                                                          | 25                                                          | 0                               | oui      | 19                | 10                | 19-10                         | 0.0        | 0.0       | {"type": "Polygon", "coordinates": [[[2.376959371594972, 48.876556575307546], [2.375289685661747, 48.87676376969479], [2.375575260990789, 48.87752954376368], [2.377393482685724, 48.87748230196962], [2.377989705174618, 48.87789842320518], [2.377907111538225, 48.87839646274977], [2.3781514551644802, 48.87882534793349], [2.3784596001621, 48.87884422824465], [2.380313729527356, 48.87882557876527], [2.381342771332414, 48.876256191710006], [2.381380156461589, 48.87620109528777], [2.381851852339082, 48.87558741271441], [2.381699256083672, 48.87553728370656], [2.381155228810861, 48.87583840417846], [2.380222426849499, 48.876049591724026], [2.379765950390622, 48.87522053058002], [2.379834497632896, 48.874702005305565], [2.379458500288481, 48.87470614743706], [2.379349260558314, 48.87461418220238], [2.378814943364098, 48.87445807123801], [2.378007264659168, 48.876347446810264], [2.376850024803491, 48.876348801769126], [2.376959371594972, 48.876556575307546]]]} | 48.8769383898, 2.37892124633 |
| 12       | 1495                                        | 21                                                          | 22                                                          | 0                               | oui      | 19                | 13                | 19-13                         | 0.0        | 0.0       | {"type": "Polygon", "coordinates": [[[2.385328872659599, 48.87409307436462], [2.382077267812372, 48.875672361813116], [2.381969247938524, 48.87572913780974], [2.381860167826533, 48.87559153491787], [2.381351063622792, 48.87625073289971], [2.381113356158437, 48.876837953982125], [2.380733759286433, 48.87778700812908], [2.38124712086053, 48.87773564745521], [2.381756329377825, 48.877173898452966], [2.382886740252304, 48.87681968729412], [2.384522123393002, 48.87657779103386], [2.385677456233416, 48.87426766668776], [2.385328872659599, 48.87409307436462]]]}                                                                                                                                                                                                                                                                                                                                                                                                                     | 48.8759164135, 2.38329252628 |

As you can see they have no column in common to join them, but with mapview we see they have basically the same geography.

So 2012 was an rda file, I made it as an sf. 2017 was a shp file and I made it as an sf (I also have a Geojson, I don't know which one would be better, I don't think it changes much here)

I tried to merge them by the polygons with test1 = aggregate(rbind(new_bureaux_shp,ParisPollingStations2012)) even if I'm not sure it will do what I want. (I want to get the old one more precies by cuting them with the new one) I always get the same error :

Erreur : arguments have different crs

So I tried to set the same CRS for the two, I use st_transform(new_bureaux_shp, 4326)and st_transform(ParisPollingStations2012, 4326) but I keep the same error.

I think this will need two steps : 1) set the data to the same geometry 2) join them by the geometry

So : - How to make sur they have the same CRS ? - How could I set my 2012 polygons as my 2017 data polygons ?

I read lots of questions about spatial polygons, but I didn't found anything that helped me.

@Spacedman asked for the data : The Polling Stations from 2012 and the Polling Stations from 2017

  • 1
    Can you point us to the shapefiles? You probably need to do some overlay operations and then fix up any slightly non-matching geometries. It might also be nice to have a focussed plot of both areas where there's a non-match - the only difference I can see are some white areas in the 2012 data and ooh there's something spiky on the western boundary... – Spacedman Apr 15 at 22:00
  • I edited the question with the data, I'm looking for the map with the changing areas ! – Svhooren Apr 16 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.