question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot get accurate position using meter offset in scatterplot

See original GitHub issue

I used the below to plot using METER_OFFSET. Results are quite good until the points are very far from the Origin, where they start moving away from their positions plotted using LNGLAT. Any idea to get it more accurate with the lnglat positions?

class Layer extends ScatterplotLayer {
    constructor(props) {
        super(props)
    }

    calculateInstancePositions(attribute) {
        const { data, getPosition, projectionMode, positionOrigin } = this.props
        const { viewport } = this.context
        const { value } = attribute
        let i = 0
        for (const point of data) {
            let position = getPosition(point)
            if (projectionMode === COORDINATE_SYSTEM.METER_OFFSETS) {
                const lngLatDelta = [
                    position[0] - positionOrigin[0],
                    position[1] - positionOrigin[1]
                ]
                position = viewport.lngLatDeltaToMeters(lngLatDelta)
                if (
                    (lngLatDelta[0] < 0 && position[0] > 0) ||
                    (lngLatDelta[0] > 0 && position[0] < 0)
                ) {
                    position[0] *= -1
                }
                if (
                    (lngLatDelta[1] < 0 && position[1] < 0) ||
                    (lngLatDelta[1] > 0 && position[1] > 0)
                ) {
                    position[1] *= -1
                }
            }
            value[i++] = get(position, 0)
            value[i++] = get(position, 1)
            value[i++] = get(position, 2) || 0
        }
    }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
howtimeflies0commented, Jun 1, 2017

@huaruiwu In that case, projectionPixelsPerUnit needs to be an attribute. Depending on the distance between the center point, each vertex would need to be projected using a different projectionPixelsPerUnit

Currently, projectionPixelsPerUnit is calculated around the center point and the same for all points.

0reactions
ibgreencommented, Nov 13, 2017

Collecting early thoughts on improved projection modes in this RFC

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot get accurate position using meter offset in scatterplot
METER_OFFSET will only give you high precision for positions near the center. It is used when you have a center LATLNG with relative...
Read more >
Scatter plot of position errors for different scenarios.
A method to enhance the indoor positioning accuracy by alleviating the effect of multipath distortion is presented. Using this method the line-of-sight ...
Read more >
SCATTERPLOT Statement - SAS Help Center
A positive offset is to the right on discrete X values and up on discrete Y values. If the layout's axis options set...
Read more >
ggplot2 offset scatterplot points - Stack Overflow
I would like to offset the second so it's displayed slightly down from the first set, so that it doesn't obscure the original....
Read more >
A Complete Guide to Scatter Plots - Chartio
A scatter plot (aka scatter chart, scatter graph) uses dots to represent values ... Each row of the table will become a single...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found