Created
December 1, 2018 15:49
-
-
Save maptastik/4eff9b6c93c26e56541b533031e06dfc to your computer and use it in GitHub Desktop.
Sometimes you just need the point coordinates for all the points in a GeoJSON. This function pulls them into an array.
This file contains hidden or 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
function createArrayOfPointCoordinates(pointsJson) { | |
let pointsCoordinatesArray = []; | |
let pointsFeatures = pointsJson.features; | |
for (let i = 0; i < pointsFeatures.length; i++) { | |
let pointsFeature = pointsFeatures[i]; | |
if (pointsFeature.geometry != null) { | |
let pointsFeaturesCoordinates = pointsFeature.geometry.coordinates; | |
pointsCoordinatesArray.push(pointsFeaturesCoordinates); | |
} | |
} | |
return pointsCoordinatesArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment