shapely

Split a linestring at each point it crosses a polygon in shapely

别说谁变了你拦得住时间么 提交于 2021-02-19 08:28:39
问题 I have a linestring which spans various polygons, stored as GeoJsons. I want to split the line into individual parts within each polygon area. I have not been able to achieve this yet, however. This is a reproducible example for what I have so far: from shapely.geometry import Point, LineString, Polygon from shapely.ops import split from matplotlib import pyplot as plt poly = { 'type': "Feature", 'geometry': { "type": "Polygon", "coordinates": ([(2,2),(2,4),(4,4),(4,2)]), }, 'properties': {

Count number of points in multipolygon shapefile using Python

最后都变了- 提交于 2021-02-16 08:56:15
问题 I have a polygon shapefile of the U.S. made up of individual states as their attribute values. In addition, I have arrays storing latitude and longitude values of point events that I am also interested in. Essentially, I would like to 'spatial join' the points and polygons (or perform a check to see which polygon [i.e., state] each point is in), then sum the number of points in each state to find out which state has the most number of 'events'. I believe the pseudocode would be something like

Count number of points in multipolygon shapefile using Python

帅比萌擦擦* 提交于 2021-02-16 08:53:06
问题 I have a polygon shapefile of the U.S. made up of individual states as their attribute values. In addition, I have arrays storing latitude and longitude values of point events that I am also interested in. Essentially, I would like to 'spatial join' the points and polygons (or perform a check to see which polygon [i.e., state] each point is in), then sum the number of points in each state to find out which state has the most number of 'events'. I believe the pseudocode would be something like

Get all lattice points lying inside a Shapely polygon

孤街醉人 提交于 2021-02-13 12:17:35
问题 I need to find all the lattice points inside and on a polygon. Input: from shapely.geometry import Polygon, mapping sh_polygon = Polygon(((0,0), (2,0), (2,2), (0,2))) Output: (0, 0), (1, 0), (2, 0), (0, 1), (1, 1), (2, 1), (0, 2), (1, 2), (2, 2) Please suggest if there is a way to get the expected result with or without using Shapely. I have written this piece of code that gives points inside the polygon, but it doesn't give points on it. Also is there a better way to do the same thing: from

what is wrong with this shapely error message

只谈情不闲聊 提交于 2021-02-11 06:32:21
问题 I have a dictionary called Rsize which have number-List as key-value pair. The dictionary is like this {10: [0.6621485767296484, 0.6610747762560114, 0.659607022086639, 0.6567761845867727, 0.6535392433801197, 0.6485977028504701, 0.6393024556394106, 0.6223866436257335, 0.5999232392636733, 0.5418403536642005, 0.4961461379219235, 0.4280278015788386, 0.35462315989740956, 0.2863017237662875, 0.2312185739351389, 0.18306363413831017], 12: [0.6638977494825118, 0.663295576452323, 0.662262804664348, 0

Pip install of shapely giving “python setup.py egg_info” failed with error code 1 error

三世轮回 提交于 2021-02-09 04:15:31
问题 I am trying to install shapely 1.5.6 in Windows 10 (python 3). I am getting this strange error. python setup.py egg_info" failed with error code 1 in c:\users\user1\appdata\local\temp\pip-build-g1iztcx1\shapely I have tried updating pip but no luck. What could be the problem? 回答1: Error code 1 means the "Operation is not permitted". Usually when that happens in Linux, you can just use sudo to resolve it. But on windows, you probably have to right-click on cmd and run as administrator to

Pip install of shapely giving “python setup.py egg_info” failed with error code 1 error

冷暖自知 提交于 2021-02-09 04:14:58
问题 I am trying to install shapely 1.5.6 in Windows 10 (python 3). I am getting this strange error. python setup.py egg_info" failed with error code 1 in c:\users\user1\appdata\local\temp\pip-build-g1iztcx1\shapely I have tried updating pip but no luck. What could be the problem? 回答1: Error code 1 means the "Operation is not permitted". Usually when that happens in Linux, you can just use sudo to resolve it. But on windows, you probably have to right-click on cmd and run as administrator to

shapely.geos.ReadingError: Could not create geometry because of errors while reading input

烂漫一生 提交于 2021-02-07 20:23:12
问题 I'm getting the error in the title when I try to use shapely.wkt.loads on the following input: POLYGON((-93.577695846689437 40.813390731817726,-93.577674865779628 40.813444137603014,-93.577722549304582 40.8136196133706,-93.577945709640048 40.814004897950532,-93.5781135556297 40.814165115070466,-93.578243255589527 40.814229965262996,-93.578363418973865 40.814268111930119,-93.578405380213241 40.814252853305611,-93.578418731892242 40.814207077283442,-93.578376770009427 40.81411170971851,-93

Find holes in a union of rectangles?

眉间皱痕 提交于 2021-02-07 08:22:31
问题 I have a number of random rectangles (black) in and around a unit square (red) and need to extract all the polygonal regions inside the unit square that are not covered by any rectangle. It looks like this can be done with Shapely and I've gotten to the point when I have the union of the rectangles (green) but I'm not sure how to subtract that from the unit square and retrieve a list of polygons. Here is my code to generate the test data: import pylab import random from matplotlib import

Find holes in a union of rectangles?

女生的网名这么多〃 提交于 2021-02-07 08:21:30
问题 I have a number of random rectangles (black) in and around a unit square (red) and need to extract all the polygonal regions inside the unit square that are not covered by any rectangle. It looks like this can be done with Shapely and I've gotten to the point when I have the union of the rectangles (green) but I'm not sure how to subtract that from the unit square and retrieve a list of polygons. Here is my code to generate the test data: import pylab import random from matplotlib import