0

I am using python, and I have a text file that contains the metadata of the area that I intend to use. Here is a sample:

{ "type": "Feature", "id": 10, "properties": { "circo_id": 220.0, "circo_na_1": "Jendouba" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 8.93042, 36.826946000000135 ], [ 8.930019, 36.820381 ], [ 8.929707, 36.813044000000104 ], [ 8.929579, 36.81000900000015 ], [ 8.925296, 36.800781 ], [ 8.925087, 36.798068 ], [ 8.92489, 36.795511000000147 ], [ 8.924849, 36.794975 ], [ 8.924617, 36.791961 ], [ 8.92791, 36.786500000000103 ], [ 8.94451, 36.784920000000113 ], [ 8.953495, 36.785014000000103 ], [ 8.963627, 36.785119 ], [ 8.978325, 36.783161 ], [ 8.995327000000145, 36.782618 ], [ 9.008783000000108, 36.778728000000115 ], [ 9.019933, 36.772889000000134 ], [ 9.02058, 36.772046 ], [ 9.022671, 36.76932 ], [ 9.02646, 36.76439 ], [ 9.031497, 36.754985 ], [ 9.033054000000106, 36.752078 ], [ 9.035473, 36.747559 ], [ 9.039081, 36.740821000000153 ], [ 9.039726, 36.739617 ], [ 9.04513500000013, 36.729512 ], [ 9.03746, 36.71935 ], [ 9.035804, 36.71577 ], [ 9.031620000000146, 36.70673 ], [ 9.02867, 36.70037 ], [ 9.024459, 36.687168 ], [ 9.02488, 36.682406 ], [ 9.025526, 36.675109 ], [ 9.026045, 36.673998 ], [ 9.027963, 36.669891000000121 ], [ 9.031041, 36.663299 ], [ 9.03759, 36.653061 ], [ 9.039488, 36.651221 ], [ 9.044067, 36.646782000000144 ], [ 9.047731, 36.643231000000128 ], [ 9.061971000000142, 36.629342 ], [ 9.073415, 36.61745900000011 ], [ 9.078124000000116, 36.609460000000126 ], [ 9.078296000000137, 36.609168000000125 ], [ 9.079749000000106, 36.606701000000101 ], [ 9.080025, 36.602885 ], [ 9.080585000000156, 36.59515 ], [ 9.07971700000013, 36.584081 ], [ 9.079463, 36.57542 ], [ 9.07932, 36.570438000000138 ], [ 9.078685, 36.567225 ], [ 9.07737, 36.560558000000128 ], [ 9.076425, 36.559185 ], [ 9.071587000000136, 36.55217 ], [ 9.063895, 36.543911000000151 ], [ 9.056668000000116, 36.53342 ], [ 9.053021, 36.524021 ], [ 9.052577, 36.513309 ], [ 9.050658, 36.502059000000145 ], [ 9.051683000000139, 36.492061000000149 ], [ 9.051669, 36.489231000000132 ], [ 9.051641, 36.483813 ], [ 9.051635, 36.482730000000117 ], [ 9.0360510000001, 36.47847 ], [ 9.030476000000135, 36.477415 ], [ 9.015807, 36.474639000000138 ], [ 9.001007, 36.47401 ], [ 8.978619, 36.471858000000111 ], [ 8.959619, 36.47010900000015 ], [ 8.95616, 36.46979 ], [ 8.953101000000117, 36.46951 ], [ 8.940754, 36.468371 ], [ 8.935953, 36.467929 ], [ 8.924223, 36.461830000000134 ], [ 8.923325, 36.460941000000105 ], [ 8.906790000000115, 36.44456 ], [ 8.903001000000131, 36.441439000000116 ], [ 8.899713, 36.438729 ], [ 8.886922, 36.433120000000145 ], [ 8.875766, 36.4304810000001 ], [ 8.875232, 36.430484 ], [ 8.862442000000158, 36.43056 ], [ 8.853001, 36.430639 ], [ 8.850386, 36.4306610000001 ], [ 8.833791, 36.425141 ], [ 8.820677, 36.425389 ], [ 8.794968, 36.421059 ], [ 8.776642, 36.417752000000121 ], [ 8.76059, 36.41689 ], [ 8.756615, 36.415932 ], [ 8.743341, 36.412731 ], [ 8.725819000000115, 36.411500000000103 ], [ 8.713947000000132, 36.412972 ], [ 8.698307, 36.419378 ], [ 8.69752, 36.4197 ], [ 8.685227, 36.42279 ], [ 8.678392000000144, 36.424508000000117 ], [ 8.676041000000112, 36.4251 ], [ 8.659779, 36.427669000000151 ], [ 8.659697, 36.427682 ], [ 8.64593, 36.422355 ], [ 8.62156, 36.412924000000146 ], [ 8.617570000000114, 36.411381 ], [ 8.61493, 36.4106 ], [ 8.603712000000144, 36.407279 ], [ 8.596174000000133, 36.407107 ], [ 8.590188, 36.406971 ], [ 8.589647, 36.407075 ], [ 8.577233, 36.409451 ], [ 8.566009, 36.410228 ], [ 8.558123, 36.409943 ], [ 8.556655, 36.409890000000132 ], [ 8.553334, 36.409770000000151 ], [ 8.543514, 36.404881000000103 ], [ 8.541066, 36.402785 ], [ 8.536681000000101, 36.39903 ], [ 8.529207, 36.393331000000103 ], [ 8.528801, 36.393036 ], [ 8.522419, 36.388401 ], [ 8.521110000000135, 36.387451 ], [ 8.502475, 36.385446 ], [ 8.50066, 36.385251 ], [ 8.496887, 36.384418 ], [ 8.484894, 36.381771 ], [ 8.471778, 36.373871 ], [ 8.465563000000145, 36.36889 ], [ 8.461157, 36.366352 ], [ 8.45119, 36.360611 ], [ 8.431706000000133, 36.362389 ], [ 8.420807, 36.36334 ], [ 8.41307, 36.364021 ], [ 8.392758, 36.366106000000116 ], [ 8.39344, 36.366557000000114 ], [ 8.39402, 36.369281000000115 ], [ 8.396842, 36.371528 ], [ 8.399187, 36.374293 ], [ 8.39916600000015, 36.376983 ], [ 8.397526, 36.380691 ], [ 8.396755000000155, 36.38248300000015 ], [ 8.397395, 36.384822 ], [ 8.398968000000139, 36.387092000000109 ], [ 8.400333000000103, 36.39067 ], [ 8.400833, 36.394065000000126 ], [ 8.399076, 36.39555300000012 ], [ 8.39675300000016, 36.396560000000136 ], [ 8.397312, 36.39917 ], [ 8.398886, 36.40132 ], [ 8.40174, 36.402965 ], [ 8.40437, 36.405578 ], [ 8.406344, 36.407725 ], [ 8.408125000000155, 36.408858 ], [ 8.410155, 36.410468000000151 ], [ 8.409249000000102, 36.41258 ], [ 8.408973, 36.415946 ], [ 8.408925, 36.418250000000114 ], [ 8.40853, 36.419749000000138 ], [ 8.408088000000134, 36.421428 ], [ 8.405796, 36.422423 ], [ 8.405252000000132, 36.422446 ], [ 8.402253000000144, 36.42257 ], [ 8.40009300000014, 36.422870000000103 ], [ 8.397684, 36.423037 ], [ 8.39474, 36.423175000000128 ], [ 8.392333, 36.423503 ], [ 8.390077, 36.424064 ], [ 8.386363, 36.424197000000106 ], [ 8.384169, 36.424716 ], [ 8.381518000000142, 36.425384000000122 ], [ 8.375307000000134, 36.427279 ], [ 8.372994, 36.428374 ], [ 8.370803000000137, 36.42982400000011 ], [ 8.369102000000112, 36.431395 ], [ 8.366798, 36.435429 ], [ 8.366435, 36.436065 ], [ 8.363801, 36.438617 ], [ 8.361654, 36.440211000000147 ], [ 8.35692, 36.44469 ], [ 8.354304000000127, 36.445357000000115 ], [ 8.35213, 36.443595 ], [ 8.350618, 36.441780000000108 ], [ 8.34952, 36.440459 ], [ 8.34813800000012, 36.438537 ], [ 8.345749, 36.436168000000123 ], [ 8.343541, 36.434401 ], [ 8.339808000000119, 36.433593 ], [ 8.337683, 36.43325700000014 ], [ 8.333628, 36.432193 ], [ 8.331063, 36.431254000000138 ], [ 8.328215, 36.431342000000143 ], [ 8.326268, 36.432033000000104 ], [ 8.32685, 36.433694 ], [ 8.326961000000153, 36.43401 ], [ 8.327082, 36.434356 ], [ 8.323971, 36.435931 ], [ 8.322243, 36.433371000000136 ], [ 8.32223, 36.433351 ], [ 8.321863, 36.432807 ], [ 8.319858, 36.429530000000113 ], [ 8.317251, 36.426433 ], [ 8.316660000000127, 36.432662000000107 ], [ 8.314462, 36.433188 ], [ 8.314427, 36.433196 ], [ 8.31181, 36.433383 ], [ 8.310419000000138, 36.433375000000126 ], [ 8.309212000000116, 36.433368 ], [ 8.30932, 36.433656 ], [ 8.310168000000147, 36.436019 ], [ 8.311114, 36.436727 ], [ 8.312207000000114, 36.437545 ], [ 8.308790000000158, 36.441745 ], [ 8.305871, 36.441516 ], [ 8.304222, 36.441386 ], [ 8.30224, 36.442756 ], [ 8.297972, 36.443374 ], [ 8.297594, 36.443301 ], [ 8.293162000000109, 36.442435000000103 ], [ 8.290802, 36.442779000000144 ], [ 8.288183, 36.443725 ], [ 8.28702200000015, 36.44465 ], [ 8.28657, 36.44501 ], [ 8.284594000000141, 36.44588 ], [ 8.281097000000159, 36.444659000000115 ], [ 8.280138, 36.444429 ], [ 8.278481, 36.444030000000112 ], [ 8.275392000000124, 36.443171 ], [ 8.272461, 36.4416 ], [ 8.268987, 36.440837 ], [ 8.26679, 36.440429 ], [ 8.264100000000155, 36.439097 ], [ 8.26202, 36.438540000000103 ], [ 8.259677000000124, 36.44088 ], [ 8.258065000000158, 36.442214000000149 ], [ 8.25522, 36.443627 ], [ 8.254641, 36.443912000000125 ], [ 8.252892, 36.444903 ], [ 8.252034000000151, 36.445388 ], [ 8.249614000000122, 36.446189 ], [ 8.245532, 36.446692 ], [ 8.244319, 36.446493000000146 ], [ 8.240908, 36.445933 ], [ 8.238179, 36.445517 ], [ 8.235629, 36.44564 ], [ 8.227342, 36.447097 ], [ 8.22493, 36.447486 ], [ 8.221072, 36.447631 ], [ 8.21751, 36.447204 ], [ 8.21532, 36.447016 ], [ 8.213220000000149, 36.446834000000138 ], [ 8.210838, 36.447112 ], [ 8.208119000000124, 36.44802 ], [ 8.207494000000111, 36.448297 ], [ 8.205551000000128, 36.449157000000127 ], [ 8.203340000000139, 36.450568000000146 ], [ 8.199827, 36.454287 ], [ 8.19795, 36.457126 ], [ 8.196959000000106, 36.459018000000128 ], [ 8.196723000000134, 36.459468 ], [ 8.195989, 36.459831 ], [ 8.193602, 36.461009 ], [ 8.18973, 36.46081 ], [ 8.185459, 36.460265000000106 ], [ 8.180586, 36.460026 ], [ 8.177576, 36.46001 ], [ 8.175118, 36.4601 ], [ 8.171526, 36.461491000000137 ], [ 8.169378000000108, 36.462822000000131 ], [ 8.166587000000106, 36.46581 ], [ 8.1667, 36.466068000000121 ], [ 8.166917, 36.467445 ], [ 8.16696, 36.468189000000109 ], [ 8.1669, 36.468418 ], [ 8.167065, 36.468647000000146 ], [ 8.166344, 36.468937000000153 ], [ 8.166, 36.469337 ], [ 8.165731, 36.469795 ], [ 8.165199, 36.470596000000114 ], [ 8.164825, 36.47105 ], [ 8.164603000000113, 36.471401000000128 ], [ 8.164477000000147, 36.471916 ], [ 8.164425000000108, 36.472374 ], [ 8.164425000000108, 36.472832 ], [ 8.164401, 36.47323200000011 ], [ 8.164315, 36.473576000000151 ], [ 8.16415000000012, 36.473862 ], [ 8.163858000000118, 36.474209 ], [ 8.163422, 36.474548 ], [ 8.163060000000144, 36.474895 ], [ 8.162769, 36.475239 ], [ 8.161829, 36.476212 ], [ 8.161566, 36.476559 ], [ 8.161318, 36.476845 ], [ 8.161142, 36.477184 ], [ 8.160873, 36.477531 ], [ 8.160678, 36.477928000000134 ], [ 8.160581, 36.478218 ], [ 8.160484, 36.478733000000148 ], [ 8.160443000000157, 36.479134000000101 ], [ 8.16038, 36.48017 ], [ 8.16038, 36.480682000000115 ], [ 8.160431, 36.481083 ], [ 8.161026, 36.482628 ], [ 8.161211, 36.483047 ], [ 8.161354, 36.483372 ], [ 8.161468, 36.483948 ], [ 8.161519, 36.484406 ], [ 8.161456000000101, 36.484921 ], [ 8.161245, 36.485493 ], [ 8.161056, 36.485893000000146 ], [ 8.161176, 36.486355 ], [ 8.16142, 36.48687 ], [ 8.16156500000011, 36.487385000000131 ], [ 8.161721, 36.487728000000118 ], [ 8.161794, 36.48819 ], [ 8.161566, 36.489044 ], [ 8.161342000000104, 36.490017000000137 ], [ 8.16117, 36.490593 ], [ 8.16098600000015, 36.490993 ], [ 8.16046, 36.491398 ], [ 8.160008, 36.49168 ], [ 8.158947, 36.492138000000125 ], [ 8.158408, 36.492428000000132 ], [ 8.157704, 36.49271 ], [ 8.157119, 36.492886 ], [ 8.157005, 36.492873 ], [ 8.156558, 36.492825 ], [ 8.155735, 36.492908 ], [ 8.155395000000112, 36.492943000000139 ], [ 8.154386000000102, 36.493172 ], [ 8.153980000000104, 36.493343000000152 ], [ 8.153710000000103, 36.49392 ], [ 8.153515, 36.49437300000011 ], [ 8.153012000000103, 36.495178000000124 ], [ 8.152891, 36.495579 ], [ 8.153218, 36.49604 ], [ 8.153612, 36.496323 ], [ 8.154014, 36.496552000000122 ], [ 8.15437, 36.49678 ], [ 8.154896, 36.497066 ], [ 8.155320000000131, 36.497467000000142 ], [ 8.155349, 36.49775 ], [ 8.155229, 36.49816 ], [ 8.155132, 36.498558 ], [ 8.155096, 36.498787000000107 ], [ 8.155135, 36.498823 ], [ 8.155333, 36.499012000000107 ], [ 8.155618, 36.499187 ], [ 8.155991, 36.499302000000114 ], [ 8.156443000000138, 36.49941600000011 ], [ 8.15689, 36.499531 ], [ 8.15767, 36.49941600000011 ], [ 8.15831, 36.499187 ], [ 8.15938, 36.498959000000127 ], [ 8.159915, 36.498726 ], [ 8.160403, 36.498558 ], [ 8.160981000000106, 36.4984970000001 ], [ 8.161428000000114, 36.498501 ], [ 8.16205, 36.498615 ], [ 8.162608, 36.4989 ], [ 8.162986, 36.49913 ], [ 8.163445, 36.499359 ], [ 8.163949, 36.499760000000151 ], [ 8.164671, 36.50027 ], [ 8.164900000000159, 36.50039 ], [ 8.165427, 36.500332 ], [ 8.166763000000117, 36.50045 ], [ 8.16737, 36.500618 ], [ 8.167632, 36.500718 ], [ 8.167816, 36.500790000000109 ], [ 8.168354000000136, 36.501194 ], [ 8.169164, 36.501938 ], [ 8.17039, 36.5028 ], [ 8.170883000000117, 36.503086 ], [ 8.172057000000109, 36.50394 ], [ 8.172544, 36.504059 ], [ 8.172933000000114, 36.504574 ], [ 8.173307000000136, 36.505032 ], [ 8.173787, 36.505893000000128 ], [ 8.173817, 36.50658 ], [ 8.173853, 36.506737 ], [ 8.17393600000014, 36.507095000000106 ], [ 8.17392, 36.507496 ], [ 8.174183000000141, 36.50927 ], [ 8.174418, 36.50961 ], [ 8.17477300000013, 36.509903 ], [ 8.175529000000154, 36.510188 ], [ 8.175724000000116, 36.510474 ], [ 8.175867, 36.510932000000139 ], [ 8.175867, 36.51133 ], [ 8.175896000000137, 36.51179500000012 ], [ 8.175793000000112, 36.51208 ], [ 8.175885000000108, 36.512423 ], [ 8.176113000000157, 36.512768 ], [ 8.17656600000015, 36.513164 ], [ 8.177311000000145, 36.51334 ], [ 8.178479000000152, 36.513511 ], [ 8.179094, 36.513682000000131 ], [ 8.180353000000139, 36.513911 ], [ 8.181568, 36.514197 ], [ 8.182112, 36.513968000000148 ], [ 8.183, 36.513629000000151 ], [ 8.183648, 36.513282 ], [ 8.1848, 36.512767 ], [ 8.185557000000131, 36.51236 ], [ 8.186209, 36.512134000000117 ], [ 8.18758, 36.511966 ], [ 8.188089, 36.511794 ], [ 8.188673, 36.511565 ], [ 8.189092, 36.5111 ], [ 8.189223, 36.510646 ], [ 8.189338000000134, 36.51036 ], [ 8.189544000000126, 36.510131000000115 ], [ 8.1901170000001, 36.51007 ], [ 8.190725000000157, 36.509902 ], [ 8.191131000000155, 36.50973 ], [ 8.191836, 36.509387 ], [ 8.192386000000113, 36.509158 ], [ 8.192953000000102, 36.508986 ], [ 8.193492000000106, 36.508872 ], [ 8.19416, 36.508986 ], [ 8.194529000000102, 36.508868 ], [ 8.194844, 36.508468 ], [ 8.19513000000012, 36.508067 ], [ 8.195571, 36.507838000000106 ], [ 8.196133000000145, 36.507838000000106 ], [ 8.196356, 36.507956 ], [ 8.197135000000117, 36.508811000000151 ], [ 8.197508, 36.509097 ], [ 8.198579, 36.509501 ], [ 8.199926000000119, 36.509959 ], [ 8.200493000000108, 36.510188 ], [ 8.201072, 36.51036 ], [ 8.201697, 36.510589000000152 ], [ 8.203913000000114, 36.511161 ], [ 8.20447, 36.511222000000146 ], [ 8.205117, 36.51133 ], [ 8.205551000000128, 36.511504 ], [ 8.206057, 36.51185 ], [ 8.206922, 36.512595 ], [ 8.207873, 36.513282 ], [ 8.209644, 36.513968000000148 ], [ 8.210366, 36.51414 ], [ 8.211006, 36.514255000000105 ], [ 8.212297000000149, 36.514541000000122 ], [ 8.213064, 36.514659000000108 ], [ 8.214422000000127, 36.514831000000129 ], [ 8.215293, 36.515002 ], [ 8.216559, 36.51512 ], [ 8.218037, 36.515403 ], [ 8.218896, 36.515456000000142 ], [ 8.220163000000127, 36.515632000000153 ], [ 8.22123, 36.515513 ], [ 8.221492000000126, 36.515513 ], [ 8.221836, 36.515689 ], [ 8.222311, 36.51615 ], [ 8.222862000000134, 36.51649 ], [ 8.223153, 36.516719 ], [ 8.223395, 36.517005 ], [ 8.223531, 36.517291000000114 ], [ 8.223503, 36.517863 ], [ 8.22339, 36.51884 ], [ 8.223458, 36.519355 ], [ 8.223715, 36.519698000000119 ], [ 8.22414, 36.520099 ], [ 8.224707, 36.520442 ], [ 8.225303, 36.520503000000133 ], [ 8.225876000000142, 36.520503000000133 ], [ 8.226466, 36.52056 ], [ 8.227073, 36.52078900000015 ], [ 8.227721, 36.521129 ], [ 8.228218, 36.5213 ], [ 8.228986, 36.521357 ], [ 8.229698000000155, 36.521247 ], [ 8.231003000000157, 36.52078900000015 ], [ 8.231273000000101, 36.5209 ], [ 8.231943000000115, 36.521533 ], [ 8.2323, 36.521991000000128 ], [ 8.23264, 36.522338000000104 ], [ 8.23322, 36.522567 ], [ 8.233879, 36.52291 ], [ 8.23443, 36.523139 ], [ 8.234922, 36.523478 ], [ 8.235702000000117, 36.523883 ], [ 8.236354, 36.524169 ], [ 8.236997000000144, 36.524341 ], [ 8.23735, 36.524627000000123 ], [ 8.237718, 36.525084000000106 ], [ 8.238182000000108, 36.525432 ], [ 8.238733, 36.525599 ], [ 8.239202000000148, 36.525599 ], [ 8.2402790000001, 36.525313 ], [ 8.240773000000104, 36.525256000000127 ], [ 8.24134, 36.525428000000147 ], [ 8.241660000000138, 36.525599 ], [ 8.242021000000136, 36.526057000000151 ], [ 8.242492, 36.526515 ], [ 8.24294, 36.52686 ], [ 8.243367000000148, 36.527263 ], [ 8.24376, 36.527545000000146 ], [ 8.244038, 36.527835000000152 ], [ 8.24455, 36.52795 ], [ 8.244978, 36.527778 ], [ 8.245669, 36.527725 ], [ 8.24573, 36.52772 ], [ 8.246308000000113, 36.52772 ], [ 8.246731000000125, 36.527835000000152 ], [ 8.24738, 36.52846 ], [ 8.247711, 36.528983 ], [ 8.248078, 36.529437 ], [ 8.248357, 36.530299000000127 ], [ 8.248461, 36.530418 ], [ 8.248708, 36.5307 ], [ 8.24883, 36.530986 ], [ 8.248788, 36.531901000000119 ], [ 8.248925, 36.532134 ], [ 8.249062, 36.532307 ], [ 8.249653000000137, 36.53305 ], [ 8.250289, 36.53356 ], [ 8.250754, 36.533965 ], [ 8.25168200000013, 36.534537000000114 ], [ 8.25209, 36.534823000000131 ], [ 8.252489000000139, 36.534995000000151 ], [ 8.253411, 36.535457 ], [ 8.253762000000108, 36.53551 ], [ 8.254368, 36.535685 ], [ 8.254775000000109, 36.535743 ], [ 8.255796, 36.535743 ], [ 8.255899, 36.535743 ], [ 8.256368, 36.535972 ], [ 8.256387, 36.536045 ], [ 8.256505, 36.536487000000136 ], [ 8.256689, 36.536715 ], [ 8.257044, 36.536944000000119 ], [ 8.257371, 36.537059 ], [ 8.258029, 36.537059 ], [ 8.258071000000143, 36.536904 ], [ 8.258076, 36.536887 ], [ 8.2583, 36.536776 ], [ 8.258631, 36.536773 ], [ 8.259113, 36.536601 ], [ 8.259342000000117, 36.536544 ], [ 8.259651000000133, 36.536372 ], [ 8.259938, 36.536258 ], [ 8.260219, 36.536086 ], [ 8.26034, 36.536029 ], 

In order for me to manipulate it with Python and display it, I need to convert it into a GeoJSON file. Any suggestions on how to do that? I have already tried geojson.io but the website crashes each time I copy-paste the data (probably due to its length).

Edit: I have also tried converting the text file into a Json file :

# Python program to convert text 
# file to JSON 


import json 


# the file to be converted to 
# json format 
filename = 'Jendouba.txt'

# dictionary where the lines from 
# text will be stored 
dict1 = {} 

# creating dictionary 
with open(filename) as fh: 

    for line in fh: 

        # reads each line and trims of extra the spaces 
        # and gives only the valid words 
        command, description = line.strip().split(None, 1) 

        dict1[command] = description.strip() 

# creating json file 
# the JSON file is named as test1 
out_file = open("Jendouba.json", "w") 
json.dump(dict1, out_file, indent = 4, sort_keys = False) 
out_file.close() 

Therefore, is it possible to go :

  1. from Text file to GeoJson file directly
  2. from text file-->Json-->GeoJson Using Pyhton in both cases?
  • 1
    1) Does your file actually end with [ 8.26034, 36.536029 ], or has it been truncated here? 2) If it is valid JSON (i.e. ends without being truncated) it looks as though it already is a GeoJSON file. – alphabetasoup Jun 8 at 10:38
  • 1
    First off, you should read the file and convert it to JSON in Python (which is already answered in Stack Overflow), then you'll be ready to start evaluating GeoJSON conformance. – Vince Jun 8 at 10:45
  • @alphabetasoup no it's pretty lengthy so I just put a sample. – Rim Sleimi Jun 8 at 10:46
0

Using pyhton the following worked for me:

# Convert text file to JSON 
import json 
with open('Jendouba.txt') as json_file:     # name of the text file
    data = json.load(json_file)

# Convert JSON to GeoJson 
from geojson import dump
with open('Jendouba.geojson', 'w') as f:   # name of the output geojson file
   dump(data, f)
| improve this answer | |
  • 1
    If that worked, then simply renaming the file to Jendouba.geojson is all you need to do. – Jeremy Malczyk Jun 8 at 17:52
  • Yeah basically just load and dump in the new format. – Rim Sleimi Jun 8 at 18:29
  • 1
    @RimSleimi No, you don't even need to load it and dump it; if this code works then Jendouba.txt is already a file containing GeoJSON data, it just has a misleading file extension (.txt instead of .json or .geojson). – alphabetasoup Jun 9 at 12:16
  • This is actually true the text file has GeoJSON data – Rim Sleimi Jun 9 at 12:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.