6

I am looking for JavaScript options that allow me to take a set of shapefiles (the .shp, .shx, .dbf, and what ever other related files) and convert them into geoJSON.

I am then going to take this geoJSON and save it to the database.

I have found a number of options:

1) https://github.com/wavded/js-shapefile-to-geojson

2) https://www.npmjs.com/package/shapefile

I believe number 2 is my best option but I can't seem to confirm that it will allow me to give it more than one shapefile to convert to geoJSON. Do you know of any libraries that allow for multiple shapefile types to be used as input at one time?

3
  • 1
    I think this question should be re-opened. But just so you're aware, the .shp, .shx, .dbf, etc are part of the same shapefile. Most tools expect you to point to the .shp and will then look for the remaining files in the same directory (because not all of them are required). The different parts must have the same name (only different in their file extension). Commented Oct 24, 2017 at 21:22
  • 1
    I thought .shp, .shx, and .dbf were required and there could be more on top of that? That's helpful though, thanks.
    – joe
    Commented Oct 24, 2017 at 21:40
  • 2
    Yes I believe those are the only three required files, and the rest are optional. I think there are about 13 optional files. Commented Oct 24, 2017 at 21:46

1 Answer 1

1

In 2020, you have such options, yes, I agree, https://www.npmjs.com/package/shapefile is a good one,

https://github.com/calvinmetcalf/shapefile-js

https://github.com/wavded/js-shapefile-to-geojson

https://github.com/RandomEtc/shapefile-js

https://www.npmjs.com/package/shapefile

3
  • It's probably worth noting that (near the end of 2021...) the package you recommend has not been updated in 4 years.
    – Coderer
    Commented Dec 10, 2021 at 16:09
  • yes. it not update for a long time, but it still works like charm.
    – hoogw
    Commented Dec 11, 2021 at 17:03
  • The package has at least one dependency that's now flagged as having a security vulnerability. I haven't checked in with the author but using unsupported packages will often bite you eventually (even though it may take years...)
    – Coderer
    Commented Dec 15, 2021 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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