Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a linestring that was built from points from GPX file. I've insert it to sql as geometry and when I try to run funcs on it (like STStartPoint ) I get error that line isn't valid and I need to run MakeValid on it (which change the GPS Points).

Here is the line :

LINESTRING (34.7873 31.3182, 34.7884 31.3366, 34.7941 31.3552, 34.7942 31.3712, 34.793 31.3756, 34.7892 31.3906, 34.7883 31.4086, 34.7864 31.423, 34.7863 31.4219, 34.7863 31.4221, 34.7863 31.422, 34.7862 31.4216, 34.7862 31.4219, 34.7849 31.4241, 34.7734 31.435, 34.7656 31.4466, 34.7734 31.4668, 34.7798 31.491, 34.7826 31.5068, 34.7927 31.5311, 34.8005 31.5514, 34.8065 31.5749, 34.8132 31.5973, 34.8147 31.6196, 34.8095 31.657, 34.806399999999996 31.6748, 34.8157 31.6988, 34.8212 31.7214, 34.8227 31.7407, 34.8264 31.7604, 34.8328 31.7959, 34.8401 31.8035, 34.8576 31.8097, 34.8766 31.809, 34.8998 31.8109, 34.9156 31.8146, 34.9208 31.8193, 34.9487 31.826, 34.9687 31.8311, 34.9774 31.8349, 34.9881 31.8345, 34.993 31.8268, 35.0003 31.8261, 35.0056 31.8259, 35.0177 31.8215, 35.0216 31.8183, 35.0269 31.8133, 35.0314 31.8098, 35.0382 31.8062, 35.0454 31.8047, 35.0532 31.805, 35.0649 31.8041, 35.0758 31.8003, 35.0884 31.8003, 35.1064 31.8015, 35.1261 31.8007, 35.147 31.7972, 35.1622 31.7933, 35.1716 31.7977, 35.1877 31.7979, 35.1884 31.7965, 35.1887 31.7961, 35.1905 31.795, 35.1926 31.7946, 35.1927 31.7936, 35.1936 31.7931, 35.1947 31.7934, 35.1961 31.7916, 35.197 31.7908, 35.1979 31.7902, 35.1987 31.7899, 35.1993 31.7872, 35.1985 31.7854, 35.1994 31.7847, 35.1992 31.7823, 35.1984 31.7814, 35.2012 31.7761, 35.2008 31.7747, 35.2045 31.7747, 35.209 31.7762, 35.2086 31.782, 35.2098 31.7825, 35.2114 31.7817, 35.2135 31.7808, 35.2148 31.7817, 35.2147 31.7809, 35.2126 31.7812, 35.2086 31.7831, 35.2083 31.783, 35.2032 31.7822, 35.1985 31.7863, 35.1998 31.7875, 35.2001 31.788, 35.1973 31.7905, 35.1911 31.7951, 35.1816 31.8017, 35.1687 31.7957, 35.1592 31.7958, 35.1194 31.7988, 35.0804 31.8009, 35.0632 31.8051, 35.0481 31.804, 35.0329 31.8085, 35.0209 31.8188, 34.9901 31.8293, 34.988 31.839, 34.978 31.8351, 34.9499 31.826, 34.9274 31.8231, 34.917 31.8156, 34.9037 31.8119, 34.883 31.8105, 34.86 31.8101, 34.84 31.8036, 34.8302 31.7943, 34.8325 31.7811, 34.8271 31.7626, 34.8228 31.7437, 34.8205 31.7209, 34.8142 31.6955, 34.8063 31.6752, 34.81 31.653199999999998, 34.8148 31.6239, 34.8133 31.6027, 34.808 31.5828, 34.803 31.5607, 34.7972 31.5415, 34.7868 31.5232, 34.783 31.5045, 34.7761 31.484, 34.7734 31.4673, 34.7665 31.4504, 34.7659 31.4422, 34.7853 31.4222, 34.7891 31.4016, 34.7913 31.3816, 34.7957 31.3653, 34.7921 31.3504, 34.7865 31.3298, 34.7884 31.3094, 34.7908 31.2899, 34.7976 31.2879, 34.8037 31.2868)

and this is that I get after MakeValid()

MULTILINESTRING ((34.991771945003556 31.828729956620826, 34.989424975190637 31.83241805204112, 34.990100026130676 31.829299926757813, 34.991771945003556 31.828729956620826), (34.954345241759384 31.827439520434716, 34.968700051307678 31.831099987030029, 34.977399945259094 31.83489990234375, 34.988100051879883 31.834500074386597, 34.989424975190637 31.83241805204112, 34.98800003528595 31.83899998664856, 34.978000044822693 31.835099935531616, 34.954345241759384 31.827439520434716), (34.999167677687957 31.8262086938732, 34.991771945003556 31.828729956620826, 34.993000030517578 31.826800107955933, 34.999167677687957 31.8262086938732), (34.947309795820473 31.825666136443175, 34.949900031089783 31.825999975204468, 34.954345241759384 31.827439520434716, 34.948699951171875 31.825999975204468, 34.947309795820473 31.825666136443175), (34.922794889315966 31.81977900590601, 34.947309795820473 31.825666136443175, 34.92739999294281 31.823100090026855, 34.922794889315966 31.81977900590601), (35.022785521481737 31.817181583739565, 35.021600008010864 31.818300008773804, 35.017699956893921 31.821500062942505, 35.005599975585938 31.825900077819824, 35.0003000497818 31.82610011100769, 34.999167677687957 31.8262086938732, 35.020900011062622 31.81879997253418, 35.022785521481737 31.817181583739565), (34.9165756262933 31.815481844098283, 34.91700005531311 31.815599918365479, 34.922794889315966 31.81977900590601, 34.920799970626831 31.819299936294556, 34.9165756262933 31.815481844098283), (35.031246560569912 31.809919226177239, 35.022785521481737 31.817181583739565, 35.026900053024292 31.813299894332886, 35.031246560569912 31.809919226177239), (35.035067600420085 31.807858299827611, 35.031399965286255 31.809799909591675, 35.031246560569912 31.809919226177239, 35.032899975776672 31.808500051498413, 35.035067600420085 31.807858299827611), (34.844628452901595 31.805104311964445, 34.858650011538806 31.809661326879048, 34.876600027084351 31.809000015258789, 34.899799942970276 31.810899972915649, 34.915599942207336 31.814599990844727, 34.9165756262933 31.815481844098283, 34.903699994087219 31.8118999004364, 34.883000016212463 31.810499906539917, 34.860000014305115 31.810100078582764, 34.858650011538806 31.809661326879048, 34.857599973678589 31.809700012207031, 34.844628452901595 31.805104311964445), (35.188035494269172 31.797229039308949, 35.187700033187866 31.797899961471558, 35.187080863729726 31.797892268672587, 35.181599974632263 31.801700115203857, 35.173038050284156 31.797717795369007, 35.187080863729726 31.797892268672587, 35.188035494269172 31.797229039308949), (35.14965103796618 31.796519744421513, 35.146999955177307 31.797199964523315, 35.126099944114685 31.800699949264526, 35.106400012969971 31.801500082015991, 35.08980497387266 31.800393562901903, 35.080399990081787 31.800899982452393, 35.063199996948242 31.805099964141846, 35.057397041666896 31.804677208028728, 35.053200006484985 31.805000066757202, 35.045697030633413 31.804711327578612, 35.035067600420085 31.807858299827611, 35.0382000207901 31.80620002746582, 35.045400023460388 31.804699897766113, 35.045697030633413 31.804711327578612, 35.048099994659424 31.803999900817871, 35.057397041666896 31.804677208028728, 35.064900040626526 31.804100036621094, 35.0757999420166 31.800299882888794, 35.08840000629425 31.800299882888794, 35.08980497387266 31.800393562901903, 35.119400024414062 31.798799991607666, 35.14965103796618 31.796519744421513), (35.191488436823214 31.794811774547405, 35.191100001335144 31.795099973678589, 35.188035494269172 31.797229039308949, 35.188400030136108 31.796499967575073, 35.188699960708618 31.796099901199341, 35.190500020980835 31.795000076293945, 35.191488436823214 31.794811774547405), (35.192666237926815 31.793937906774794, 35.192600011825562 31.794600009918213, 35.191488436823214 31.794811774547405, 35.192666237926815 31.793937906774794), (35.162199974060059 31.793299913406372, 35.1673577298707 31.795714187650482, 35.168699979782104 31.795700073242187, 35.173038050284156 31.797717795369007, 35.171599984169006 31.797699928283691, 35.1673577298707 31.795714187650482, 35.159199953079224 31.795799970626831, 35.14965103796618 31.796519744421513, 35.162199974060059 31.793299913406372), (35.198880189308213 31.789089100267343, 35.198699951171875 31.789900064468384, 35.197900056838989 31.790199995040894, 35.197000026702881 31.790800094604492, 35.196099996566772 31.791599988937378, 35.194700002670288 31.793400049209595, 35.193742910444314 31.79313907120585, 35.192666237926815 31.793937906774794, 35.192700028419495 31.793600082397461, 35.1936000585556 31.793100118637085, 35.193742910444314 31.79313907120585, 35.197299957275391 31.790499925613403, 35.198880189308213 31.789089100267343), (34.831336083280775 31.787779747905049, 34.832800030708313 31.795900106430054, 34.840100049972534 31.803499937057495, 34.844628452901595 31.805104311964445, 34.8400000333786 31.803600072860718, 34.830199956893921 31.794300079345703, 34.831336083280775 31.787779747905049), (35.199178294521381 31.786926018042656, 35.19980001449585 31.787499904632568, 35.200099945068359 31.788000106811523, 35.198880189308213 31.789089100267343, 35.199300050735474 31.787199974060059, 35.199178294521381 31.786926018042656), (35.198788290813596 31.78604849517162, 35.199178294521381 31.786926018042656, 35.1985000371933 31.78629994392395, 35.198788290813596 31.78604849517162), (35.2007999420166 31.774699926376343, 35.204499959945679 31.774699926376343, 35.208999991416931 31.77620005607605, 35.208600044250488 31.782000064849854, 35.209800004959106 31.782500028610229, 35.211400032043457 31.781699895858765, 35.213500022888184 31.780800104141235, 35.213824916937241 31.781024982663222, 35.2146999835968 31.780900001525879, 35.214800000190735 31.781699895858765, 35.213824916937241 31.781024982663222, 35.212599992752075 31.781199932098389, 35.208600044250488 31.783099889755249, 35.208299994468689 31.782999992370605, 35.203199982643127 31.78220009803772, 35.198788290813596 31.78604849517162, 35.1985000371933 31.785399913787842, 35.199399948120117 31.7846999168396, 35.199200034141541 31.782299995422363, 35.198400020599365 31.781399965286255, 35.201200008392334 31.776099920272827, 35.2007999420166 31.774699926376343), (34.825456178748283 31.755374636510627, 34.827100038528442 31.762599945068359, 34.832499980926514 31.781100034713745, 34.831336083280775 31.787779747905049, 34.8264000415802 31.760400056838989, 34.825456178748283 31.755374636510627), (34.810187663125 31.652054055238416, 34.809499979019165 31.657000064849854, 34.8063999414444 31.674799919128418, 34.8157000541687 31.698800086975098, 34.821200013160706 31.721400022506714, 34.822700023651123 31.740700006484985, 34.825456178748283 31.755374636510627, 34.822800040245056 31.74370002746582, 34.820500016212463 31.720900058746338, 34.814200043678284 31.695499897003174, 34.806300044059753 31.67519998550415, 34.809999942779541 31.653199911117554, 34.810187663125 31.652054055238416), (34.814564661037444 31.62057350543299, 34.814800024032593 31.623899936676025, 34.810187663125 31.652054055238416, 34.814564661037444 31.62057350543299), (34.803976636563448 31.565016789967814, 34.80649995803833 31.574899911880493, 34.813199996948242 31.597300052642822, 34.81470000743866 31.619600057601929, 34.814564661037444 31.62057350543299, 34.813300013542175 31.602699995040894, 34.807999968528748 31.582799911499023, 34.803976636563448 31.565016789967814), (34.802189379692969 31.558016620660805, 34.802999973297119 31.560699939727783, 34.803976636563448 31.565016789967814, 34.802189379692969 31.558016620660805), (34.799052621581232 31.547632967487864, 34.80050003528595 31.551399946212769, 34.802189379692969 31.558016620660805, 34.799052621581232 31.547632967487864), (34.795644399658784 31.538762870825277, 34.797199964523315 31.541500091552734, 34.799052621581232 31.547632967487864, 34.795644399658784 31.538762870825277), (34.78429707291923 31.510882897847225, 34.792700052261353 31.531100034713745, 34.795644399658784 31.538762870825277, 34.786800026893616 31.523200035095215, 34.78429707291923 31.510882897847225), (34.781294481037484 31.4994327924487, 34.782999992370605 31.504499912261963, 34.78429707291923 31.510882897847225, 34.782600045204163 31.506799936294556, 34.781294481037484 31.4994327924487), (34.766367359702791 31.448587318836147, 34.773399949073792 31.466799974441528, 34.779800057411194 31.490999937057495, 34.781294481037484 31.4994327924487, 34.776100039482117 31.483999967575073, 34.773399949073792 31.467299938201904, 34.7664999961853 31.450400114059448, 34.766367359702791 31.448587318836147), (34.766160912887024 31.445765728619, 34.766367359702791 31.448587318836147, 34.765599966049194 31.446599960327148, 34.766160912887024 31.445765728619), (34.78629994392395 31.422100067138672, 34.78629994392395 31.421999931335449), (34.788482692723164 31.404946598016188, 34.788300037384033 31.408600091934204, 34.786399960517883 31.42300009727478, 34.78629994392395 31.421900033950806, 34.78629994392395 31.421999931335449, 34.786200046539307 31.421600103378296, 34.786200046539307 31.421900033950806, 34.784899950027466 31.424099922180176, 34.773399949073792 31.434999942779541, 34.766160912887024 31.445765728619, 34.765900015830994 31.442199945449829, 34.7853000164032 31.422199964523315, 34.788482692723164 31.404946598016188), (34.791161962913016 31.382855310863285, 34.789100050926208 31.401599884033203, 34.788482692723164 31.404946598016188, 34.789199948310852 31.390599966049194, 34.791161962913016 31.382855310863285), (34.794197849383437 31.370864674378371, 34.79419994354248 31.371200084686279, 34.792999982833862 31.3756000995636, 34.791161962913016 31.382855310863285, 34.791300058364868 31.381599903106689, 34.794197849383437 31.370864674378371), (34.794122337747623 31.35877037755764, 34.7956999540329 31.365299940109253, 34.794197849383437 31.370864674378371, 34.794122337747623 31.35877037755764), (34.787409615770848 31.320033730460121, 34.788400053977966 31.336600065231323, 34.794100046157837 31.355200052261353, 34.794122337747623 31.35877037755764, 34.792099952697754 31.3503999710083, 34.786499977111816 31.329799890518188, 34.787409615770848 31.320033730460121), (34.803699970245361 31.286799907684326, 34.797600030899048 31.2878999710083, 34.7907999753952 31.289900064468384, 34.788400053977966 31.309400081634521, 34.787409615770848 31.320033730460121, 34.787299990653992 31.31820011138916))

I'm trying to show the line and auto put flag on start and end of it.

share|improve this question
    
If I load the data in QGIS as delimited text, I get no error. Exporting from there as shapefile and importing that into spatialite, it tells me that the geometry is valid. –  Andre Joost Jun 24 '13 at 9:31
    
Can you try and do geom.STStartPoint() in MSSQL . See if it brings you 34.7873 31.3182 or 34.991771945003556 31.828729956620826 ? –  Alophind Jun 24 '13 at 14:23
    
I don't have MSSQL, but if I do it in Postgis SELECT ST_AsText(ST_StartPoint('LINESTRING (34.7873 31.3182, 34.7884 31.3366, 34.7941 31.3552, 34.7942 31.3712, 34.793 31.3756, 34.7976 31.2879, 34.8037 31.2868)'::geometry)); even with all vertices, I get exactly the first point, as it should be. –  Andre Joost Jun 24 '13 at 15:02
    
I've converted it from LINESTRING to MULTILINESTRING and now it works fine. –  Alophind Jun 25 '13 at 4:46
    
Looks like MSSQL has some problems with intersection, invalid geometry and precision. Take a look here: blog.safe.com/2012/06/… –  Andre Joost Jun 25 '13 at 5:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.