karimbahgat / Shapy

A lightweight pure-Python version of Shapely for working with geographical shapes.
18 stars 3 forks source link

Contributions #1

Open jzmiller1 opened 10 years ago

jzmiller1 commented 10 years ago

Hello!

I just read this blog post: http://thepythongischallenge.wordpress.com/2014/06/04/shapy-a-new-pure-python-shapely-in-the-works/

Was wondering what type of contributions you might be interested in?

karimbahgat commented 10 years ago

Hey Zac!

Good to hear you might want to contribute to Shapy! Well below is an overview of the features that are currently supported or not for the different geometries (for each geometry type I just write the single variety, e.g. Point for both Point and MultiPoint).

One of the harder things that I would appreciate some help on and that is quite useful is working out a line-polygon intersect function, returning and clipping the lines that are within polygon boundaries. If you just work out such a function that takes a linelist of xy pairs and returns a new linelist then I can figure out how and where to place it in the package.

Another thing that I haven't been able to do is to give the linebuffer a round jointype, using some sort of arc algorithm and figuring out the correct angles, with a user-allowed level of precision/detail (how many points) in the arc. There is a basic arc-method in the "geomhelper.py" module in Shapy's Pydraw subpackage which is based on some code I found, and I tried using it in the LineString's buffer method but I can't get it working properly.

But I guess it depends what you are good at. Are there any of the missing areas that you feel you could and would prefer to do? Currently, I'm working on the remaining distance features so maybe not those.

Completed clipping features (intersect,union,etc)

Point LineString Polygon
Point
LineString
Polygon X

Completed comparison features (contains, within, etc)

Point LineString Polygon
Point
LineString
Polygon

Completed buffer jointypes

Miter Round Bevel
Point X
LineString X
Polygon X X X

Completed distance features

Point LineString Polygon
Point X X X
LineString X
Polygon X
jzmiller1 commented 10 years ago

Hello again! I kind of started by looking at a different part of the project. I was interested in using pyshp to get data to feed into shapy. I've been working on some code for geo_interface to allow the properties and other options fields to cross back and forth between pyshp and shapy. Here is what I have so far if you'd like to take a look and comment. I have not tested it beyond point and polygon data yet.

https://github.com/jzmiller1/Shapy/commit/93ef64aeb06130d3127039374bba439282a2292e

Here's what I have on the pyshp side just in case you are interested:

https://github.com/jzmiller1/pyshp/commit/ba4296bdaefbc215499a30fc7c976b69622c72cf

karimbahgat commented 10 years ago

That's pretty cool, and very useful, since then the bbox doesnt have to be recalculated and the attribute values can follow the geometrical operations automatically and it will be much easier to perform spatial joins etc.

A bit busy lately but I'll try to take a look at it soon. Maybe by then you'll have time to fix it for the other geometry types as well. I briefly saw you code though, and was wondering if instead of subclassing the Mixin class (thus limiting the geometry classes if they want to subclass something else later on) you could simply have each geometry's geo_interface property call on and pass the necessary arguments to the Mixin class and have it return the geojson dictionary and then return that?

jzmiller1 commented 10 years ago

The mix in class should not impact subclassing something else because the mixin only has methods related to the Geo_interface so doing multiple inheritance should be painless. Let me know what you think once you get a chance to take a look. I am trying to put a similar interface together for pyshp.

jzmiller1 commented 10 years ago

Any chance you've had some time to review the geo_interface code?