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

Add WKT / WKB representation of geometry #39

Open
tomplex opened this issue Apr 1, 2019 · 2 comments
Open

Add WKT / WKB representation of geometry #39

tomplex opened this issue Apr 1, 2019 · 2 comments

Comments

@tomplex
Copy link

tomplex commented Apr 1, 2019

This would make it a lot easier to use go-shp to interface with other libraries which implement geometry operations, like gogeos or orb.

@fawick
Copy link
Collaborator

fawick commented Apr 1, 2019

What is the usecase that you want to solve with that?

go-shp is a library for reading the shapefile binary fileformat, converting the read geometries to WKT / WKB is a bit out of scope here. For precedence, are you aware of libraries (in other languages, maybe) that provide native WKT / WKB support for shape files?

I can understand the need to have a lingua franca for geometry data to ease the pain to glue together different libraries. I am just not sure that WKT / WKB would a be a good fit for go-shp. Maybe the answer would be a subpackage?

@tomplex
Copy link
Author

tomplex commented Apr 1, 2019

Thanks for responding!

The general use case is, I have a shape file that I want to open, read geometry from, and process somehow. I don't want to write my own geometry processing algorithms because there already exist many implementations like those mentioned above, which can read their own geometry objects from wkt / wkb, but often dont implement reading of binary formats like shp or TAB - so we need to turn to libraries like this to do so.

We have "well known" formats for this reason, so that packages can support them - a relatively small interface - and easily interoperate with other packages which deal with geometry. Especially in a strongly typed language like Go, having a different implementation of geometry for every package doesn't help anything if none of them can talk to each other.

As for other languages, in Java / Geotools, you can convert a geometry read from shapefile to wkt using a factory (ugh) or using the toString() method - which would be a nice fit for Golangs Stringer interface.
In python, the default for the Fiona/Shapely packages is geojson, which is a good fit for Python because the dicts are basically valid json as is. You could argue that they work so well together because they're written by the same guy - a valid point - but it's a pleasure to work with geometry in python because all the disparate tools work together easily.

All that said, I'd be very happy to take a shot at it and submit a PR for this package with an implementation that we can iterate on, if you would be receptive to it! I think a subpackage which has conversion functions could be a great solution, and a step in a direction towards easier interoperability.

Thanks for your time!
Tom

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

2 participants