2

Let's say I have the following GeoJSON:

{
    "type": "FeatureCollection",
    "features": [{
            "type": "Feature",
            "properties": {},
            "geometry": {
                "type": "Point",
                "coordinates": [-88.0344009399414, 43.11040115356445]
            }
        },
        {
            "type": "Feature",
            "properties": {},
            "geometry": {
                "type": "Point",
                "coordinates": [-89.3375015258789, 43.13990020751953]
            }
        },
        {
            "type": "Feature",
            "properties": {
                "feature_type": "line"
            },
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [-88.0344009399414, 43.11040115356445],
                    [-89.3375015258789, 43.13990020751953]
                ]
            }
        }
    ]
}

The above is a line between two points. I want to shorten that line by some x amount so it doesn't go all the way to the points at the beginning and end. Is there a way to do this without changing the start and end points for the line? To say, for example shorten the line by 50px or something like that?

I know you can do this when creating a polyline in leaflet, but can't find any settings on a GeoJSON LineString that would allow me to do the same.

1

I would say no, there is no 'length' property in the definition of a line string in the geojson spec. You need to use the start and end points.

0

Paste in your geojson to geojs on.io And edit it

  • That's a very helpful website. The issue is I haven't been able to find any documentation that says how to do this, and can't guess at how I would do it. – Arel Oct 7 '17 at 3:20

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.