Skip to content

How to get polygon of any city or state in the world and save it in MySql table

Notifications You must be signed in to change notification settings

HusamAamer/PolygonOfAnyCity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

Get the Polygon of any City and store it in MySql

How to get polygon of any city or state in the world and save it in MySql table

1- Enter this url and search for any city https://nominatim.openstreetmap.org

2- Click on "details" button on the left side of your screen

3- Scroll down and look for relation number (looks like this ==> 3242293)

4- Now, Open this url and paste the relation number http://polygons.openstreetmap.fr/index.py

5- Choose GeoJSON format

🎉🎉🎉 Now we have a MultiPolygon

Inserting a polygon to MySql

1- Prepare the polygon, Use the following format

{
  “type” : “Polygon”,
  “coordinates” [[
    [xx ,xx],
    [xx ,xx],
    ...
    ..
  ]]
}

*Note: I use jaysoon app in macOS to read and modify JSON easily. Download jayson: https://itunes.apple.com/us/app/jayson-visual-json-editor/id1189824719?mt=12

2- Store JSON inside a text column.

3- Assuming your column is called bounds and table is cities,You can read it as follows:

References :

About

How to get polygon of any city or state in the world and save it in MySql table

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published