I have a dataset that has four types of files with the following file extensions - .DBF,.PRJ,SHP,SHX
My goal is to get all the polygon coordinates for each neighborhood and draw the boundary outline on the google map when a user is on a specific Neighborhood page. Currently the datasource for the site is a MySQL Database.
I have tried converting the shp file to Geojson but then parsing that file is time taking.
I have also tried using tools such as QGIS and shp2sql etc.
I would like to know what is the best way to get the main attributes from the dataset along with each neighborhood's Polygon coordinates.
please advise
I have managed to accomplish this using the ogr2ogr command line tool -
ogr2ogr -f "MySQL" MYSQL:"mydb,host=myhost,user=mylogin,password=mypassword,port=3306" -nln "world" -a_srs "EPSG:4326" path/to/world_adm0.shp
I have the polygon coordinates in a geometry field in the table attached to its corresponding neighborhood id.
I did Select ASTEXT(Shape) as POLYGON from world to get the array of coordinates and now I can convert that to json and send it to Javascript so that it can be mapped
用插件gdal实现将shp格式数据转换为json格式的数据就可以了