-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1575 lines (1518 loc) · 129 KB
/
index.html
File metadata and controls
1575 lines (1518 loc) · 129 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr-FR" xml:lang="fr-FR"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.5.57">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="keywords" content="semis de points, réseau spatial, analyse spatiale">
<title>Analyse de semis de points sur un réseau spatial avec R</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
/* CSS for citations */
div.csl-bib-body { }
div.csl-entry {
clear: both;
margin-bottom: 0em;
}
.hanging-indent div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}</style>
<script src="index_files/libs/clipboard/clipboard.min.js"></script>
<script src="index_files/libs/quarto-html/quarto.js"></script>
<script src="index_files/libs/quarto-html/popper.min.js"></script>
<script src="index_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="index_files/libs/quarto-html/anchor.min.js"></script>
<link href="index_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="index_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="index_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="index_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="index_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<style>
.quarto-title-block .quarto-title-banner h1,
.quarto-title-block .quarto-title-banner h2,
.quarto-title-block .quarto-title-banner h3,
.quarto-title-block .quarto-title-banner h4,
.quarto-title-block .quarto-title-banner h5,
.quarto-title-block .quarto-title-banner h6
{
color: #f0aa0c;
}
.quarto-title-block .quarto-title-banner {
color: #f0aa0c;
background: #0c3762;
}
</style>
<style>
h1 {
color: #f0aa0c;
}
</style>
<script>window.backupDefine = window.define; window.define = undefined;</script><script src="https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.js"></script>
<script>document.addEventListener("DOMContentLoaded", function () {
var mathElements = document.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains('display'),
throwOnError: false,
macros: macros,
fleqn: false
});
}}});
</script>
<script>window.define = window.backupDefine; window.backupDefine = undefined;</script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css">
<script type="text/javascript">
const typesetMath = (el) => {
if (window.MathJax) {
// MathJax Typeset
window.MathJax.typeset([el]);
} else if (window.katex) {
// KaTeX Render
var mathElements = el.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
window.katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains('display'),
throwOnError: false,
macros: macros,
fleqn: false
});
}
}
}
}
window.Quarto = {
typesetMath
};
</script>
<link rel="stylesheet" href="_extensions/rzine-reviews/rzine/styles.css">
</head>
<body>
<header id="title-block-header" class="quarto-title-block default page-columns page-full">
<div class="quarto-title-banner page-columns page-full">
<div class="quarto-title column-body">
<h1 class="title">Analyse de semis de points sur un réseau spatial avec R</h1>
<p class="subtitle lead">Commerces parisiens au début du XIXe siècle</p>
</div>
</div>
<div class="quarto-title-meta-author">
<div class="quarto-title-meta-heading">Auteur·rice·s</div>
<div class="quarto-title-meta-heading">Affiliations</div>
<div class="quarto-title-meta-contents">
<p class="author"><a href="https://esprad.hypotheses.org/cv-com-et-publis">Laurent Beauguitte</a> <a href="https://orcid.org/0000-0001-8803-6056" class="quarto-title-author-orcid"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo1N0NEMjA4MDI1MjA2ODExOTk0QzkzNTEzRjZEQTg1NyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDozM0NDOEJGNEZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozM0NDOEJGM0ZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZDN0YxMTc0MDcyMDY4MTE5NUZFRDc5MUM2MUUwNEREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjU3Q0QyMDgwMjUyMDY4MTE5OTRDOTM1MTNGNkRBODU3Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+84NovQAAAR1JREFUeNpiZEADy85ZJgCpeCB2QJM6AMQLo4yOL0AWZETSqACk1gOxAQN+cAGIA4EGPQBxmJA0nwdpjjQ8xqArmczw5tMHXAaALDgP1QMxAGqzAAPxQACqh4ER6uf5MBlkm0X4EGayMfMw/Pr7Bd2gRBZogMFBrv01hisv5jLsv9nLAPIOMnjy8RDDyYctyAbFM2EJbRQw+aAWw/LzVgx7b+cwCHKqMhjJFCBLOzAR6+lXX84xnHjYyqAo5IUizkRCwIENQQckGSDGY4TVgAPEaraQr2a4/24bSuoExcJCfAEJihXkWDj3ZAKy9EJGaEo8T0QSxkjSwORsCAuDQCD+QILmD1A9kECEZgxDaEZhICIzGcIyEyOl2RkgwAAhkmC+eAm0TAAAAABJRU5ErkJggg=="></a></p>
</div>
<div class="quarto-title-meta-contents">
<p class="affiliation">
UMR Géographie-cités
</p>
</div>
<div class="quarto-title-meta-contents">
<p class="author"><a href="https://thema.univ-fcomte.fr/page_personnelle/jgravier">Julie Gravier</a> <a href="https://orcid.org/0000-0003-0449-6499" class="quarto-title-author-orcid"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo1N0NEMjA4MDI1MjA2ODExOTk0QzkzNTEzRjZEQTg1NyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDozM0NDOEJGNEZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozM0NDOEJGM0ZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZDN0YxMTc0MDcyMDY4MTE5NUZFRDc5MUM2MUUwNEREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjU3Q0QyMDgwMjUyMDY4MTE5OTRDOTM1MTNGNkRBODU3Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+84NovQAAAR1JREFUeNpiZEADy85ZJgCpeCB2QJM6AMQLo4yOL0AWZETSqACk1gOxAQN+cAGIA4EGPQBxmJA0nwdpjjQ8xqArmczw5tMHXAaALDgP1QMxAGqzAAPxQACqh4ER6uf5MBlkm0X4EGayMfMw/Pr7Bd2gRBZogMFBrv01hisv5jLsv9nLAPIOMnjy8RDDyYctyAbFM2EJbRQw+aAWw/LzVgx7b+cwCHKqMhjJFCBLOzAR6+lXX84xnHjYyqAo5IUizkRCwIENQQckGSDGY4TVgAPEaraQr2a4/24bSuoExcJCfAEJihXkWDj3ZAKy9EJGaEo8T0QSxkjSwORsCAuDQCD+QILmD1A9kECEZgxDaEZhICIzGcIyEyOl2RkgwAAhkmC+eAm0TAAAAABJRU5ErkJggg=="></a></p>
</div>
<div class="quarto-title-meta-contents">
<p class="affiliation">
UMR ThéMA
</p>
</div>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Date de publication</div>
<div class="quarto-title-meta-contents">
<p class="date">2025-05</p>
</div>
</div>
<div>
<div class="quarto-title-meta-heading">Doi</div>
<div class="quarto-title-meta-contents">
<p class="doi">
<a href="https://doi.org/XXX">XXX</a>
</p>
</div>
</div>
</div>
<div>
<div class="abstract">
<div class="block-title">Résumé</div>
<p>L’analyse d’un semis de points sur un réseau désigne un ensemble de méthodes statistiques permettant de caractériser des événements ponctuels dans le temps et dans l’espace prenant place sur un réseau spatial planaire. Deux des sujets les plus traités dans la bibliographie sont les accidents de la circulation et les actes criminels commis dans l’espace public. Il est possible d’imaginer étudier d’autres thématiques plus ou moins ponctuelles dans le temps, qu’il s’agisse de l’offre commerciale dans un espace donné, du collage militant ou publicitaire, de la présence d’équipements dans l’espace public (bancs, toilettes), de présence de biotopes le long de cours d’eau, etc. Trois grands types de question sont généralement posés à ces données : (1) les points sont-ils significativement proches (ou éloignés) les uns des autres (étude du voisinage) ? (2) Existe-t-il des lieux où la concentration des points est notable (hot spots) ? (3) Quel modèle statistique est susceptible d’expliquer la géographie de ce semis de points ? Ces trois questions sont abordées à l’aide du package R <a href="https://cran.r-project.org/web/packages/spatstat.linnet/index.html">spatstat.linnet</a> de la famille <a href="https://cran.r-project.org/web/packages/spatstat/index.html">spatstat</a>.</p>
</div>
</div>
<div>
<div class="keywords">
<div class="block-title">Mots clés</div>
<p>semis de points, réseau spatial, analyse spatiale</p>
</div>
</div>
</header><div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table des matières</h2>
<ul>
<li><a href="#définitions-et-questions-de-recherche" id="toc-définitions-et-questions-de-recherche" class="nav-link active" data-scroll-target="#définitions-et-questions-de-recherche">Définitions et questions de recherche</a></li>
<li><a href="#le-package-linnet" id="toc-le-package-linnet" class="nav-link" data-scroll-target="#le-package-linnet">Le package linnet</a>
<ul class="collapse">
<li><a href="#préparer-ses-données" id="toc-préparer-ses-données" class="nav-link" data-scroll-target="#préparer-ses-données">Préparer ses données</a></li>
<li><a href="#créer-des-objets-linnet-et-lpp-de-a-à-z-et-visualiser-pour-comprendre-la-structure-des-objets" id="toc-créer-des-objets-linnet-et-lpp-de-a-à-z-et-visualiser-pour-comprendre-la-structure-des-objets" class="nav-link" data-scroll-target="#créer-des-objets-linnet-et-lpp-de-a-à-z-et-visualiser-pour-comprendre-la-structure-des-objets">Créer des objets <code>linnet</code> et <code>lpp</code> de A à Z et visualiser pour comprendre la structure des objets</a></li>
<li><a href="#créer-et-visualiser-des-objets-à-partir-de-données-spatiales" id="toc-créer-et-visualiser-des-objets-à-partir-de-données-spatiales" class="nav-link" data-scroll-target="#créer-et-visualiser-des-objets-à-partir-de-données-spatiales">Créer et visualiser des objets à partir de données spatiales</a></li>
</ul></li>
<li><a href="#modéliser-la-géographie-du-semis-de-points" id="toc-modéliser-la-géographie-du-semis-de-points" class="nav-link" data-scroll-target="#modéliser-la-géographie-du-semis-de-points">Modéliser la géographie du semis de points</a>
<ul class="collapse">
<li><a href="#répartitions-aléatoires-des-points-sur-un-réseau-spatial" id="toc-répartitions-aléatoires-des-points-sur-un-réseau-spatial" class="nav-link" data-scroll-target="#répartitions-aléatoires-des-points-sur-un-réseau-spatial">Répartitions aléatoires des points sur un réseau spatial</a></li>
<li><a href="#mesurer-lécart-des-distributions-observées-aux-distributions-aléatoires" id="toc-mesurer-lécart-des-distributions-observées-aux-distributions-aléatoires" class="nav-link" data-scroll-target="#mesurer-lécart-des-distributions-observées-aux-distributions-aléatoires">Mesurer l’écart des distributions observées aux distributions aléatoires</a></li>
<li><a href="#répartition-aléatoire-inhomogène" id="toc-répartition-aléatoire-inhomogène" class="nav-link" data-scroll-target="#répartition-aléatoire-inhomogène">Répartition aléatoire inhomogène</a></li>
<li><a href="#étudier-les-voisinages" id="toc-étudier-les-voisinages" class="nav-link" data-scroll-target="#étudier-les-voisinages">Étudier les voisinages</a></li>
<li><a href="#rechercher-et-analyser-des-clusters-hot-spots" id="toc-rechercher-et-analyser-des-clusters-hot-spots" class="nav-link" data-scroll-target="#rechercher-et-analyser-des-clusters-hot-spots">Rechercher et analyser des clusters (hot spots)</a></li>
</ul></li>
<li><a href="#intérêts-et-limites-du-package" id="toc-intérêts-et-limites-du-package" class="nav-link" data-scroll-target="#intérêts-et-limites-du-package">Intérêts et limites du package</a></li>
<li><a href="#pour-aller-plus-loin" id="toc-pour-aller-plus-loin" class="nav-link" data-scroll-target="#pour-aller-plus-loin">Pour aller plus loin</a></li>
<li><a href="#bibliography" id="toc-bibliography" class="nav-link" data-scroll-target="#bibliography">Bibliographie</a></li>
</ul>
</nav>
</div>
<main class="content quarto-banner-title-block" id="quarto-document-content">
<section id="définitions-et-questions-de-recherche" class="level1">
<h1>Définitions et questions de recherche</h1>
<p>L’analyse d’un semis de points sur un réseau désigne un ensemble de méthodes statistiques permettant de caractériser des événements ponctuels dans le temps et dans l’espace, appelés points dans la suite du texte, prenant place sur un réseau spatial planaire, appelé réseau ou <span class="math inline">L</span> dans la suite du texte.</p>
<p>Un réseau planaire est constitué par un ensemble de sommets et un ensemble de liens entre ces sommets. Tout sommet est soit une intersection entre deux liens, soit l’extrémité d’un lien. Chaque sommet est défini par un couple de coordonnées, chaque lien est caractérisé par une distance. Un lien peut par ailleurs être porteur d’attributs supplémentaires (largeur, intensité, etc.). En géographie, les réseaux de transport terrestres, les réseaux viaires et les réseaux hydrographiques sont généralement modélisés sous forme de graphes planaires.</p>
<p>Deux des sujets les plus traités dans la bibliographie sont les accidents de la circulation et les actes criminels commis dans l’espace public. Dans les deux cas, des événements dramatiques pouvant être caractérisés par des attributs de types différents se produisent dans un espace pouvant être modélisé sous forme de réseau planaire (réseau routier, réseau viaire). Il est possible d’imaginer d’autres thématiques plus ou moins ponctuelles dans le temps, qu’il s’agisse de l’offre commerciale dans un espace donné, du collage militant ou publicitaire, de la présence d’équipements dans l’espace public (bancs, toilettes), de la répartition de biotopes le long d’un cours d’eau, etc.</p>
<p>Trois grands types de question sont généralement posées à ces données :</p>
<ul>
<li>les points sont-ils significativement proches (ou éloignés) les uns des autres (étude du voisinage) ?</li>
<li>existe-il des lieux où la concentration des points est notable (<em>hot spots</em>) ?</li>
<li>quel modèle statistique est susceptible d’expliquer la géographie de ce semis de points ?</li>
</ul>
</section>
<section id="le-package-linnet" class="level1">
<h1>Le package linnet</h1>
<p><code>spatstat.linnet</code><a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a> est un <em>package</em> de la famille de <em>packages</em> <code>spatstat</code> consacrés à la statistique spatiale et notamment à l’analyse de semis de points.</p>
<section id="préparer-ses-données" class="level2">
<h2 class="anchored" data-anchor-id="préparer-ses-données">Préparer ses données</h2>
<p>La première étape consiste à créer un objet <code>linnet</code> (<em>linear network</em> ou <span class="math inline">L</span>) à l’aide de deux fichiers : un fichier correspondant aux sommets (intersections et extrémités des liens), un fichier correspondant aux liens entre ces sommets. Le fichier des sommets comprend trois colonnes correspondant à l’identifiant et aux coordonnées de chaque sommet ; le fichier des liens comprend <em>a minima</em> deux colonnes correspondant aux deux extrémités de chaque lien. L’orientation des liens n’est pas prise en compte : un lien <em>a-b</em> implique nécessairement un lien <em>b-a</em>, il n’est donc pas utile d’avoir deux lignes différentes.</p>
<p>Créer un objet <code>lpp</code> (<em>linear point pattern</em>) suppose d’ajouter à ce réseau <span class="math inline">L</span> un semis de points. Le fichier correspondant comprend au moins les coordonnées (x,y) de chacun des points, nécessairement situés sur <span class="math inline">L</span>, c’est-à-dire accrochés d’un point de vue topologique ; il peut comprendre autant de colonnes supplémentaires que d’attributs, les attributs pouvant être de types différents (entiers, flottants, chaîne de caractères, booléen). Si les coordonnées d’un sommet de ce semis de points sont situées en dehors du réseau planaire <span class="math inline">L</span>, le package accroche par défaut le sommet en question au lien le plus proche. Aucun avertissement n’est affiché par le package. En revanche, quand un point est situé en dehors de la fenêtre d’observation<a href="#fn2" class="footnote-ref" id="fnref2" role="doc-noteref"><sup>2</sup></a> dans laquelle est intégré le réseau étudié, il n’est pas accroché à un lien et un message avertit que le point a été rejeté de la construction du <code>lpp</code>.</p>
</section>
<section id="créer-des-objets-linnet-et-lpp-de-a-à-z-et-visualiser-pour-comprendre-la-structure-des-objets" class="level2">
<h2 class="anchored" data-anchor-id="créer-des-objets-linnet-et-lpp-de-a-à-z-et-visualiser-pour-comprendre-la-structure-des-objets">Créer des objets <code>linnet</code> et <code>lpp</code> de A à Z et visualiser pour comprendre la structure des objets</h2>
<p>Dans un premier temps, nous montrons comment créer les objets <code>linnet</code> à partir de ses propres données. Le mini jeu de données concerne des affichages politiques dans l’espace public. Deux fichiers sont utilisés pour créer le réseau planaire : un fichier de points et leurs coordonnées ; un fichier de liens entre ces points (liens non orientés). L’ultime point de ce dernier fichier est volontairement situé hors du réseau planaire.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># chargement des packages</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(sf) <span class="co"># gestion de données spatiales vectorielles</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(spatstat)</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tibble) <span class="co"># construction de données tabulaires de type tibble()</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyr) <span class="co"># modification de la forme et de la hiérarchie d'un tableau</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(dplyr) <span class="co"># manipulation de données tabulaires (filtrage, création de colonne, etc.)</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(stringr) <span class="co"># manipulation de chaîne de charactère</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggplot2) <span class="co"># construction et visualisation de graphiques</span></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="co"># import des fichiers</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>mini_node <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="at">file =</span> <span class="st">"data/data_mini/mini_node.txt"</span>, </span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> <span class="at">header =</span> <span class="cn">TRUE</span>, </span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a> <span class="at">row.names =</span> <span class="dv">1</span>, </span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a> <span class="at">sep =</span> <span class="st">","</span>)</span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a>mini_edge <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="st">"data/data_mini/mini_edge.txt"</span>, </span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a> <span class="at">header =</span> <span class="cn">FALSE</span>, </span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a> <span class="at">sep =</span> <span class="st">","</span>)</span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a><span class="co"># transformation en objet ppp et matrice</span></span>
<span id="cb1-20"><a href="#cb1-20" aria-hidden="true" tabindex="-1"></a>mini_node_ppp <span class="ot"><-</span> <span class="fu">ppp</span>(<span class="at">x =</span> mini_node<span class="sc">$</span>x, </span>
<span id="cb1-21"><a href="#cb1-21" aria-hidden="true" tabindex="-1"></a> <span class="at">y =</span> mini_node<span class="sc">$</span>y, </span>
<span id="cb1-22"><a href="#cb1-22" aria-hidden="true" tabindex="-1"></a> <span class="at">xrange =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">10</span>), </span>
<span id="cb1-23"><a href="#cb1-23" aria-hidden="true" tabindex="-1"></a> <span class="at">yrange =</span> <span class="fu">c</span>(<span class="dv">0</span>,<span class="dv">10</span>)) <span class="co"># coordonnées de la fenêtre d'observation</span></span>
<span id="cb1-24"><a href="#cb1-24" aria-hidden="true" tabindex="-1"></a>mini_edge_matrix <span class="ot"><-</span> <span class="fu">as.matrix</span>(mini_edge, </span>
<span id="cb1-25"><a href="#cb1-25" aria-hidden="true" tabindex="-1"></a> <span class="at">ncol =</span> <span class="dv">2</span>)</span>
<span id="cb1-26"><a href="#cb1-26" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-27"><a href="#cb1-27" aria-hidden="true" tabindex="-1"></a>mini <span class="ot"><-</span> <span class="fu">linnet</span>(<span class="at">vertices =</span> mini_node_ppp, </span>
<span id="cb1-28"><a href="#cb1-28" aria-hidden="true" tabindex="-1"></a> <span class="at">edges =</span> mini_edge_matrix)</span>
<span id="cb1-29"><a href="#cb1-29" aria-hidden="true" tabindex="-1"></a><span class="fu">class</span>(mini)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "linnet" "list" </code></pre>
</div>
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(mini)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-1-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Un semis de points est ensuite importé. Il concerne l’affichage politique et comprend les variables suivantes :</p>
<ul>
<li>x,y : coordonnées du collage</li>
<li>nb : nombre d’affiches (entier)</li>
<li>pol : tendance politique (eg : extrême-gauche, fe : féministe, ed : extrême-droite)</li>
<li>sti : présence d’autocollant (0 : non, 1 : oui)</li>
</ul>
<p>Il est fréquent lorsqu’on récolte des donnnées ponctuelles que les coordonnées ne correspondent pas exactement au tracé viaire. Dans ce jeu de données, la dernière ligne concerne un point décalé d’une unité par rapport à la voie la plus proche. Le package <code>linnet</code>, par défaut, attribue ces points au segment le plus proche. Si le point est équidistant de deux segments, le package semble par défaut attribuer le point au segment le plus court. Il est donc prudent de contrôler soigneusement ses données avant toute manipulation.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co"># semis sur l'affichage politique</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>semis_collage <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="st">"data/data_mini/mini_points.txt"</span>, </span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="at">header =</span> <span class="cn">TRUE</span>, </span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="at">sep =</span> <span class="st">","</span>) </span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="co"># contrôle du typage des variables</span></span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="fu">str</span>(semis_collage)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>'data.frame': 7 obs. of 5 variables:
$ x : num 1 2.8 3 3 3 4.5 7
$ y : num 1.5 1 2.8 3.2 5 6 3
$ nb : int 5 4 1 1 1 2 1
$ pol: chr "eg" "eg" "fe" "fe" ...
$ sti: int 0 1 0 0 0 1 0</code></pre>
</div>
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="co"># typage de la variable sti</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>semis_collage<span class="sc">$</span>sti <span class="ot"><-</span> <span class="fu">as.logical</span>(semis_collage<span class="sc">$</span>sti)</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a><span class="co"># transformation en semis de points sur réseau linéaire</span></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a>collage_lpp <span class="ot"><-</span> <span class="fu">lpp</span>(<span class="at">X =</span> semis_collage, </span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a> <span class="at">L =</span> mini)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Les attributs des semis de points sont appelé <code>marks</code> dans le <em>package</em> <code>linnet</code>. Par défaut, la fonction <code>plot</code> crée une visualisation par attribut et la variable visuelle s’adapte au type de l’attribut. Si l’on souhaite visualiser un attribut et un seul, on utilise l’argument <code>which.marks</code>.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(collage_lpp)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-3-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(collage_lpp, </span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="at">which.marks =</span> <span class="st">"nb"</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-3-2.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>La fonction <code>summary</code> permet d’obtenir des mesures basiques sur le réseau viaire et sur le semis de points.</p>
<p>Concernant les informations sur le réseau viaire, la fonction <code>summary</code> renvoie :</p>
<ul>
<li>le nombre de sommets et de liens (<em>8 vertices and 9 lines</em>)</li>
<li>la longueur totale du réseau (<em>total length 25 units</em>)</li>
<li>le degré maximal (<em>maximum vertex degree 3</em>)</li>
<li>la connexité du réseau (<em>network is connected</em>)</li>
<li>le diamètre (<em>diameter 11</em>)</li>
<li>le rayon (<em>bouding radius: 8</em>)</li>
</ul>
<p>Il est possible d’obtenir ces mesures individuellement à l’aide de fonctions spécifiques, que ce soit le nombre de sommets (<code>nvertices</code>), la longueur totale du réseau planaire (<code>volume</code>) ou le degré (<code>vertexdegree</code>).</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(mini)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Linear network with 8 vertices and 9 lines
Total length 25 units
Maximum vertex degree: 3
[Non-sparse matrix representation]
Network is connected
Diameter: 11 units
Bounding radius: 8 units
Numerical tolerance: 0.002 units
Enclosing window: rectangle = [0, 10] x [0, 10] units</code></pre>
</div>
</div>
<p>Longueur totale, diamètre et rayon se basent sur la distance géographique (exprimée en unités de mesure) sur le réseau planaire et non sur la distance topologique (nombre de liens). Le diamètre donne donc ici la longueur en unités du plus long des plus courts chemins. De manière générale, toutes les méthodes implémentées dans <code>linnet</code> se basent sur les distances géographiques sur le réseau planaire étudié.</p>
<p>La fonction <code>summary</code> appliquée à un semis de points renvoie quant à elle les informations suivantes : propriétés de base du réseau planaire (nombre de sommets, de liens et longueur totale), nombre de points (7), intensité moyenne (<em>average intensity</em>, nombre de points par unité de mesure) et la distribution des éventuels attributs numériques et booléens.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(collage_lpp)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Marked point pattern on linear network
7 points
Linear network with 8 vertices and 9 lines
Total length 25 units
Average intensity 0.28 points per unit length
Mark variables: nb, pol, sti
Summary of marks:
hyperframe with 7 rows and 3 columns
nb pol sti
(integer) (character) (logical)
Min. :1.000 Length:7 Mode :logical
1st Qu.:1.000 Class :character FALSE:5
Median :1.000 Mode :character TRUE :2
Mean :2.143
3rd Qu.:3.000
Max. :5.000
Enclosing window: rectangle = [0, 10] x [0, 10] units</code></pre>
</div>
</div>
<p>Les principales mesures proposées pour caractériser un semis de points sont les suivantes :</p>
<ul>
<li>nombre de points (<code>npoints</code>)</li>
<li>nombre de points par unité de mesure (<code>intensity</code>)</li>
<li>matrice des plus courtes distances entre points (<code>pairdist</code>)</li>
<li>distance au plus proche voisin (<code>nndist</code>)</li>
<li>identifiant du plus proche voisin (<code>nnwhich</code>)</li>
</ul>
<div class="cell">
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="fu">npoints</span>(collage_lpp)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 7</code></pre>
</div>
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="fu">intensity</span>(collage_lpp)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 0.28</code></pre>
</div>
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pairdist</span>(collage_lpp)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 0.0 2.3 3.7 3.7 5.5 8.0 7.5
[2,] 2.3 0.0 2.0 2.4 4.2 6.7 5.2
[3,] 3.7 2.0 0.0 0.4 2.2 4.7 6.8
[4,] 3.7 2.4 0.4 0.0 1.8 4.3 7.2
[5,] 5.5 4.2 2.2 1.8 0.0 2.5 7.0
[6,] 8.0 6.7 4.7 4.3 2.5 0.0 4.5
[7,] 7.5 5.2 6.8 7.2 7.0 4.5 0.0</code></pre>
</div>
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="fu">nndist</span>(collage_lpp)[<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>] </span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 2.3 2.0 0.4 0.4 1.8</code></pre>
</div>
<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="fu">nnwhich</span>(collage_lpp)[<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>] </span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 2 3 4 3 4</code></pre>
</div>
</div>
<p>L’objectif des lignes précédentes était de montrer comment créer un objet <code>linnet</code> de A à Z et de présenter les mesures de base. Les objets créés sont cependant trop pauvres pour justifier des traitements plus avancés et, dans la suite du texte, le jeu de données est issu du projet <a href="https://soduco.geohistoricaldata.org/">SoDUCo</a>.</p>
</section>
<section id="créer-et-visualiser-des-objets-à-partir-de-données-spatiales" class="level2">
<h2 class="anchored" data-anchor-id="créer-et-visualiser-des-objets-à-partir-de-données-spatiales">Créer et visualiser des objets à partir de données spatiales</h2>
<p>Les données sont issues de l’extraction des <em>Annuaires</em> commerciaux de la ville de Paris en 1839<a href="#fn3" class="footnote-ref" id="fnref3" role="doc-noteref"><sup>3</sup></a>. Les deux jeux de données listent les épiciers et les bijoutiers présents dans l’espace municipal à cette date.</p>
<p>Le code suivant permet d’importer les données et de les transformer en objet <code>linnet</code>, puis en objet <code>lpp</code>.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb23"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="co"># import du réseau viaire parisien en 1836</span></span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a>paris <span class="ot"><-</span> <span class="fu">st_read</span>(<span class="st">"data/1836_jacoubet.gpkg"</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Reading layer `1836_jacoubet' from data source
`D:\jgravier\Sync\publications\linnet_point_pattern\data\1836_jacoubet.gpkg'
using driver `GPKG'
Simple feature collection with 4266 features and 2 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: 647640.1 ymin: 6859014 xmax: 656138.1 ymax: 6865167
Projected CRS: RGF93 Lambert 93</code></pre>
</div>
<div class="sourceCode cell-code" id="cb25"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="co"># import des semis de points</span></span>
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a>epiciers <span class="ot"><-</span> <span class="fu">st_read</span>(<span class="at">dsn =</span> <span class="st">"data/grocers_1839.gpkg"</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Reading layer `grocers_1839' from data source
`D:\jgravier\Sync\publications\linnet_point_pattern\data\grocers_1839.gpkg'
using driver `GPKG'
Simple feature collection with 1028 features and 3 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 648447.8 ymin: 6859096 xmax: 655618 ymax: 6865142
Projected CRS: +proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +units=m +no_defs</code></pre>
</div>
<div class="sourceCode cell-code" id="cb27"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a>bijoutiers <span class="ot"><-</span> <span class="fu">st_read</span>(<span class="at">dsn =</span> <span class="st">"data/jewellers_1839.gpkg"</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Reading layer `jewellers_1839' from data source
`D:\jgravier\Sync\publications\linnet_point_pattern\data\jewellers_1839.gpkg'
using driver `GPKG'
Simple feature collection with 341 features and 3 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 648631.2 ymin: 6860188 xmax: 654177.7 ymax: 6865008
Projected CRS: +proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +units=m +no_defs</code></pre>
</div>
<div class="sourceCode cell-code" id="cb29"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="co"># contrôle visuel des objets importés</span></span>
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(paris<span class="sc">$</span>geom)</span>
<span id="cb29-3"><a href="#cb29-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(epiciers<span class="sc">$</span>geom, </span>
<span id="cb29-4"><a href="#cb29-4" aria-hidden="true" tabindex="-1"></a> <span class="at">pch =</span> <span class="dv">15</span>, </span>
<span id="cb29-5"><a href="#cb29-5" aria-hidden="true" tabindex="-1"></a> <span class="at">col =</span> <span class="st">"blue"</span>, </span>
<span id="cb29-6"><a href="#cb29-6" aria-hidden="true" tabindex="-1"></a> <span class="at">add =</span> <span class="cn">TRUE</span>)</span>
<span id="cb29-7"><a href="#cb29-7" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(bijoutiers<span class="sc">$</span>geom, </span>
<span id="cb29-8"><a href="#cb29-8" aria-hidden="true" tabindex="-1"></a> <span class="at">pch =</span> <span class="dv">15</span>, </span>
<span id="cb29-9"><a href="#cb29-9" aria-hidden="true" tabindex="-1"></a> <span class="at">col =</span> <span class="st">"red"</span>, </span>
<span id="cb29-10"><a href="#cb29-10" aria-hidden="true" tabindex="-1"></a> <span class="at">bg =</span> <span class="st">"red"</span>, </span>
<span id="cb29-11"><a href="#cb29-11" aria-hidden="true" tabindex="-1"></a> <span class="at">add =</span> <span class="cn">TRUE</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-7-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>La transformation des semis de points en objets spatstat se fait à l’aide de la fonction <code>as.ppp</code> (<em>planar point pattern</em>). Pour transformer le réseau viaire en objet <code>linnet</code>, deux étapes sont nécessaires : transformer le <code>sf</code> en objet <code>psp</code> (<em>planar segment pattern</em>) puis en objet <code>linnet</code> (<em>linear network</em>). La fonction <code>summary</code> permet de connaître les principales propriétés des objets créés.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb30"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a>epiciers_ppp <span class="ot"><-</span> <span class="fu">as.ppp</span>(<span class="fu">st_geometry</span>(epiciers))</span>
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a>bijoutiers_ppp <span class="ot"><-</span> <span class="fu">as.ppp</span>(<span class="fu">st_geometry</span>(bijoutiers))</span>
<span id="cb30-3"><a href="#cb30-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb30-4"><a href="#cb30-4" aria-hidden="true" tabindex="-1"></a>paris_linnet <span class="ot"><-</span> <span class="fu">as.psp</span>(<span class="fu">st_geometry</span>(paris))</span>
<span id="cb30-5"><a href="#cb30-5" aria-hidden="true" tabindex="-1"></a>paris_linnet <span class="ot"><-</span> <span class="fu">as.linnet</span>(paris_linnet)</span>
<span id="cb30-6"><a href="#cb30-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb30-7"><a href="#cb30-7" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(paris_linnet)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Linear network with 7237 vertices and 8730 lines
Total length 461193.7 units
Maximum vertex degree: 7
[Non-sparse matrix representation]
Network is connected
Diameter: 10017.93 units
Bounding radius: 5058.732 units
Numerical tolerance: 1.673106e-07 units
Enclosing window: rectangle = [647640.1, 656138.1] x [6859014, 6865167] units</code></pre>
</div>
</div>
<p>Le réseau parisien est composé de 7 237 sommets et 8 730 liens. La longueur totale du réseau, exprimée ici en mètres, est de 460 km dans un diamètre de 10 km. Ce dernier représente ici la longueur du plus long des plus courts chemins entre deux sommets.</p>
<p>La dernière étape consiste à intégrer dans le même objet le réseau linéaire et chacun des semis de points à l’aide de la fonction <code>lpp</code><a href="#fn4" class="footnote-ref" id="fnref4" role="doc-noteref"><sup>4</sup></a>. Les semis sont composés de 341 bijoutiers et 1 028 épiciers.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb32"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a>epiciers_lpp <span class="ot"><-</span> <span class="fu">lpp</span>(<span class="at">X =</span> epiciers_ppp, </span>
<span id="cb32-2"><a href="#cb32-2" aria-hidden="true" tabindex="-1"></a> <span class="at">L =</span> paris_linnet)</span>
<span id="cb32-3"><a href="#cb32-3" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(epiciers_lpp)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Point pattern on linear network
1028 points
Linear network with 7237 vertices and 8730 lines
Total length 461193.7 units
Average intensity 0.002228998 points per unit length
Unmarked
Enclosing window: rectangle = [647640.1, 656138.1] x [6859014, 6865167] units</code></pre>
</div>
<div class="sourceCode cell-code" id="cb34"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a>bijoutiers_lpp <span class="ot"><-</span> <span class="fu">lpp</span>(<span class="at">X =</span> bijoutiers_ppp, </span>
<span id="cb34-2"><a href="#cb34-2" aria-hidden="true" tabindex="-1"></a> <span class="at">L =</span> paris_linnet)</span>
<span id="cb34-3"><a href="#cb34-3" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(bijoutiers_lpp)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Point pattern on linear network
341 points
Linear network with 7237 vertices and 8730 lines
Total length 461193.7 units
Average intensity 0.0007393856 points per unit length
Unmarked
Enclosing window: rectangle = [647640.1, 656138.1] x [6859014, 6865167] units</code></pre>
</div>
</div>
<p>Il est possible d’étudier un semis de points sur un réseau spatial selon les mêmes logiques qu’un semis dans un espace isotrope car diverses mesures ont été adaptées afin de considérer la structure du réseau <span class="citation" data-cites="okabe2012">(voir en particulier <a href="#ref-okabe2012" role="doc-biblioref">Okabe et Sugihara, 2012</a>)</span>.</p>
</section>
</section>
<section id="modéliser-la-géographie-du-semis-de-points" class="level1">
<h1>Modéliser la géographie du semis de points</h1>
<p>La modélisation du semis de points implique conceptuellement de distinguer le motif ponctuel (<em>point pattern</em>) et le processus ponctuel (<em>point process</em>), ce dernier renvoyant au processus aléatoire qui permet de générer un semis de points. Dans le cas de <code>linnet</code>, il est possible de générer différents processus aléatoires sur un réseau. Il devient donc possible de comparer la répartition spatiale du semis étudié par rapport à une situation aléatoire afin de mieux caractériser les processus potentiels ayant pu mener à la situation observée.</p>
<section id="répartitions-aléatoires-des-points-sur-un-réseau-spatial" class="level2">
<h2 class="anchored" data-anchor-id="répartitions-aléatoires-des-points-sur-un-réseau-spatial">Répartitions aléatoires des points sur un réseau spatial</h2>
<p>Plusieurs processus aléatoires déterminant à la fois le nombre et la distribution spatiale des points peuvent être simulés dans <code>linnet</code>. Dans le premier cas (fonction <code>runiflpp()</code>), le semis de points est généré de façon aléatoire et la position des points est fonction de la structure du réseau, en l’occurrence la longueur des tronçons : plus un tronçon est long, plus il est probable qu’il accueille un ou plusieurs points. Cette hypothèse n’est pas toujours la plus pertinente. Si on prend l’exemple des accidents de voiture, on peut supposer qu’ils sont plus fréquents à mesure que le trafic augmente (et non par la seule longueur des routes). Les deux options suivantes (<code>rpoislpp()</code> et <code>rlpp()</code>) permettent de générer un semis de points aléatoire lié à une intensité variable sur le réseau.</p>
<p>Pour résumer, on peut simuler les trois semis suivants :</p>
<ul>
<li>Un processus aléatoire uniforme avec <code>runiflpp()</code>. La fonction génère <span class="math inline">n</span> points aléatoires, indépendamment et uniformément distribués, sur le réseau <span class="math inline">L</span>. La probabilité de tirer un tronçon <span class="math inline">Ls</span> du réseau dépend de sa longueur dans <span class="math inline">L</span>. Le point est ensuite généré selon une probabilité uniforme le long de <span class="math inline">Ls</span>.</li>
<li>Un processus poissonien avec la fonction <code>rpoislpp()</code>. Elle génère une réalisation du processus de Poisson avec une intensité spécifiée (paramètre <code>lambda</code>) sur le réseau <span class="math inline">L</span>.</li>
<li>Un processus aléatoire grâce à <code>rlpp()</code>, qui génère <span class="math inline">n</span> points aléatoires sur le réseau <span class="math inline">L</span> avec une densité de probabilité spécifiée (paramètre <code>f</code>). Cette dernière ne doit pas nécessairement être normalisée.</li>
</ul>
<p>Quelle que soit la fonction utilisée, il est possible de spécifier le nombre de simulations souhaitées grâce au paramètre <code>nsim</code>.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb36"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a><span class="co"># visualisation de la génération d'une simulation selon un processus de Poisson</span></span>
<span id="cb36-2"><a href="#cb36-2" aria-hidden="true" tabindex="-1"></a><span class="co"># avec une intensité uniforme égale à la densité moyenne</span></span>
<span id="cb36-3"><a href="#cb36-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(<span class="at">x =</span> <span class="fu">rpoislpp</span>(<span class="at">lambda =</span> <span class="fu">intensity</span>(bijoutiers_lpp), <span class="co"># le nombre de points est variable</span></span>
<span id="cb36-4"><a href="#cb36-4" aria-hidden="true" tabindex="-1"></a> <span class="at">L =</span> paris_linnet, </span>
<span id="cb36-5"><a href="#cb36-5" aria-hidden="true" tabindex="-1"></a> <span class="at">nsim =</span> <span class="dv">1</span>),</span>
<span id="cb36-6"><a href="#cb36-6" aria-hidden="true" tabindex="-1"></a> <span class="at">pch =</span> <span class="dv">15</span>, <span class="at">main =</span> <span class="cn">NULL</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-10-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Dans les cas de <code>rpoislpp()</code> et de <code>runiflpp()</code>, le paramètre <code>ex</code> permet d’intégrer un objet <code>lpp</code> afin de déterminer <span class="math inline">L</span>, ainsi que <span class="math inline">\lambda</span> et <span class="math inline">n</span>. La valeur par défaut de <span class="math inline">\lambda</span> est alors la densité moyenne des points du <code>lpp</code>, ou <span class="math inline">n</span> le nombre de points de l’objet <code>lpp</code>.</p>
</section>
<section id="mesurer-lécart-des-distributions-observées-aux-distributions-aléatoires" class="level2">
<h2 class="anchored" data-anchor-id="mesurer-lécart-des-distributions-observées-aux-distributions-aléatoires">Mesurer l’écart des distributions observées aux distributions aléatoires</h2>
<p>Au même titre que dans le cadre d’analyse de semis de points dans un espace</p>
<!-- à écrire -->
<p>Cas des bijoutiers, distances points aléatoires VS distances observées. Ici : proposition d’une boucle et de l’utilisation des packages de la famille du <code>tydiverse</code> à visée pédagogique, mais mieux de faire une fonction pour paralléliser le calcul matriciel si l’on a un nombre de simulations élevés (e.g. 100) et un semis initial et un réseau plus important, et d’utiliser plutôt des packages comme <code>dtplyr</code> ou directement <code>data.table</code>.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb37"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a><span class="co"># génération de 10 simulations</span></span>
<span id="cb37-2"><a href="#cb37-2" aria-hidden="true" tabindex="-1"></a>bijoutiers_10sim <span class="ot"><-</span> <span class="fu">runiflpp</span>(<span class="at">ex =</span> bijoutiers_lpp, <span class="at">nsim =</span> <span class="dv">10</span>)</span>
<span id="cb37-3"><a href="#cb37-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb37-4"><a href="#cb37-4" aria-hidden="true" tabindex="-1"></a><span class="co"># calcul des distances entre les points simulés aléatoirement sur le réseau</span></span>
<span id="cb37-5"><a href="#cb37-5" aria-hidden="true" tabindex="-1"></a>list_simulated_dist <span class="ot"><-</span> <span class="fu">list</span>()</span>
<span id="cb37-6"><a href="#cb37-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb37-7"><a href="#cb37-7" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="fu">length</span>(bijoutiers_10sim)) {</span>
<span id="cb37-8"><a href="#cb37-8" aria-hidden="true" tabindex="-1"></a> <span class="co"># calculs des plus courts chemins sur réseau</span></span>
<span id="cb37-9"><a href="#cb37-9" aria-hidden="true" tabindex="-1"></a> dist_pi_p <span class="ot"><-</span> spatstat.geom<span class="sc">::</span><span class="fu">pairdist</span>(<span class="at">X =</span> bijoutiers_10sim[[i]])</span>
<span id="cb37-10"><a href="#cb37-10" aria-hidden="true" tabindex="-1"></a> dist_pi_p[<span class="fu">upper.tri</span>(<span class="at">x =</span> dist_pi_p, <span class="at">diag =</span> <span class="cn">TRUE</span>)] <span class="ot"><-</span> <span class="cn">NA</span></span>
<span id="cb37-11"><a href="#cb37-11" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb37-12"><a href="#cb37-12" aria-hidden="true" tabindex="-1"></a> dist_pi_p <span class="ot"><-</span> dist_pi_p <span class="sc">%>%</span></span>
<span id="cb37-13"><a href="#cb37-13" aria-hidden="true" tabindex="-1"></a> tibble<span class="sc">::</span><span class="fu">as_tibble</span>() <span class="sc">%>%</span></span>
<span id="cb37-14"><a href="#cb37-14" aria-hidden="true" tabindex="-1"></a> tibble<span class="sc">::</span><span class="fu">rowid_to_column</span>(<span class="at">var =</span> <span class="st">"Pi"</span>) <span class="sc">%>%</span></span>
<span id="cb37-15"><a href="#cb37-15" aria-hidden="true" tabindex="-1"></a> tidyr<span class="sc">::</span><span class="fu">pivot_longer</span>(<span class="at">cols =</span> <span class="sc">-</span>Pi, <span class="at">names_to =</span> <span class="st">"P"</span>, <span class="at">values_to =</span> <span class="st">"dist_pi_p"</span>) <span class="sc">%>%</span></span>
<span id="cb37-16"><a href="#cb37-16" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(dist_pi_p)) <span class="sc">%>%</span></span>
<span id="cb37-17"><a href="#cb37-17" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">P =</span> stringr<span class="sc">::</span><span class="fu">str_replace_all</span>(<span class="at">string =</span> P, <span class="at">pattern =</span> <span class="st">"V"</span>, <span class="at">replacement =</span> <span class="st">""</span>)) <span class="sc">%>%</span></span>
<span id="cb37-18"><a href="#cb37-18" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">type =</span> <span class="st">"simulation"</span>, <span class="at">n_sim =</span> i)</span>
<span id="cb37-19"><a href="#cb37-19" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb37-20"><a href="#cb37-20" aria-hidden="true" tabindex="-1"></a> list_simulated_dist[[i]] <span class="ot"><-</span> dist_pi_p </span>
<span id="cb37-21"><a href="#cb37-21" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb37-22"><a href="#cb37-22" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb37-23"><a href="#cb37-23" aria-hidden="true" tabindex="-1"></a><span class="co"># création d'un unique tableau et non d'une liste de tableaux</span></span>
<span id="cb37-24"><a href="#cb37-24" aria-hidden="true" tabindex="-1"></a>table_simulated_dist <span class="ot"><-</span> <span class="fu">do.call</span>(<span class="at">what =</span> <span class="st">"rbind"</span>, <span class="at">args =</span> list_simulated_dist)</span>
<span id="cb37-25"><a href="#cb37-25" aria-hidden="true" tabindex="-1"></a>table_simulated_dist</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code># A tibble: 579,700 × 5
Pi P dist_pi_p type n_sim
<int> <chr> <dbl> <chr> <int>
1 2 1 2944. simulation 1
2 3 1 1480. simulation 1
3 3 2 3283. simulation 1
4 4 1 2882. simulation 1
5 4 2 4781. simulation 1
6 4 3 1498. simulation 1
7 5 1 1795. simulation 1
8 5 2 1471. simulation 1
9 5 3 2555. simulation 1
10 5 4 4052. simulation 1
# ℹ 579,690 more rows</code></pre>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb39"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a><span class="co"># calcul des distances entre les points observés des bijoutiers en 1839</span></span>
<span id="cb39-2"><a href="#cb39-2" aria-hidden="true" tabindex="-1"></a>dist_bijoutiers <span class="ot"><-</span> spatstat.geom<span class="sc">::</span><span class="fu">pairdist</span>(<span class="at">X =</span> bijoutiers_lpp)</span>
<span id="cb39-3"><a href="#cb39-3" aria-hidden="true" tabindex="-1"></a>dist_bijoutiers[<span class="fu">upper.tri</span>(<span class="at">x =</span> dist_bijoutiers, <span class="at">diag =</span> <span class="cn">TRUE</span>)] <span class="ot"><-</span> <span class="cn">NA</span></span>
<span id="cb39-4"><a href="#cb39-4" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb39-5"><a href="#cb39-5" aria-hidden="true" tabindex="-1"></a>dist_bijoutiers <span class="ot"><-</span> dist_bijoutiers <span class="sc">%>%</span></span>
<span id="cb39-6"><a href="#cb39-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">as_tibble</span>() <span class="sc">%>%</span></span>
<span id="cb39-7"><a href="#cb39-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">rowid_to_column</span>(<span class="at">var =</span> <span class="st">"Pi"</span>) <span class="sc">%>%</span></span>
<span id="cb39-8"><a href="#cb39-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_longer</span>(<span class="at">cols =</span> <span class="sc">-</span>Pi, <span class="at">names_to =</span> <span class="st">"P"</span>, <span class="at">values_to =</span> <span class="st">"dist_pi_p"</span>) <span class="sc">%>%</span></span>
<span id="cb39-9"><a href="#cb39-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(dist_pi_p)) <span class="sc">%>%</span></span>
<span id="cb39-10"><a href="#cb39-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">P =</span> stringr<span class="sc">::</span><span class="fu">str_replace_all</span>(<span class="at">string =</span> P, <span class="at">pattern =</span> <span class="st">"V"</span>, <span class="at">replacement =</span> <span class="st">""</span>)) <span class="sc">%>%</span></span>
<span id="cb39-11"><a href="#cb39-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">type =</span> <span class="st">"observation"</span>, <span class="at">n_sim =</span> <span class="cn">NA</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Comparaison visuelle <!-- à commenter --></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb40"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a>bijoutiers_ecart <span class="ot"><-</span> table_simulated_dist <span class="sc">%>%</span></span>
<span id="cb40-2"><a href="#cb40-2" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">bind_rows</span>(dist_bijoutiers)</span>
<span id="cb40-3"><a href="#cb40-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb40-4"><a href="#cb40-4" aria-hidden="true" tabindex="-1"></a>bijoutiers_ecart <span class="sc">%>%</span></span>
<span id="cb40-5"><a href="#cb40-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x =</span> dist_pi_p, <span class="at">color =</span> type)) <span class="sc">+</span></span>
<span id="cb40-6"><a href="#cb40-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>(<span class="at">linewidth =</span> <span class="dv">1</span>) <span class="sc">+</span></span>
<span id="cb40-7"><a href="#cb40-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>()</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-13-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Idem, cas des épiciers <!-- courbe ajoutée uniquement sans visualisation du code. A commenter --></p>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-15-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="répartition-aléatoire-inhomogène" class="level2">
<h2 class="anchored" data-anchor-id="répartition-aléatoire-inhomogène">Répartition aléatoire inhomogène</h2>
<p>Mesurer l’écart à une répartition aléatoire inhomogène selon l’inverse de la distance au centre. <!-- expliciter choix du centre : signification --></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb41"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a>center <span class="ot"><-</span> <span class="fu">st_read</span>(<span class="at">dsn =</span> <span class="st">"data/halles.gpkg"</span>) <span class="co"># Les Halles considérées comme centre économique</span></span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Reading layer `notre-dame' from data source
`D:\jgravier\Sync\publications\linnet_point_pattern\data\halles.gpkg'
using driver `GPKG'
Simple feature collection with 1 feature and 2 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 651980.5 ymin: 6862655 xmax: 651980.5 ymax: 6862655
Projected CRS: RGF93 v1 / Lambert-93</code></pre>
</div>
<div class="sourceCode cell-code" id="cb43"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a>center_ppp <span class="ot"><-</span> <span class="fu">as.ppp</span>(<span class="fu">st_geometry</span>(center)) <span class="co"># semis de points</span></span>
<span id="cb43-2"><a href="#cb43-2" aria-hidden="true" tabindex="-1"></a>center_lpp <span class="ot"><-</span> <span class="fu">lpp</span>(<span class="at">X =</span> center_ppp, <span class="at">L =</span> paris_linnet) <span class="co"># semis de points sur le réseau</span></span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<!-- expliciter import de la fonction (vérifier encore une fois inexistance inverse de la distance) -->
<div class="cell">
<div class="sourceCode cell-code" id="cb44"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1"><a href="#cb44-1" aria-hidden="true" tabindex="-1"></a><span class="co"># import fonction</span></span>
<span id="cb44-2"><a href="#cb44-2" aria-hidden="true" tabindex="-1"></a><span class="fu">source</span>(<span class="at">file =</span> <span class="st">"local-functions.R"</span>) <span class="co"># adaptation de spatstat.linnet::distfun.lpp()</span></span>
<span id="cb44-3"><a href="#cb44-3" aria-hidden="true" tabindex="-1"></a>f_dist2_center <span class="ot"><-</span> <span class="fu">distfun.inverse.lpp</span>(<span class="at">X =</span> center_lpp) <span class="co"># création de la fonction d'intensité</span></span>
<span id="cb44-4"><a href="#cb44-4" aria-hidden="true" tabindex="-1"></a>f_dist2_center</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Function on linear network:
function (x, y = NULL, seg = NULL, tp = NULL, ...)
{
Y <- as.lpp(x = x, y = y, seg = seg, tp = tp, L = L)
d <- nncross.lpp(Y, X, what = "dist", k = k)
d <- 1/d
return(d)
}
<bytecode: 0x0000026111356e70>
<environment: 0x000002610d70e008>
Function domain:
Linear network with 7237 vertices and 8730 lines
Enclosing window: rectangle = [647640.1, 656138.1] x [6859014, 6865167] units</code></pre>
</div>
</div>
<p>Répartition aléatoire inhomogène selon l’inverse de la distance au centre, i.e. plus on s’éloigne, plus la probabilité qu’un point soit simulé sur un tronçon diminue. <!-- à commenter --></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb46"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb46-1"><a href="#cb46-1" aria-hidden="true" tabindex="-1"></a><span class="co"># simulation aléatoire de Poisson</span></span>
<span id="cb46-2"><a href="#cb46-2" aria-hidden="true" tabindex="-1"></a>dist2_center_bijoutiers <span class="ot"><-</span> <span class="fu">rpoislpp</span>(<span class="at">lambda =</span> f_dist2_center, <span class="co"># fonction d'intensité</span></span>
<span id="cb46-3"><a href="#cb46-3" aria-hidden="true" tabindex="-1"></a> <span class="at">L =</span> paris_linnet, <span class="co"># réseau</span></span>
<span id="cb46-4"><a href="#cb46-4" aria-hidden="true" tabindex="-1"></a> <span class="at">lmax =</span> <span class="fl">0.05</span>,</span>
<span id="cb46-5"><a href="#cb46-5" aria-hidden="true" tabindex="-1"></a> <span class="at">nsim =</span> <span class="dv">1</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Il est important de spécifier <code>lmax</code> si possible afin de diminuer le temps de calcul<a href="#fn5" class="footnote-ref" id="fnref5" role="doc-noteref"><sup>5</sup></a>.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb47"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1"><a href="#cb47-1" aria-hidden="true" tabindex="-1"></a>lmax_known <span class="ot"><-</span> <span class="fu">as.linim</span>(f_dist2_center)</span>
<span id="cb47-2"><a href="#cb47-2" aria-hidden="true" tabindex="-1"></a>tab_lmax <span class="ot"><-</span> <span class="fu">attr</span>(<span class="at">x =</span> lmax_known, <span class="at">which =</span> <span class="st">"df"</span>)</span>
<span id="cb47-3"><a href="#cb47-3" aria-hidden="true" tabindex="-1"></a><span class="fu">max</span>(tab_lmax<span class="sc">$</span>values)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Visualisation</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb48"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb48-1"><a href="#cb48-1" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(dist2_center_bijoutiers, <span class="at">pch =</span> <span class="dv">15</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-20-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Calcul des distances entre les points simulés et le centre. Deux lpp avec <code>crossdist.lpp()</code></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb49"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1"><a href="#cb49-1" aria-hidden="true" tabindex="-1"></a><span class="co"># génération de 10 simulations (Poisson)</span></span>
<span id="cb49-2"><a href="#cb49-2" aria-hidden="true" tabindex="-1"></a>bijoutiers_10sim <span class="ot"><-</span> <span class="fu">rpoislpp</span>(<span class="at">lambda =</span> f_dist2_center, <span class="co"># fonction d'intensité</span></span>
<span id="cb49-3"><a href="#cb49-3" aria-hidden="true" tabindex="-1"></a> <span class="at">L =</span> paris_linnet, <span class="co"># réseau</span></span>
<span id="cb49-4"><a href="#cb49-4" aria-hidden="true" tabindex="-1"></a> <span class="at">lmax =</span> <span class="fl">0.05</span>, <span class="co"># cf. plus bas</span></span>
<span id="cb49-5"><a href="#cb49-5" aria-hidden="true" tabindex="-1"></a> <span class="at">nsim =</span> <span class="dv">10</span>)</span>
<span id="cb49-6"><a href="#cb49-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb49-7"><a href="#cb49-7" aria-hidden="true" tabindex="-1"></a>list_simulated_dist <span class="ot"><-</span> <span class="fu">list</span>()</span>
<span id="cb49-8"><a href="#cb49-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb49-9"><a href="#cb49-9" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="fu">length</span>(bijoutiers_10sim)) {</span>
<span id="cb49-10"><a href="#cb49-10" aria-hidden="true" tabindex="-1"></a> dist_pi_p <span class="ot"><-</span> <span class="fu">crossdist.lpp</span>(<span class="at">X =</span> bijoutiers_10sim[[i]], <span class="at">Y =</span> center_lpp) <span class="co"># distances au plus court chemin entre deux lpp</span></span>
<span id="cb49-11"><a href="#cb49-11" aria-hidden="true" tabindex="-1"></a> dist_pi_p[<span class="fu">upper.tri</span>(<span class="at">x =</span> dist_pi_p, <span class="at">diag =</span> <span class="cn">TRUE</span>)] <span class="ot"><-</span> <span class="cn">NA</span></span>
<span id="cb49-12"><a href="#cb49-12" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb49-13"><a href="#cb49-13" aria-hidden="true" tabindex="-1"></a> dist_pi_p <span class="ot"><-</span> dist_pi_p <span class="sc">%>%</span></span>
<span id="cb49-14"><a href="#cb49-14" aria-hidden="true" tabindex="-1"></a> tibble<span class="sc">::</span><span class="fu">as_tibble</span>() <span class="sc">%>%</span></span>
<span id="cb49-15"><a href="#cb49-15" aria-hidden="true" tabindex="-1"></a> tibble<span class="sc">::</span><span class="fu">rowid_to_column</span>(<span class="at">var =</span> <span class="st">"Pi"</span>) <span class="sc">%>%</span></span>
<span id="cb49-16"><a href="#cb49-16" aria-hidden="true" tabindex="-1"></a> tidyr<span class="sc">::</span><span class="fu">pivot_longer</span>(<span class="at">cols =</span> <span class="sc">-</span>Pi, <span class="at">names_to =</span> <span class="st">"P"</span>, <span class="at">values_to =</span> <span class="st">"dist_pi_p"</span>) <span class="sc">%>%</span></span>
<span id="cb49-17"><a href="#cb49-17" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(dist_pi_p)) <span class="sc">%>%</span></span>
<span id="cb49-18"><a href="#cb49-18" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">P =</span> stringr<span class="sc">::</span><span class="fu">str_replace_all</span>(<span class="at">string =</span> P, <span class="at">pattern =</span> <span class="st">"V"</span>, <span class="at">replacement =</span> <span class="st">""</span>)) <span class="sc">%>%</span></span>
<span id="cb49-19"><a href="#cb49-19" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">type =</span> <span class="st">"simulation"</span>, <span class="at">n_sim =</span> i)</span>
<span id="cb49-20"><a href="#cb49-20" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb49-21"><a href="#cb49-21" aria-hidden="true" tabindex="-1"></a> list_simulated_dist[[i]] <span class="ot"><-</span> dist_pi_p </span>
<span id="cb49-22"><a href="#cb49-22" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb49-23"><a href="#cb49-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb49-24"><a href="#cb49-24" aria-hidden="true" tabindex="-1"></a>table_simulated_dist <span class="ot"><-</span> <span class="fu">do.call</span>(<span class="at">what =</span> <span class="st">"rbind"</span>, <span class="at">args =</span> list_simulated_dist)</span>
<span id="cb49-25"><a href="#cb49-25" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb49-26"><a href="#cb49-26" aria-hidden="true" tabindex="-1"></a><span class="co"># calcul des distances entre les points observés des bijoutiers et le centre</span></span>
<span id="cb49-27"><a href="#cb49-27" aria-hidden="true" tabindex="-1"></a>dist_bijoutiers <span class="ot"><-</span> <span class="fu">crossdist.lpp</span>(<span class="at">X =</span> bijoutiers_lpp, <span class="at">Y =</span> center_lpp)</span>
<span id="cb49-28"><a href="#cb49-28" aria-hidden="true" tabindex="-1"></a>dist_bijoutiers[<span class="fu">upper.tri</span>(<span class="at">x =</span> dist_bijoutiers, <span class="at">diag =</span> <span class="cn">TRUE</span>)] <span class="ot"><-</span> <span class="cn">NA</span></span>
<span id="cb49-29"><a href="#cb49-29" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb49-30"><a href="#cb49-30" aria-hidden="true" tabindex="-1"></a>dist_bijoutiers <span class="ot"><-</span> dist_bijoutiers <span class="sc">%>%</span></span>
<span id="cb49-31"><a href="#cb49-31" aria-hidden="true" tabindex="-1"></a> <span class="fu">as_tibble</span>() <span class="sc">%>%</span></span>
<span id="cb49-32"><a href="#cb49-32" aria-hidden="true" tabindex="-1"></a> <span class="fu">rowid_to_column</span>(<span class="at">var =</span> <span class="st">"Pi"</span>) <span class="sc">%>%</span></span>
<span id="cb49-33"><a href="#cb49-33" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_longer</span>(<span class="at">cols =</span> <span class="sc">-</span>Pi, <span class="at">names_to =</span> <span class="st">"P"</span>, <span class="at">values_to =</span> <span class="st">"dist_pi_p"</span>) <span class="sc">%>%</span></span>
<span id="cb49-34"><a href="#cb49-34" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(dist_pi_p)) <span class="sc">%>%</span></span>
<span id="cb49-35"><a href="#cb49-35" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">P =</span> stringr<span class="sc">::</span><span class="fu">str_replace_all</span>(<span class="at">string =</span> P, <span class="at">pattern =</span> <span class="st">"V"</span>, <span class="at">replacement =</span> <span class="st">""</span>)) <span class="sc">%>%</span></span>
<span id="cb49-36"><a href="#cb49-36" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">type =</span> <span class="st">"observation"</span>, <span class="at">n_sim =</span> <span class="cn">NA</span>)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Visualisation</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb50"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb50-1"><a href="#cb50-1" aria-hidden="true" tabindex="-1"></a>bijoutiers_ecart <span class="ot"><-</span> table_simulated_dist <span class="sc">%>%</span></span>
<span id="cb50-2"><a href="#cb50-2" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">bind_rows</span>(dist_bijoutiers)</span>
<span id="cb50-3"><a href="#cb50-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb50-4"><a href="#cb50-4" aria-hidden="true" tabindex="-1"></a>bijoutiers_ecart <span class="sc">%>%</span></span>
<span id="cb50-5"><a href="#cb50-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x =</span> dist_pi_p, <span class="at">color =</span> type)) <span class="sc">+</span></span>
<span id="cb50-6"><a href="#cb50-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>(<span class="at">linewidth =</span> <span class="dv">1</span>) <span class="sc">+</span></span>
<span id="cb50-7"><a href="#cb50-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">xlab</span>(<span class="st">"distance en mètres"</span>) <span class="sc">+</span></span>
<span id="cb50-8"><a href="#cb50-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">ylab</span>(<span class="st">"KDE"</span>) <span class="sc">+</span></span>
<span id="cb50-9"><a href="#cb50-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>()</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-22-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<!-- ajouter ici : possibilité de considérer plusieurs points concomitamment (i.e. des pôles) -->
</section>
<section id="étudier-les-voisinages" class="level2">
<h2 class="anchored" data-anchor-id="étudier-les-voisinages">Étudier les voisinages</h2>
<p>Différences d’approche entre fonction K et méthode du plus proche voisin</p>
<!--Questions selon qu'on étudie un ou deux semis de points-->
<p>Fonctions:</p>
<p>linearK (plus court chemin) et linearKinhom (pcc et non homogène)</p>
<p>linearKEuclid (distance euclidienne), linearKEuclidInhom (distance euclidienne et non homogène)</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb51"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb51-1"><a href="#cb51-1" aria-hidden="true" tabindex="-1"></a>kth_neighbour <span class="ot"><-</span> <span class="fu">seq</span>(<span class="dv">1</span>, <span class="dv">20</span>, <span class="dv">1</span>)</span>
<span id="cb51-2"><a href="#cb51-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb51-3"><a href="#cb51-3" aria-hidden="true" tabindex="-1"></a>nndist <span class="ot"><-</span> <span class="fu">tibble</span>()</span>
<span id="cb51-4"><a href="#cb51-4" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> kth_neighbour) {</span>
<span id="cb51-5"><a href="#cb51-5" aria-hidden="true" tabindex="-1"></a> compute_nndist_bij <span class="ot"><-</span> <span class="fu">nndist.lpp</span>(<span class="at">X =</span> bijoutiers_lpp, <span class="at">k =</span> i)</span>
<span id="cb51-6"><a href="#cb51-6" aria-hidden="true" tabindex="-1"></a> compute_nndist_epi <span class="ot"><-</span> <span class="fu">nndist.lpp</span>(<span class="at">X =</span> epiciers_lpp, <span class="at">k =</span> i)</span>
<span id="cb51-7"><a href="#cb51-7" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb51-8"><a href="#cb51-8" aria-hidden="true" tabindex="-1"></a> nndist <span class="ot"><-</span> nndist <span class="sc">%>%</span></span>
<span id="cb51-9"><a href="#cb51-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">bind_rows</span>(<span class="fu">tibble</span>(<span class="at">type =</span> <span class="st">"bijoutiers"</span>, </span>
<span id="cb51-10"><a href="#cb51-10" aria-hidden="true" tabindex="-1"></a> <span class="at">ppv =</span> i,</span>
<span id="cb51-11"><a href="#cb51-11" aria-hidden="true" tabindex="-1"></a> <span class="at">dist =</span> compute_nndist_bij)) <span class="sc">%>%</span></span>
<span id="cb51-12"><a href="#cb51-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">bind_rows</span>(<span class="fu">tibble</span>(<span class="at">type =</span> <span class="st">"épiciers"</span>, </span>
<span id="cb51-13"><a href="#cb51-13" aria-hidden="true" tabindex="-1"></a> <span class="at">ppv =</span> i,</span>
<span id="cb51-14"><a href="#cb51-14" aria-hidden="true" tabindex="-1"></a> <span class="at">dist =</span> compute_nndist_epi))</span>
<span id="cb51-15"><a href="#cb51-15" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb51-16"><a href="#cb51-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb51-17"><a href="#cb51-17" aria-hidden="true" tabindex="-1"></a>nndist_summary <span class="ot"><-</span> nndist <span class="sc">%>%</span></span>
<span id="cb51-18"><a href="#cb51-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(type, ppv) <span class="sc">%>%</span></span>
<span id="cb51-19"><a href="#cb51-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">mean =</span> <span class="fu">mean</span>(dist), <span class="at">sd =</span> <span class="fu">sd</span>(dist))</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>`summarise()` has grouped output by 'type'. You can override using the
`.groups` argument.</code></pre>
</div>
<div class="sourceCode cell-code" id="cb53"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb53-1"><a href="#cb53-1" aria-hidden="true" tabindex="-1"></a>nndist_summary <span class="sc">%>%</span></span>
<span id="cb53-2"><a href="#cb53-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="at">mapping =</span> <span class="fu">aes</span>(<span class="at">x =</span> ppv, <span class="at">y =</span> mean, <span class="at">color =</span> type)) <span class="sc">+</span></span>
<span id="cb53-3"><a href="#cb53-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_errorbar</span>(<span class="fu">aes</span>(<span class="at">ymin =</span> mean <span class="sc">-</span> sd, <span class="at">ymax =</span> mean <span class="sc">+</span> sd), </span>
<span id="cb53-4"><a href="#cb53-4" aria-hidden="true" tabindex="-1"></a> <span class="at">width =</span> <span class="fl">0.1</span>, <span class="at">alpha =</span> <span class="fl">0.4</span>,</span>
<span id="cb53-5"><a href="#cb53-5" aria-hidden="true" tabindex="-1"></a> <span class="at">position =</span> <span class="fu">position_dodge</span>(<span class="fl">0.05</span>)) <span class="sc">+</span></span>
<span id="cb53-6"><a href="#cb53-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>() <span class="sc">+</span></span>
<span id="cb53-7"><a href="#cb53-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_line</span>() <span class="sc">+</span></span>
<span id="cb53-8"><a href="#cb53-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">xlab</span>(<span class="st">"Plus proche voisin"</span>) <span class="sc">+</span></span>
<span id="cb53-9"><a href="#cb53-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">ylab</span>(<span class="st">"Distance moyenne (en m.)"</span>) <span class="sc">+</span></span>
<span id="cb53-10"><a href="#cb53-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>()</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-23-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<!-- ## Analyser la relation entre deux semis de points - on vire
A évoquer dans la conclusion générale
::: {.cell}
```{.r .cell-code}
# étudier un semis par rapport à un autre
crossdist(epiciers_ppp, bijoutiers_ppp)[1:5, 1:5] # shortest-path distances between pairs of ‘things’ taken from two different datasets.
```
::: {.cell-output .cell-output-stdout}
```
[,1] [,2] [,3] [,4] [,5]
[1,] 1725.354 1189.305 1524.982 2715.270 1354.0494
[2,] 2198.302 680.736 1924.450 1321.922 243.2868
[3,] 3039.742 1575.508 2769.227 1735.172 1173.2468
[4,] 1721.839 1377.616 1569.930 1631.090 1569.6652
[5,] 4199.966 3024.996 3964.274 3468.329 2745.1090
```
:::
```{.r .cell-code}
nncross(epiciers_ppp, bijoutiers_ppp)[1:5,] # given two point patterns X and Y, finds the nearest neighbour in Y of each point of X.
```
::: {.cell-output .cell-output-stdout}
```
dist which
1 174.5787 257
2 105.8595 71
3 100.6455 122
4 248.2634 312
5 592.7533 163
```
:::
:::
Fonctions: linearKcross, linearKdot -->
</section>
<section id="rechercher-et-analyser-des-clusters-hot-spots" class="level2">
<h2 class="anchored" data-anchor-id="rechercher-et-analyser-des-clusters-hot-spots">Rechercher et analyser des clusters (hot spots)</h2>
<!-- différence hot spot - cluster ? à creuser... -->
<p>La recherche de clusters ou de hot spots, soit des zones du réseau où la densité de points est plus forte qu’attendue, suppose de comparer la répartion observée à une répartition homogène où la probabilité de chaque tronçon d’accueillir un sommet serait fonction de sa seule longueur. La fonction <code>intensity</code> renvoie ce résultat (nombre moyen de points par unité de longueur). La visualisation de certaines mesures est intégrée par défaut dans le <em>package</em> et c’est notamment le cas pour la densité (nombre de points par unité de mesure du réseau).</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb54"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb54-1"><a href="#cb54-1" aria-hidden="true" tabindex="-1"></a><span class="co"># calcul de la densité de points par unité de réseau</span></span>
<span id="cb54-2"><a href="#cb54-2" aria-hidden="true" tabindex="-1"></a><span class="co"># l'option finespacing n'est pas nécessaire pour un réseau de petite taille</span></span>
<span id="cb54-3"><a href="#cb54-3" aria-hidden="true" tabindex="-1"></a>densite_bij <span class="ot"><-</span> <span class="fu">density.lpp</span>(<span class="at">x =</span> bijoutiers_lpp, </span>
<span id="cb54-4"><a href="#cb54-4" aria-hidden="true" tabindex="-1"></a> <span class="at">finespacing =</span> <span class="cn">FALSE</span>, </span>
<span id="cb54-5"><a href="#cb54-5" aria-hidden="true" tabindex="-1"></a> <span class="at">distance =</span> <span class="st">"path"</span>)</span>
<span id="cb54-6"><a href="#cb54-6" aria-hidden="true" tabindex="-1"></a>densite_epic <span class="ot"><-</span> <span class="fu">density.lpp</span>(epiciers_lpp, </span>
<span id="cb54-7"><a href="#cb54-7" aria-hidden="true" tabindex="-1"></a> <span class="at">finespacing =</span> <span class="cn">FALSE</span>, </span>
<span id="cb54-8"><a href="#cb54-8" aria-hidden="true" tabindex="-1"></a> <span class="at">distance =</span> <span class="st">"path"</span>)</span>
<span id="cb54-9"><a href="#cb54-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb54-10"><a href="#cb54-10" aria-hidden="true" tabindex="-1"></a><span class="co"># option couleur (par défaut)</span></span>
<span id="cb54-11"><a href="#cb54-11" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(densite_epic)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-25-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
<div class="sourceCode cell-code" id="cb55"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb55-1"><a href="#cb55-1" aria-hidden="true" tabindex="-1"></a><span class="co"># option épaisseur des liens du réseau</span></span>
<span id="cb55-2"><a href="#cb55-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(<span class="at">x =</span> densite_bij, </span>
<span id="cb55-3"><a href="#cb55-3" aria-hidden="true" tabindex="-1"></a> <span class="at">main =</span> <span class="st">"Densité de bijoutiers"</span>,</span>
<span id="cb55-4"><a href="#cb55-4" aria-hidden="true" tabindex="-1"></a> <span class="at">style =</span> <span class="st">"width"</span>, </span>
<span id="cb55-5"><a href="#cb55-5" aria-hidden="true" tabindex="-1"></a> <span class="at">adjust =</span> <span class="fl">0.5</span>) <span class="co"># contrôler épaisseur max</span></span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-25-2.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Comme dans de nombreuses visualisations proposées ces dernières années et contrairement aux règles classiques de la sémiologie graphique, plus la teinte est claire et plus la densité est élevée.</p>
<!-- découper, pas au bon endroit - garder un test et l'expliquer et signaler les autres tests possibles -->
<p>Il est possible de tester la densité des points en fontion d’une variable spatiale. L’opposition socio-spatiale ouest-est étant une donnée ancienne de Paris, on pourrait par exemple tester la densité des bijoutiers en fonction des x. Différents tests statistiques permettent ensuite de vérifier si le lien entre la densité du semis et la variable considérée est statistiquement significatif. Le test utilisé ci-dessous se base sur l’article de Mark Berman <span class="citation" data-cites="berman1986">(<a href="#ref-berman1986" role="doc-biblioref">1986</a>)</span>. La valeur <span class="math inline">Z_1</span>, appelée aussi test de Lawson-Waller en épidémiologie, mesure l’écart entre le semis observé et un semis suivant une répartition de Poisson. <!--; il est avec la fonction `cdf.test` d'utiliser les tests de Kolmogorov-Smirnov, Cramer-von Mises ou Anderson-Darling.--></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb56"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb56-1"><a href="#cb56-1" aria-hidden="true" tabindex="-1"></a><span class="co"># bijoutiers plus présents à l'ouest ?</span></span>
<span id="cb56-2"><a href="#cb56-2" aria-hidden="true" tabindex="-1"></a><span class="co"># test de Berman</span></span>
<span id="cb56-3"><a href="#cb56-3" aria-hidden="true" tabindex="-1"></a>btB <span class="ot"><-</span> <span class="fu">berman.test</span>(bijoutiers_lpp, <span class="st">"x"</span>)</span>
<span id="cb56-4"><a href="#cb56-4" aria-hidden="true" tabindex="-1"></a>btB</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>
Berman Z1 test of CSR in linear network
data: covariate 'x' evaluated at points of 'bijoutiers_lpp'
Z1 = 0.013408, p-value = 0.9893
alternative hypothesis: two-sided</code></pre>
</div>
<div class="sourceCode cell-code" id="cb58"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb58-1"><a href="#cb58-1" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(btB)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="index_files/figure-html/unnamed-chunk-26-1.svg" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>Comparer la courbe en pointillé (distribution attendue si le semis homogène était fonction de la variation de x) et la courbe noire (distribution observée) montre une plus faible présence aux extremités de la zone observée ; inversement, les bijoutiers sont davantage présents au centre de l’espace considéré (cf la pente de la courbe pleine). Les traits verticaux indiquent la médiane, en pointillés pour la répartition uniforme, en trait plein pour la répartition observée.</p>
<p>Si l’on observe une relation claire - ce qui n’est pas le cas ici - entre la densité du semis de points et une variable spatiale, il est possible de modéliser la relation entre les deux et d’étudier la qualité du modèle retenu. Le script suivant est donné uniquement à des fins pédagogiques, les résultats précédents ne montrant pas de relation significative entre semis et variable considérée.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb59"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb59-1"><a href="#cb59-1" aria-hidden="true" tabindex="-1"></a><span class="co"># modéliser la relation entre présence de bijoutiers et axe ouest-est</span></span>
<span id="cb59-2"><a href="#cb59-2" aria-hidden="true" tabindex="-1"></a>fit <span class="ot"><-</span> <span class="fu">lppm</span>(bijoutiers_lpp <span class="sc">~</span> x)</span>
<span id="cb59-3"><a href="#cb59-3" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(fit)</span>
<span id="cb59-4"><a href="#cb59-4" aria-hidden="true" tabindex="-1"></a>lam <span class="ot"><-</span> <span class="fu">predict</span>(fit, <span class="at">dimyx=</span><span class="dv">512</span>)</span>
<span id="cb59-5"><a href="#cb59-5" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(lam)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<!-- à commenter quand j'aurai compris... à mettre après hot spot car logique répartition uniforme et non aléatoire-->
<p>Caractériser la répartition du semis de points peut se fait à une échelle plus fine, celle du tronçon. Dans le cas de commerces, on pourrait par exemple supposer qu’il est plus intéressant d’être à proximité des intersections (visibilité et accessibilité plus grandes).</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb60"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb60-1"><a href="#cb60-1" aria-hidden="true" tabindex="-1"></a><span class="co"># épiciers davantage présents à proximité des intersections ?</span></span>
<span id="cb60-2"><a href="#cb60-2" aria-hidden="true" tabindex="-1"></a><span class="co"># création du objet linfun (fonction d'un réseau linéaire)</span></span>
<span id="cb60-3"><a href="#cb60-3" aria-hidden="true" tabindex="-1"></a>alongE <span class="ot"><-</span> <span class="fu">linfun</span>(<span class="cf">function</span>(x,y,seg,tp) { tp }, </span>
<span id="cb60-4"><a href="#cb60-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">domain</span>(epiciers_lpp))</span>
<span id="cb60-5"><a href="#cb60-5" aria-hidden="true" tabindex="-1"></a><span class="co"># relation entre semis de point et fonction</span></span>
<span id="cb60-6"><a href="#cb60-6" aria-hidden="true" tabindex="-1"></a>rhoalongE <span class="ot"><-</span> <span class="fu">rhohat</span>(epiciers_lpp, alongE)</span>
<span id="cb60-7"><a href="#cb60-7" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(rhoalongE)</span></code><button title="Copier vers le presse-papier" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">