Question

I am working on fence violation. A tracking device sends a series of co-ords, out of this I need to create a fence with buffer.

I use shapely library for this.

from shapely.geometry import LineString
coords = [((12.898208,80.227798),(12.811857,80.228433),(12.794150,80.222705),...)]
multilines = MultiLineString(coords)
poly = multilines.buffer(1)

Now I want to store this polygon as a MongoDB GeoJson and for every point I receive from the tracker device, I want to check a $within query on Mongo.

Is there any way to convert this polygon into a bounding box, iterate all the points and create a geoJson object to store inside Mongodb. Is there any other better option?

Was it helpful?

Solution

I did not read the manual carefully. After some time I found that

boundbox = list(poly.exterior.coords)

returns what I wanted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top