-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.py
26 lines (20 loc) · 10.4 KB
/
script.py
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
import folium
from shapely.geometry import Polygon
border = "SRID=4326;POLYGON((101.3260618 0.5985796,101.3277795 0.5965827,101.3298946 0.5965818000000001,101.3306874 0.595783,101.3305543 0.5936538,101.3287024 0.5907269000000001,101.3302881 0.5892624,101.335046 0.586865,101.3378221 0.5868638,101.340069 0.5860644,101.3412578 0.5836686,101.3390106 0.5839356,101.3372912 0.5816741,101.3388769 0.5803426,101.3423135 0.5794097,101.342445 0.5776796,101.3450874 0.5740855,101.3470703 0.5740847,101.3489207 0.5734185000000001,101.3494483 0.5706237,101.3540733 0.5664965,101.3557918 0.5664958,101.3561886 0.567161,101.3559252 0.5695565,101.3572472 0.569689,101.3588333 0.5692891,101.3597581 0.567958,101.3610783 0.5638322,101.3646472 0.5632984,101.3673501 0.5603384,101.3688874 0.5593712,101.3693055 0.5593711,101.3693987 0.5599323,101.3680525 0.563254,101.3680066 0.5646573,101.3683323 0.5655459,101.3694012 0.5661068,101.370191 0.5657791,101.3725599 0.5637667,101.3720464 0.5578263,101.3723247 0.5565632,101.3736718 0.5556272,101.3747941 0.554186,101.373639 0.5532964,101.3733607 0.552242,101.3734811 0.5501624000000001,101.3729887 0.5491655,101.3726981 0.5487012999999999,101.3719273 0.5487578,101.3719071 0.5481484,101.3712775 0.5479385,101.3706579 0.5472948,101.3708355 0.54698,101.3704824 0.5462273,101.3711584 0.545083,101.3710474 0.5443545,101.3702878 0.54361,101.3691076 0.5431987,101.3677773 0.5421522,101.3671173 0.5412455,101.3668274 0.5396602,101.3656884 0.5378796,101.3653327 0.5367879,101.3649317 0.5364445,101.3629455 0.5360712,101.3629854 0.4989439,101.3594052 0.4976479,101.3587591 0.4996103,101.3590966 0.500374,101.3585333 0.5015802,101.3560615 0.5006297,101.3553866 0.4994417,101.3553863 0.4988476,101.3525729 0.4971089,101.3508324 0.4947077,101.3499866 0.4926064,101.3496877 0.4905549,101.3495357 0.4822486,101.3502307 0.4795963,101.3514227 0.4768939,101.3539067 0.4732402,101.3550495 0.472189,101.3572417 0.4713625,101.3628656 0.4319545,101.3656083 0.432896,101.3670116 0.4339473,101.3701069 0.4353911,101.3703234 0.4353911,101.3704498 0.4339743,101.37313 0.4346963,101.3732112 0.4343263,101.3757199 0.4345609,101.3758011 0.4333968,101.3812202 0.4343669,101.3830793 0.434162,101.386388 0.4328861,101.389023 0.4327825,101.3907185 0.4332138,101.3912091 0.4344269,101.3915564 0.434509,101.3918448 0.4363071,101.395537 0.4339135,101.3980337 0.4327865,101.4026091 0.4315879,101.4029914 0.4325277,101.403748 0.4322888,101.4047276 0.4316676,101.40908 0.4301106,101.4140695 0.4272156,101.4186409 0.4262042,101.4206717 0.4252803,101.4219659 0.4241295,101.4272689 0.4220222,101.4284036 0.4217002,101.4287217 0.4226777,101.429774 0.4222962,101.4308577 0.4211352,101.4322484 0.4210753,101.4323423 0.4220356,101.4316561 0.4233849,101.4307992 0.4236616,101.4308703 0.4260029,101.4305482 0.4270893,101.4308211 0.4276405,101.4311774 0.4276739,101.4323656 0.4263036,101.4375351 0.4239036,101.4368096 0.4224583,101.4391962 0.4211723,101.4395694 0.4198612,101.4441882 0.4174176,101.4458587 0.4175293,101.4474436 0.416975,101.4487818 0.4195283,101.4452954 0.4214828,101.4469329 0.4227154,101.4465103 0.4243177,101.4468273 0.4244058,101.4471794 0.4254622,101.4468713 0.425788,101.4472411 0.4263691,101.4471706 0.427091,101.4481215 0.4278834,101.44822 0.4296027,101.4486669 0.4304794,101.4472082 0.4314578,101.4472494 0.4321323,101.4482139 0.4336869,101.4499372 0.4338325,101.450559 0.4345442,101.4511736 0.4358292,101.4512222 0.436751,101.4508986 0.4374106,101.4510777 0.4386657,101.4515981 0.4398054,101.4520807 0.4395488,101.4536163 0.4426648,101.4549436 0.4422457,101.4546536 0.4416241,101.4560926 0.4407868,101.4562136 0.4409868,101.4581539 0.4407912,101.4587907 0.4404846,101.4590189 0.441111,101.4593561 0.4411205,101.4593132 0.4406805,101.4608663 0.4403505,101.4617403 0.4397903,101.4632034 0.4400863,101.463405 0.4416671,101.4652633 0.4418476,101.4650152 0.4425162,101.4664478 0.4441957,101.4674972 0.4437647,101.4699555 0.446511,101.4710388 0.4471515,101.47155 0.4483822,101.475525 0.4531705,101.4769723 0.4559501,101.4856011 0.452859,101.4959315 0.4463049,101.4998878 0.4456452,101.5054333 0.4460652,101.5068354 0.4446527,101.510188 0.4428339,101.5158624 0.4425723,101.5158619 0.4410143,101.5212773 0.4373772,101.5248879 0.4360777,101.5259198 0.4365966,101.5264362 0.4381544,101.5274678 0.4378944,101.527467 0.4355575,101.5290141 0.433999,101.5367517 0.4332174,101.539331 0.4332165,101.5398467 0.432697,101.5457792 0.4332143,101.5517113 0.432693,101.5543193 0.4315313,101.5558507 0.429641,101.5569502 0.4267733,101.5586548 0.4268162,101.5607906 0.4254904,101.5671342 0.4252276,101.5678901 0.4272692,101.5681065 0.4292024,101.5665535 0.4308104,101.5670724 0.4339816,101.5687773 0.4349151,101.5699646 0.4364135,101.5701141 0.4403605,101.5668046 0.4473527,101.5695836 0.4507934,101.5710802 0.4533742,101.5741474 0.454135,101.5707576 0.4609396,101.5691244 0.4686608,101.5703522 0.4707192,101.5721933 0.4722626,101.5743057 0.4728016,101.5771018 0.4728784,101.5810895 0.4720534,101.5856908 0.4718458,101.5885548 0.4741094,101.5850925 0.4859634,101.5839092 0.4891205,101.5799398 0.4955055,101.5798706 0.4967332,101.5815882 0.4996076,101.58243 0.5015968,101.5820693 0.5069039,101.5850501 0.5107984,101.5880791 0.5167006,101.5892163 0.5208559,101.5892896 0.5243255999999999,101.5889311 0.5256269,101.588932 0.52794,101.5905843 0.5298187,101.5920849 0.5305796,101.5928814 0.5318813999999999,101.5925795 0.5336775,101.5919186 0.5348214,101.5899247 0.5378311,101.5883831 0.5392869,101.5883728 0.5406474999999999,101.5887041 0.5412186,101.5883521 0.542306,101.5877051 0.5428811,101.5865849 0.542986,101.5851577 0.5422675,101.5807594 0.5419362,101.5785841 0.5424608,101.5775914 0.5433658,101.5766937 0.5455086,101.5764579 0.5469368999999999,101.575912 0.5481182999999999,101.5761586 0.5491478,101.5757887 0.5506271,101.5760846 0.5513915,101.5777859 0.5534873,101.5794132 0.5568899,101.5810899 0.5577529,101.5819603 0.5586679,101.5805681 0.5652225,101.5799504 0.5709984,101.5819667 0.5722463,101.5836734 0.5744309,101.5852241 0.5747424,101.5860007 0.5775517999999999,101.5846075 0.5827036,101.5844535 0.5850452,101.5818155 0.5881687,101.5818198 0.5900416000000001,101.580425 0.5917593,101.5790309 0.5948819,101.5785011 0.5970922,101.5820912 0.5967291,101.5844504 0.5953221,101.5858956 0.5954289,101.5881108 0.5968254,101.5903512 0.600612,101.5910723 0.6029674,101.5914341 0.6065915,101.5898145 0.6077701,101.5880627 0.6098279,101.5862809 0.6103575999999999,101.5850288 0.6103575999999999,101.5840564 0.6121220000000001,101.5830663 0.6121224,101.5821667 0.6129383,101.5808165 0.6127578,101.580367 0.6137546,101.5793773 0.6145706,101.5781763 0.6146809,101.5758499 0.6172752,101.5737099 0.620644,101.5732838 0.6226048,101.5721656 0.6234443,101.5713098 0.6248044,101.5714586 0.6262949,101.5725224 0.6272295,101.5736834 0.6295473,101.574267 0.6315671,101.5742018 0.6328874,101.5727286 0.6364845,101.5710407 0.639031,101.5692193 0.6403078,101.5666295 0.6410291,101.5638193 0.6409448,101.559895 0.6379823999999999,101.5584172 0.637595,101.5527588 0.6370898,101.549801 0.6384301,101.5472128 0.6405099,101.5459034 0.6422405,101.544436 0.6478995,101.5444555 0.6498453,101.5436236 0.6513171,101.5417363 0.6535671,101.541 0.6550925,101.5402844 0.6580072,101.5187521 0.6569896,101.4981569 0.6595159,101.4971067 0.6587332,101.4969352 0.6580216,101.4972141 0.6569955,101.4960716 0.6558869000000001,101.4953129 0.6554613,101.4943085 0.655545,101.4919925 0.6544351,101.4911223 0.6536912,101.4901695 0.652129,101.4890777 0.6512722,101.4884763 0.6521813,101.4874231 0.6525769,101.4857672 0.6543957,101.4842915 0.6548845,101.4841718 0.6557517,101.4850545 0.6583125,101.4844949 0.6596727,101.4571015 0.6618243,101.4407356 0.6659771,101.4346656 0.6691305,101.4291565 0.6725148,101.4264044 0.6747064,101.4230757 0.6783616,101.4178139 0.6849353,101.4149974 0.6828225,101.4113134 0.6835256,101.4071516 0.6882651,101.4014708 0.6890939,101.3972698 0.692421,101.3920284 0.6903921,101.3863124 0.6865295,101.3822402 0.6812182,101.3808288 0.6756556,101.3776373 0.6704366,101.3781908 0.6625821,101.3799391 0.6622638,101.3803808 0.6617352,101.380289 0.661041,101.3808381 0.6608073,101.3808927 0.6602667,101.3805567 0.6595235,101.3809307 0.6593532,101.380824 0.658807,101.3811221 0.6592995,101.3813562 0.6592351,101.3815259 0.658164,101.381249 0.6575323,101.3807171 0.6576932,101.3808125 0.6569863,101.3804931 0.6565902,101.3806737 0.6559689,101.379961 0.6561834,101.3801734 0.6553801,101.3797584 0.6552839,101.3796199 0.6548341,101.3792749 0.655462,101.378932 0.6548713,101.3781457 0.654826,101.3779638 0.653928,101.3773362 0.6538598,101.3769353 0.6534794,101.3774335 0.6517285,101.3771005 0.6511806,101.3774481 0.6507617999999999,101.3773894 0.6487911,101.3762275 0.6465943,101.3763167 0.6462217,101.3752736 0.6447678999999999,101.3737344 0.6438547999999999,101.3699442 0.6399745,101.367202 0.6390101,101.3666146 0.637913,101.3656918 0.6369849,101.3634274 0.6363951,101.3622529 0.6351294,101.3586462 0.6330207,101.3581425 0.6316703,101.356549 0.6309958,101.354871 0.6288862,101.3533613 0.628296,101.3522705 0.6266926,101.3495036 0.6248375,101.3477044 0.623071,101.3477043 0.6227134,101.347026 0.6223887,101.3468643 0.6217386,101.347367 0.6214969,101.3467024 0.620796,101.3440221 0.6203096,101.3435375 0.6196922,101.3418579 0.6187178,101.3420191 0.6181976,101.3409535 0.6181331,101.3412181 0.6184962000000001,101.3403398 0.6176457,101.3397909 0.6176785,101.3392739 0.6169311,101.337982 0.616379,101.3378849 0.6158915,101.3370775 0.6154042,101.3360441 0.6152747,101.3348488 0.614105,101.3335246 0.6133254,101.3318392 0.6108506,101.331385 0.6108508,101.3308735 0.6094794,101.329565 0.6087375,101.3279157 0.6060311,101.3280474 0.6049664,101.3295019 0.6057643,101.3312201 0.6049651,101.3308229 0.6036345,101.3324091 0.6032345,101.3321436 0.6007062,101.3298961 0.6001749,101.3279132 0.6001757,101.3260618 0.5985796))"
# Convert the border to a list of coordinates
coordinates = []
border_points = border.replace("SRID=4326;POLYGON((", "").replace("))", "").split(",")
for point in border_points:
lat, lon = point.split(" ")
coordinates.append((float(lat), float(lon)))
print(coordinates)
# Initialize the map centered around the average coordinates of the polygon
map_center = [sum([coord[1] for coord in coordinates]) / len(coordinates),
sum([coord[0] for coord in coordinates]) / len(coordinates)]
map_ = folium.Map(location=map_center, zoom_start=10)
# Add the polygon to the map
folium.Polygon(locations=[(a,b) for (b,a) in coordinates],
color='blue', fill=True, fill_opacity=0.2).add_to(map_)
# Save the map to an HTML file
map_.save('polygon_map.html')
map_