How can i convert my lat and long value into geojson object. I work on php platform.
Asked
Active
Viewed 2.8k times
3 Answers
17
If I understand well, you want to build a string like this:
$my_geoJSON = '{ "type": "Point", "coordinates": ['.$longitude.' ,'.$latitude.'] }';
As as the specification for GeoJSON format (RFC7946) says:
Point coordinates are in x, y order (easting, northing for projected coordinates, longitude, and latitude for geographic coordinates):
{ "type": "Point", "coordinates": [100.0, 0.0] }

Community
- 1
- 1

pconcepcion
- 5,591
- 5
- 35
- 53
-
7I wonder why geoJSON uses longitude, latitude when almost everyone else uses lat,lng. – Samuel Barbosa Oct 28 '16 at 04:17
-
2@SamuelBarbosa, it's cause most everyone else is wrong. Lng is the x coordinate and lat is y, so correct usage is lng, lat. – sunny-mittal May 09 '21 at 20:05
3
Put all your Lat Long data in a CSV file and use the below online tool to create a GeoJson file. Verify it using http://geojson.io/ tool.

kalyan verma
- 29
- 1
-1
I think, you should have a look to the geojson specification (http://geojson.org/geojson-spec.html#id9) you can also view simple example that will certainly help you to create a simple geojson with you lat/lon.

j_freyre
- 4,623
- 2
- 30
- 47