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

Convert coordinates to WGS 84 base on the .prj file #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

knut-forkalsrud
Copy link

Let me preface this with a disclaimer: Don't merge this!
Consider it a sketch for a possible feature addition, nothing more.

The question of "reprojection" has come up several times,
in issue 5, issue 27 and issue 50. For beginners like me
it easily trips us up when trying to follow tutorials online,
but with our own map data. In retrospect I now realize
that I could simply have skipped the projection step,
instead of getting only garbage when trying to project
something that is already projected. There are Stack Overflow
answers describing this in great detail
. Before I came
to that realization I took a stab at "fixing" the coordinates.
It worked for me, so I'll share it here for other that may be
looking for the same.

This uses proj4js to read the "well known" text of
the coordinate reference system. Then as we read in
coordinates from the .shp file we map each to WGS 84
using the same proj4js library.

https://tools.ietf.org/html/rfc7946#section-4 suggests
that's the only allowed coordinate reference system in
GeoJSON.

Unfortunately this is a bit of a hack, it breaks with
streaming nature of the program. It also affects only
the command line shp2json. Accommodations for library
use are lacking. There should be a command line switch
for deciding to use the .prj transform this or not.
Arguably the mapping should not be conflated with
reading, but it was the most convenient way for me to
make it work. Tests are absent.

This uses proj4js to read the "well known" text of
the coordinate reference system. Then as we read in
coordinates from the `.shp` file we map each to WGS 84
using the same proj4js library.

https://tools.ietf.org/html/rfc7946#section-4 suggests
that's the only allowed coordinate reference system in
GeoJSON.

Unfortunately this is a bit of a hack, it breaks with
streaming nature of the program. It also affects only
the command line `shp2json`. Accommodations for library
use are lacking. There should be a command line switch
for deciding to use the `.prj` transform  this or not.
Arguably the mapping should not be conflated with
reading, but it was the most convenient way for me to
make it work. Tests are absent.
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 this pull request may close these issues.

1 participant