shapely

Polygon touches in more than one point with Shapely

夙愿已清 提交于 2020-05-10 10:17:38
问题 I have a list of Shapely polygons in Python. To find out which polygon touch is easy, using the .touches() method. However, I need something that returns True only when the polygons share more than one point (in other words shares a border). Let me illustrate: In [1]: from shapely.geometry import Polygon In [2]: polygons = [Polygon([(0,0),(0,1),(1,1),(1,0)]), Polygon([(1,0),(1,1),(2,1),(2,0)]), Polygon([(2,1),(2,2),(3,2),(3,1)])] In [3]: polygons[0].touches(polygons[1]) Out[3]: True In [4]:

3D Geometry Package for Python

戏子无情 提交于 2020-03-18 12:12:18
问题 I am trying to find a good 3D geometry library for Python that has similar operations and functionality to Shapely. http://toblerity.org/shapely/manual.html Shapely is great, and has exactly what I need, especially around the creation and manipulation of Linestring objects. Unfortunately, it only supports operations on 2D objects, even though 3D points can be created. Does anybody know of any a similar module that operates in full 3D? It would be greatly appreciated. Thanks. 回答1: Have a look

How do I plot Shapely polygons and objects using Matplotlib?

旧城冷巷雨未停 提交于 2020-03-18 03:28:05
问题 I want to use Shapely for my computational geometry project. I need to be able to visualize and display polygons, lines, and other geometric objects for this. I've tried to use Matplotlib for this but I am having trouble with it. from shapely.geometry import Polygon import matplotlib.pyplot as plt polygon1 = Polygon([(0,5), (1,1), (3,0), ]) plt.plot(polygon1) plt.show() I would like to be able to display this polygon in a plot. How would I change my code to do this? 回答1: Use: import

Geopandas set geometry: ValueError for MultiPolygon “equal len keys and value”

风格不统一 提交于 2020-03-03 20:31:32
问题 I have 2 geodataframes with a geometry column and I copy some geometries from 1 to the other. This works well with Polygons but returns a ValueError for any (valid) MultiPolygon. Please advice how to solve this? I don't know if / how / why I should change the MultiPolygon to get "equal len keys and value"? geodata01.loc[index, 'geometry'] = geodata02.loc[index, 'geometry'] This works well with Polygons. Only with MultiPolygons I get: ValueError if len(labels) != len(value): --> 611 raise

Geopandas set geometry: ValueError for MultiPolygon “equal len keys and value”

妖精的绣舞 提交于 2020-03-03 20:26:42
问题 I have 2 geodataframes with a geometry column and I copy some geometries from 1 to the other. This works well with Polygons but returns a ValueError for any (valid) MultiPolygon. Please advice how to solve this? I don't know if / how / why I should change the MultiPolygon to get "equal len keys and value"? geodata01.loc[index, 'geometry'] = geodata02.loc[index, 'geometry'] This works well with Polygons. Only with MultiPolygons I get: ValueError if len(labels) != len(value): --> 611 raise

Geopandas set geometry: ValueError for MultiPolygon “equal len keys and value”

半城伤御伤魂 提交于 2020-03-03 20:26:10
问题 I have 2 geodataframes with a geometry column and I copy some geometries from 1 to the other. This works well with Polygons but returns a ValueError for any (valid) MultiPolygon. Please advice how to solve this? I don't know if / how / why I should change the MultiPolygon to get "equal len keys and value"? geodata01.loc[index, 'geometry'] = geodata02.loc[index, 'geometry'] This works well with Polygons. Only with MultiPolygons I get: ValueError if len(labels) != len(value): --> 611 raise

Geopandas Dataframe Points to Polygons

╄→尐↘猪︶ㄣ 提交于 2020-02-27 08:09:14
问题 I have a geopandas dataframe made up of an id and a geometry column which is populated by 2D points. I want to join the points for each unique id to create a polygon, so that my new dataframe will have polygons as its geometry. My code currently looks something like this: polygons = geopandas.GeoDataFrame() for i in id: group = df[df['id']== i] polygon = {'type': 'Polygon', 'coordinates': group['geometry']} polygon['poly'] = polygon polygons = geopandas.concat([polygon,polygons]) It creates a

Determine the “left” and “right” side of a split shapely geometry

送分小仙女□ 提交于 2020-02-22 14:09:07
问题 My question is: how can I determine which of the Aside and Bside sides of an already split rotated rectangular geometry are the "left" and "right" side of an arbitrary LineString that splits that geometry? For the purposes of this problem, "left" and "right" are defined as the left-hand and right-hand side of a LineString splitter when "walking" from node to node, in order. I've created this function for splitting any arbitrary shapely geometry (non collection) into two sides - the "left" and

From Voronoi tessellation to Shapely polygons

自古美人都是妖i 提交于 2020-02-12 08:16:50
问题 from a set of points I built the Voronoi tessellation using scipy: from scipy.spatial import Voronoi vor = Voronoi(points) Now I would like to build a Polygon in Shapely from the regions the Voronoi algorithm created. The problem is that the Polygon class requires a list of counter-clockwise vertices. Although I know how to order these vertices, I can't solve the problem because often this is my result: (overlapping polygon). This is the code (ONE RANDOM EXAMPLE): def order_vertices(l): mlat

How to get a list of every Point inside a MultiPolygon using Shapely

两盒软妹~` 提交于 2020-01-29 19:48:32
问题 I have the following MultiPolygon : MULTIPOLYGON ( ( (10.8849956 49.8901705, 10.8849507 49.8902499, 10.884969 49.8902588, 10.8851033 49.8903298, 10.8851183 49.8903132, 10.88512882654868 49.8903054, 10.8851246 49.8903054, 10.8851246 49.8902754, 10.8851546 49.8902754, 10.8851546 49.89028643275958, 10.8853289 49.8901612, 10.885421 49.8901035, 10.8854414638889 49.8900896, 10.8854205 49.8900896, 10.8854205 49.8900596, 10.8854505 49.8900596, 10.8854505 49.89008346226415, 10.885527 49.8900315, 10