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

Does this work with just a .shp file that is not in a zip? #171

Open
GinoVillalpando opened this issue Oct 19, 2021 · 3 comments
Open

Does this work with just a .shp file that is not in a zip? #171

GinoVillalpando opened this issue Oct 19, 2021 · 3 comments

Comments

@GinoVillalpando
Copy link

I have an <input> where a user can upload a file and I noticed whenever you upload just the .shp file then you run into the following error:
image

However, using the entire zip folder works fine. Am I misunderstanding the first part in the documentation where you can use this on just the .shp file?

Here is a code snippet of the function that is using shpjs to translate to geojson:

onInputChange(file: File) {
  file.arrayBuffer().then(buffer => {
    shp(buffer).then(geojson => {
       console.log(geojson); 
    })
  })
};
@calvinmetcalf
Copy link
Owner

the way it's set up doesn't work with just a .shp file because we assume that any binary buffer passed is a zip file, BUT if you call shp.parseShp(shpBuffer) that should just (synchronously) return the geometries as an array.

@GinoVillalpando
Copy link
Author

the way it's set up doesn't work with just a .shp file because we assume that any binary buffer passed is a zip file, BUT if you call shp.parseShp(shpBuffer) that should just (synchronously) return the geometries as an array.

Thank you for the response. I should be able to work this :)

@mohammadrezaataeii
Copy link

@GinoVillalpando I have the same issue could you fix it?

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

No branches or pull requests

3 participants