Use this site to validate and view your GeoJSON. For details about GeoJSON, read the spec.
If you need progrmmatic access to validate your GeoJSON you can simply use the same /validate endpoint that this site uses. It's CORS enabled so you can use it from the browser as well as any back end.
var good_geojson = '{"type": "Point", "coordinates": [-100, 80]}';
var bad_geojson = '{"type": "Rhombus", "coordinates": [[1, 2], [3, 4], [5, 6]]}';
function processSuccess(data) {
if (data.status === 'ok') {
alert('You just posted some valid GeoJSON!');
} else if (data.status === 'error') {
alert('There was a problem with your GeoJSON: ' + data.message);
}
}
function processError() {
alert('There was a problem with your ajax.');
}
$.ajax({
url: 'http://geojsonlint.com/validate',
type: 'POST',
data: good_geojson,
dataType: 'json',
success: processSuccess,
error: processError
});
$.ajax({
url: 'http://geojsonlint.com/validate',
type: 'POST',
data: bad_geojson,
dataType: 'json',
success: processSuccess,
error: processError
});
import requests
validate_endpoint = 'http://geojsonlint.com/validate'
good_geojson = '{"type": "Point", "coordinates": [-100, 80]}'
bad_geojson = '{"type": "Rhombus", "coordinates": [[1, 2], [3, 4], [5, 6]]}'
good_request = requests.post(validate_endpoint, data=good_geojson)
bad_request = requests.post(validate_endpoint, data=bad_geojson)
print good_request.json()
# {u'status': u'ok'}
print bad_request.json()
# {u'status': u'error', u'message': u'"Rhombus" is not a valid GeoJSON type.'}
Read the blog post or check out the source code.