Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert lat long into geojson object

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

like image 884
Ashish Pethkar Avatar asked Apr 11 '11 11:04

Ashish Pethkar


People also ask

Is GeoJSON Lat Long or Long LAT?

Nothing is in the wrong order. Leaflet uses lat-lng (or northing-easting ) whereas GeoJSON uses lng-lat (or easting-northing ).

How do you create a GeoJSON?

Launch geojson.io from http://geojson.io/#map=2/20.0/0.0. I will be using a polygon in this instance. Draw your AOI by clicking desired points on the map to outline your AOI. Once you complete the polygon it will be shaded and the associated JSON will be generated in the output area to the left.

What is a GeoJSON object?

GeoJSON is an open standard geospatial data interchange format that represents simple geographic features and their nonspatial attributes. Based on JavaScript Object Notation (JSON), GeoJSON is a format for encoding a variety of geographic data structures.


2 Answers

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]
 }
like image 198
pconcepcion Avatar answered Sep 19 '22 14:09

pconcepcion


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

like image 32
kalyan verma Avatar answered Sep 21 '22 14:09

kalyan verma