python,ubuntu,importerror,anaconda,shapely

That happens because apt-get installs packages to the system default python, under /usr/python2.7/lib/site-packages. Anaconda has its own package manager, conda, which you might want to use in your case. conda install shapely should do the trick.

From your question, it looks like you are running your code inside of an IPython (qt)console? The problem appears to be unrelated to Shapely, but rather some issue with IPython trying to render/draw your LineString as a vector image (in SVG format). Using ipython qtconsole: In [1]: from shapely.geometry import...

python-2.7,gis,shapely,kartograph

I had a look at shapely and it seems like you are using an outdated version. Update your current install: pip install -U shapely ...

Rather than buffering a geometry, which is expensive and imperfect (since buffering requires a number of segments and many other options), just see if the point is within a distance threshold: if route.distance(p) <= r: return route.project(p) Also, you probably realised by now that your distance units are in degrees....

python,polygon,shapely,multilinestring

Probably not the best code, but I solved it by loading the points shapefile (where the points attributes were), the lines shapefile (where the lines attributes were) and polygons (buffered points). Then I used 2 'for' to check if each buffered point intersected each line. If it did, I retrieved...

If you specifically want to construct your Polygon from the shapely geometry Points, then call their x, y properties in a list comprehension. In other words: poly = Polygon([[p.x, p.y] for p in pointList]) print(poly.wkt) # prints: 'POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))' Note that...

Creating your own way of making the arc in python isn't necessarily slow. Numpy is excellent for operations along these lines, and shapely is deliberately intended to interoperate well with numpy. For example, import numpy as np import shapely.geometry as geom # Define the arc (presumably ezdxf uses a similar...

Break up Line1_string into a list of simple line segments, and check if each segment intersects. Use a pairwise recipe from itertools: from itertools import tee def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) return izip(a, b) # Convert input line into list...

python,windows,gdal,shapely,ogr

The crash is most likely a well documented gotcha. Similar work can be done with Shapely, which doesn't have that gotcha. Also, the query in the for loop can be done faster by using an Rtree index, there are a few Q&A's related to shapely + Rtree out there....

They are inverse relationships: A contains B, and B is within A. >>> A.contains(B) True >>> B.within(A) True +----------------------------------+ | | | +----------+ | | | | | | | | | | | | | | | | | | | | | | | B | | |...

Keep a dict of objects mapped to A,B and C, a set of matched objects and only add the single elements that have no matches after we get to a new letter if they are not in our matched set as all possible combinations will have been tested: from shapely.geometry...

python,pandas,apply,geojson,shapely

Thanks, DSM, for pointing that out. Lesson learned: pandas is not good for arbitrary Python objects So this is what I wound up doing: temp = zip(list(data.geom), list(data.address)) output = map(lambda x: {'geometry': x[0], 'properties':{'address':x[1]}}, temp) ...

python,geolocation,shapely,utm

Shapely only uses the Cartesian coordinate system, so in order to make sense of metric distances, you would need to either: project the coordinates into a local projection system that uses distance units in metres, such as a UTM zone. buffer a point from (0,0), and use a dynamic azimuthal...

All of your geometries are invalid. [p.is_valid for p in polygons] # [False, False, False, ...] If you look closely at your plot, the lines used for each LinearRing cross near the start and end. This makes Polygons invalid, which inevitably yield unpredictable results. Here's my version of what you...

Fundamentally, a precision model is needed, and there are various plans to implement this into GEOS at some time (don't hold your breath, as this has been under discussion for several years). Otherwise, the options are distance-based tests (recommended) or more expensive buffer-based techniques by a small adjustment (see machine...

numpy,matplotlib,polygon,shapely

This type of intersection is easily done by the "min of the maxes" and "max of the mins" idea. To write it out one needs a specific notion for the rectangle, and, just to make things clear I'll use a namedtuple: from collections import namedtuple Rectangle = namedtuple('Rectangle', 'xmin ymin...

python,python-2.7,python-3.x,numpy,shapely

Without downloading shapely, I think what you want to do with lists can be replicated with strings (or integers): In [221]: data=['one','two','three'] In [222]: data1=['one','four','two'] In [223]: results=[[],[]] In [224]: for i in data1: if i in data: results[0].append(i) else: results[1].append(i) .....: In [225]: results Out[225]: [['one', 'two'], ['four']] Replace...

The GIS term you are describing is linear referencing, and Shapely has these methods. # Length along line that is closest to the point print(line.project(p)) # Now combine with interpolated point on line np = line.interpolate(line.project(p)) print(np) # POINT (5 7) ...

Sure it does, see shapely.ops.cascaded_union. There is no equivalent for intersection, but you just need to accumulate a result: result = a.intersection(b) result = result.intersection(c) More tricks here....

If you're just after a collection of polygons you don't need to pre-order the point to build them. The scipy.spatial.Voronoi object has a ridge_vertices attribute containing indices of vertices forming the lines of the Voronoi ridge. If the index is -1 then the ridge goes to infinity. First start with...