-1

How to search polygon/polyline geojson file by an attribute

I have a geojson file of roads(polyline) having an attribute of road_length now i want to search the geojson file by this(road length) attribute and draw the matched road(polyline) on the google map e-g if i want to draw only those roads having length less than 10 km.

1 Answer 1

2

Assuming you're using Javascript and have a variable data as your .geojson with this format then you can access the data in a GeoJSON file like so:

for (var i = 0; i < data.length; i++) {
    var feature = data[i];
    if (feature['type'] == "Polyline") {
        if (feature['properties']['road_length'] > 10) {
            // draw Polyline
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.