Convert coordinates to WGS 84 base on the .prj file #66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 84using 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 libraryuse 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.