Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric column coming in as NULL property #68

Open
nwesterman opened this issue Jul 20, 2021 · 0 comments · May be fixed by #71
Open

Numeric column coming in as NULL property #68

nwesterman opened this issue Jul 20, 2021 · 0 comments · May be fixed by #71

Comments

@nwesterman
Copy link

Hi! We think we have found an edge case. We have a file that has a numeric column "Blend - *", that when we run it through shapefile, returns all NULL values in the property field instead of the true values. Values can be properly read by other software such as mapshaper or our C++ program, but not this library.

The shape points get converted correctly, and the property "Blend - *" appears on the result object, just not the associated property values.

Code for testing:

async function parseShapefile(absPath) {
    const geoJson = await shapefile.read(absPath)
    if (!geoJson) { return {} }
    // Find numeric columns to use for rate selection
    for (const property of Object.keys(shape.properties)) {
        let numeric = true
        for (const feature of geoJson.features) {
            // Use both global isNaN() and parseFloat() to determine if we have a numeric column.
            // isNaN() catches most non-numeric columns, but not null
            // parseFloat(null) == NaN, but a column value such as "32 UAN" will return a number (32)
            if (isNaN(feature.properties[property]) || Number.isNaN(parseFloat(feature.properties[property]))) {
                numeric = false
            }
            else {
                console.log('Found Number')
            }
        }
        if (numeric) {
             console.log(`Numeric Column: ${property}`)
        }
    }
}

File in question:
TID_822919_OID_2363808_Raven_Viper_2021-04-26-03-53-54.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant