8

How can i convert my lat and long value into geojson object. I work on php platform.

hakre
  • 193,403
  • 52
  • 435
  • 836
Ashish Pethkar
  • 1,558
  • 4
  • 12
  • 10

3 Answers3

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
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.

http://www.convertcsv.com/csv-to-geojson.htm

-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