Last active
July 2, 2019 10:53
-
-
Save roberto-butti/114205ca3f370062887a954925c04413 to your computer and use it in GitHub Desktop.
JS script without dependencies to generate a geojson file with a grid for latitude and longitude
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var geojson = {}; | |
geojson.type = "FeatureCollection"; | |
var features = []; | |
const step = 1; | |
var i=0; | |
var feature = {}; | |
for(i=-180;i<=180;i=i+step){ | |
feature = {}; | |
feature.type = "Feature"; | |
feature.properties = {}; | |
feature.properties.title = "Longitude " + i; | |
feature.geometry = {}; | |
feature.geometry.type = "LineString"; | |
feature.geometry.coordinates = []; | |
feature.geometry.coordinates.push([ i, 89 ]); | |
feature.geometry.coordinates.push([ i, -89 ]); | |
features.push(feature); | |
} | |
for (i = -90; i <= 90; i = i+step) { | |
feature = {}; | |
feature.type = "Feature"; | |
feature.properties = {}; | |
feature.properties.title = "Latitude " + i; | |
feature.geometry = {}; | |
feature.geometry.type = "LineString"; | |
feature.geometry.coordinates = []; | |
feature.geometry.coordinates.push([ 179, i ]); | |
feature.geometry.coordinates.push([ -179, i ]); | |
features.push(feature); | |
} | |
geojson.features = features; | |
console.log(JSON.stringify(geojson)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment