shapely

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

纵饮孤独 提交于 2020-01-29 19:46:26
问题 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

Error importing Polygon from shapely.geometry.polygon

爷,独闯天下 提交于 2020-01-13 18:40:33
问题 In my Anaconda 2.2 64bit with Python 3.4.3 the following line works well: import shapely But the following line: from shapely.geometry.polygon import Polygon returns the following error: OSError: [WinError 126] The specified module could not be found What am I missing? EDIT I tried with iNotebook, idle.exe and Eclipse. They all use Anaconda (the only Python installation on my computer) and they all show the same error. If I type from shapely.geometry import Polygon in Eclipse, then I click on

How do I get Python libraries in pyspark?

梦想的初衷 提交于 2020-01-09 09:07:06
问题 I want to use matplotlib.bblpath or shapely.geometry libraries in pyspark. When I try to import any of them I get the below error: >>> from shapely.geometry import polygon Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named shapely.geometry I know the module isn't present, but how can these packages be brought to my pyspark libraries? 回答1: In the Spark context try using: SparkContext.addPyFile("module.py") # also .zip , quoting from the docs:

How to convert NumPy arrays obtained from cv2.findContours to Shapely polygons?

白昼怎懂夜的黑 提交于 2020-01-04 09:32:47
问题 I am using CV2 to find contours from an image and then converting them into polygons using Shapely. I am currently stuck because when I try putting one of the contour arrays into Polygon() from Shapely it throws an unspecified error. I have double-checked that I imported everything I needed, and that creating a Shapely polygon works when I manually enter the array coordinate points. Here is the problematic section of the code: contours, hierarchy = cv2.findContours(thresh, cv2.RETR_CCOMP, cv2

How to convert NumPy arrays obtained from cv2.findContours to Shapely polygons?

删除回忆录丶 提交于 2020-01-04 09:32:28
问题 I am using CV2 to find contours from an image and then converting them into polygons using Shapely. I am currently stuck because when I try putting one of the contour arrays into Polygon() from Shapely it throws an unspecified error. I have double-checked that I imported everything I needed, and that creating a Shapely polygon works when I manually enter the array coordinate points. Here is the problematic section of the code: contours, hierarchy = cv2.findContours(thresh, cv2.RETR_CCOMP, cv2

How to extract Polygons from Multipolygons in Shapely?

醉酒当歌 提交于 2020-01-01 08:55:06
问题 I'm trying to extract the polygons from multipolygons in Shapely. I can transform a list of polygons into multipolygons using MultiPolygon from Shapely. >>> Multi = MultiPolygon([shape(pol['geometry']) for pol in fiona.open('data.shp')]) And, >>> Multi.wkt 'MULTIPOLYGON (((249744.2315302934148349 142798.1643468967231456, 250113.7910872535139788 142132.9571443685272243, 250062.6213024436729029 141973.7622582934272941, 249607.7787708004761953 141757.7120557629095856, 249367.7742475979903247

Polygon containment test in matplotlib artist

情到浓时终转凉″ 提交于 2020-01-01 06:57:47
问题 I have the following code, gathered initially from here., which uses matplotlib, shapely, cartopy to draw a world map. When a click is made, I need to determine on which country it was made. I am able to add a pick_event callback to the canvas, however, it is called on every artist.(cartopy.mpl.feature_artist.FeatureArtist, which corresponds to a country). Given an artist and a mouse event with x, y coordinates, how can I determine containment? I've tried artist.get_clip_box().contains , but

Determine if Shapely point is within a LineString/MultiLineString

懵懂的女人 提交于 2019-12-29 07:50:14
问题 I am trying to use Shapely's within function to do a 'spatial join' of a LineString and a Point file (FYI, the point file was generated using the interpolate function on the LineString ). Problem is - nothing is being returned. # this condition is never satisfied if point.within(line): # here I write stuff to a file where: point = POINT (-9763788.9782693591000000 5488878.3678984242000000) line = LINESTRING (-9765787.998118492 5488940.974948905, -9748582.801636808 5488402.127570709) What am I

Find coordinate of the closest point on polygon in Shapely

走远了吗. 提交于 2019-12-29 04:34:28
问题 Say I have the following Polygon and Point: >>> poly = Polygon([(0, 0), (2, 8), (14, 10), (6, 1)]) >>> point = Point(12, 4) I can calculate the point's distance to the polygon... >>> dist = point.distance(poly) >>> print(dist) 2.49136439561 ...but I would like to know the coordinate of the point on the polygon border where that shortest distance measures to. My initial approach is to buffer the point by its distance to the polygon, and find the point at which that circle is tangent to the

Define points within a polygon

风流意气都作罢 提交于 2019-12-26 02:56:08
问题 I have a list of customers lat and long and I want to define which ones are within a given polygon. But the results I got are none of them in that polygon and it is not correct. Could you please help? Thanks! from shapely.geometry import Polygon from shapely.geometry import Point import pandas as pd import geopandas as gpd df=pd.read_csv("C:\\Users\\n.nguyen.2\\Documents\\order from May 1.csv") geometry=[Point(xy) for xy in zip(df['customer_lat'],df['customer_lng'])] crs={'init':'epsg:4326'}