3

I need to create a MySQL database for storing coordinates from a KML file with the structure as follows:

<Placemark>
        <name>someplace</name>
        <styleUrl>#m_ylw-pushpin</styleUrl>
        <Polygon>
            <tessellate>1</tessellate>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>
                        73.13693971060766,19.25310233594502,0 73.13693833446244,19.25310233595927,0 73.13693403840304,19.2530984545477,0 73.13693244215831,19.25309329030865,0 73.13693090444444,19.25308942538022,0 73.13692794507664,19.25308428308517,0 73.13692494004152,19.25307787269911,0 73.13692467634385,19.25307148170985,0 73.1369258304161,19.25306638278946,0 73.13692698179315,19.2530612962149,0 73.1369322686994,19.25305748929283,0 73.13693618566978,19.25305368927265,0 73.13694020972429,19.25305242409976,0 73.1369455322031,19.25304989609698,0 73.13695090854537,19.25304863322264,0 73.13695628164153,19.25304737111269,0 73.13696294560927,19.25304484915161,0 73.13696837570761,19.25304484914826,0 73.13697652081103,19.2530448491438,0 73.13698202045055,19.25304610973631,0 73.13698895342023,19.2530486332095,0 73.13699582091516,19.25304989604919,0 73.13700004851012,19.25305242405945,0 73.13700428114488,19.25305495514516,0 73.137008596689,19.25305875746043,0 73.13701292005057,19.25306256664898,0 73.13701733179597,19.25306765632393,0 73.1370191023439,19.25307403574487,0 73.13702208277293,19.25307787264039,0 73.13702249452535,19.25308428301952,0 73.1370229075506,19.25309071284612,0 73.13702323885482,19.25309587081664,0 73.13702227801461,19.25310233591246,0 73.13702260952107,19.25310752220441,0 73.1370201827993,19.25311272114856,0 73.1370177501589,19.2531179327989,0 73.13701531155583,19.25312315721282,0 73.1370114025442,19.25312708392549,0 73.13700602252482,19.25312970574124,0 73.1370006359243,19.25313233078209,0 73.13699509258757,19.25313233079353,0 73.13698816344083,19.25313233078499,0 73.13698116356548,19.25313101786714,0 73.13697555292208,19.25312970576528,0 73.13696994578734,19.2531283944655,0 73.13696434201735,19.25312708395525,0 73.13695999711467,19.25312315723566,0 73.13695697863325,19.25311793285053,0 73.13695264975624,19.25311402288048,0 73.13694832879452,19.2531101201258,0 73.13694395681273,19.25310492752692,0 73.13693971060766,19.25310233594502,0 
                    </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
    </Placemark>
    <Placemark>
        <name>place2</name>
        <styleUrl>#m_ylw-pushpin</styleUrl>
        <Polygon>
            <tessellate>1</tessellate>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>
                        73.13723765697174,19.25290222725077,0 73.13723989677642,19.25289857411988,0 73.13724050975087,19.25289250009896,0 73.13724140951585,19.2528888642842,0 73.13724216325605,19.25288402638158,0 73.13724690239067,19.2528791999123,0 73.1372491215834,19.25287558746117,0 73.13725413788218,19.25287318265183,0 73.13725944636737,19.25287318265056,0 73.13726740917318,19.25287318261767,0 73.1372740448365,19.25287318261646,0 73.13727818083784,19.25287438462484,0 73.13728161429077,19.25288040541489,0 73.1372835696157,19.25288523471525,0 73.13728286450872,19.25289007539774,0 73.13727964512475,19.25289614231522,0 73.1372761061091,19.25289979111273,0 73.13727389776194,19.25290344626298,0 73.13727065467811,19.25290955268617,0 73.13726828301977,19.25291200031773,0 73.13726337940838,19.25291567720809,0 73.13725846706093,19.25291936058711,0 73.13725324778412,19.25292058984915,0 73.13724877730209,19.25291690427552,0 73.13724550831267,19.25291200035216,0 73.13724224708763,19.25290710800144,0 73.13724152171221,19.25290100884397,0 73.13723765697174,19.25290222725077,0 
                    </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
    </Placemark>

How do I store the above in MySQL database?

I need to store coordinates of polygons.

say FE: in kml file, i have highlighted 2 areas. I may required to calculate area(sq. mt) or distance from point a to point b. add custom placemarks with data generated by database

  • Do you intend to store as KML or as points? What are your intentions to do with the data after storage? – Michael Stimson Jun 27 '14 at 5:25
  • I will receive kml file. i need to store coordinates of polygon. – user3497997 Jun 27 '14 at 5:36
  • say FE: in kml file, i have highlighted 2 areas. I may required to calculate area(sq. mt) or distance from point a to point b. add custom placemarks with data generated by database. – user3497997 Jun 27 '14 at 5:37
2

I found a blog posting entitled KML / KMZ data import into MySQL for use with GIS functions by Romain which looks like it will do much of what you are asking.

For demonstration purposes, the KML polygons will be inserted into a simple table storing a string and a matching polygon definition.

  • thanks for quick reply. i got fair idea. when i insert to mysql database. INSERT INTO sector_geometry_t ( sector_id, geometry) VALUES ('3', GeomFromText( 'POLYGON((73.13693971060766,19.25310233594502 73.13693833446244,19.25310233595927 73.13693403840304,19.2530984545477 73.13693244215831,19.25309329030865 ))',0) ) i get error geometry cant be null. would you please throw some light on this. Thank you once again – user3497997 Jun 27 '14 at 6:52
  • @user3497997 GIS SE is not like other Q&A sites or Discussion Forums that you may have used. To get an idea of how it works here I recommend the 2 minute Tour. If you have a new question I recommend that you research/ask it separately. – PolyGeo Jun 27 '14 at 6:58

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.