R|记一次R的可视化使用-生成城市各个景点的多边形图

项目中需要用到全国各个城市的景点坐标范围,需要人工审核各个景点的数据正确性和各个景点之间的距离分布。首先想到的就是使用R绘制每个景点的多边形区域。


首先通过python,根据数据生成R绘图代码,当然这里的R绘图代码非常简单,利用原始数据拼接成R代码才是耗费工作量最大的工作,具体过程比较繁琐,此处略去。
生成的R绘图代码示例如下:

pdf("嘉兴.png"); png(file="嘉兴.png") pdf(file="嘉兴.pdf", family="GB1"); plot(c(120.89517631, 120.480760131), c(30.9493649491, 30.7446859019), type='n', main='嘉兴'); text(120.89517631020124, 30.94572968975392, '西塘'); polygon(c(120.89517631020124,120.89497868298903,120.89494275076864,120.89489783549314,120.89469930997544,120.89452953023405,120.89449359801365,120.89443430985,120.89440376746265,120.8944253267949,120.8943992759351,120.89420164872291,120.89412529275457,120.8941836826127,120.89417829277966,120.89412080122702,120.89390071637706,120.89368512305467,120.89360876708632,120.89372554680263,120.89404893678622,120.89425105552596,120.8944253267949,120.89517631020124), c(30.94572968975392,30.946999529964174,30.947270530241386,30.947351830173172,30.947371187289498,30.94818805398829,30.94865649095114,30.948718432855237,30.948935229200234,30.949082340722832,30.949364949058623,30.9492759081672,30.94911718289205,30.94865649095114,30.948153211476896,30.947429258614697,30.94696081557549,30.946573670817415,30.94606263731114,30.945931007021578,30.94584970586889,30.945590316010005,30.945567087032728,30.94572968975392)); text(120.48346295259601, 30.75858194713455, '乌镇'); polygon(c(120.48346295259601,120.48510712117094,120.48604198771515,120.48715588654753,120.48798205812506,120.48986805054325,120.49139588855462,120.49308398426898,120.4968931589535,120.49912113627934,120.50124086779124,120.50138486616449,120.50136681022373,120.50106084736703,120.50069685397439,120.50010900284866,120.49961116193504,120.5006799658308,120.50136213903508,120.50233203949419,120.5032349263623,120.50410215050161,120.50713402142834,120.50597987850912,120.50573688686868,120.50406217590643,120.50336086879479,120.50264195489514,120.50200514611913,120.50138486616449,120.49964206364457,120.49864485469796,120.49786296958206,120.4982769985916,120.49883313953283,120.4984828902145,120.49706410649203,120.49546503285373,120.49247304669164,120.48988610648402,120.48977013524268,120.48999408280632,120.49079402386293,120.48800002423526,120.4847662142299,120.48158594323291,120.48090305138425,120.4807601309776,120.480796063198,120.48105603281259,120.48129902445302,120.4825381470735,120.48346295259601), c(30.75858194713455,30.758845804981686,30.7591249457726,30.759791916720214,30.75994684695632,30.75976080651225,30.759357924522806,30.758472943606083,30.756719870448315,30.755648816569746,30.754531897440422,30.754329941299538,30.75394185534379,30.753278800393474,30.752355900295903,30.751001831794046,30.74991884246953,30.7495818702917,30.7493649287891,30.74930983984541,30.749333815178336,30.7490928977239,30.74812681649693,30.74541481567451,30.744685901868714,30.74503895321551,30.74503895321551,30.74500783819329,30.745108787393026,30.745310918251928,30.74576088095575,30.746225894500856,30.746683922478915,30.74711083392101,30.74818881172298,30.74832894095901,30.748650864985432,30.749146900529908,30.750101876132877,30.75104093649442,30.751257874183796,30.75185491581261,30.753670768375148,30.754469828752693,30.755346855561772,30.756075920627406,30.75636290554877,30.756828875981466,30.757270948389028,30.757844832589257,30.75832584683198,30.758395904026447,30.75858194713455)); dev.off();


最终可视化结果: R|记一次R的可视化使用-生成城市各个景点的多边形图
文章图片


【R|记一次R的可视化使用-生成城市各个景点的多边形图】

    推荐阅读