1

I have shapefiles which I converted to .csv format. I want to insert those into a MySQL Database table. I used ST_PolyFromText according to the MySQL reference manual.

## create table
cur.execute("CREATE TABLE `db1`.`table1` ("
  "`Id` INT NOT NULL AUTO_INCREMENT,"
  "`geometry` POLYGON NOT NULL,"
  "PRIMARY KEY (`Id`));")

sql_statement = "INSERT INTO table1(geometry) VALUES (ST_PolyFromText(%s,0))"

When I try to insert polygon values into the Database. I get the error 3037, 'Invalid GIS data provided to function st_polyfromtext.'

  1. How should I use MySQL Spatial Functions to insert my Polygons ??

My Polygon geometry column looks like this : enter image description here

2
  • Try replacing the geometry column with wkt column: df['wkt']=df.geometry.apply(lambda x: x.wkt) when exporting to csv. What if you open the csv and look at the incomplete row, is it complete in the csv?
    – BERA
    Mar 1, 2019 at 13:27
  • I tried it out , still I am getting the same error!
    – roshualine
    Mar 1, 2019 at 13:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.