Questions tagged [shapely]
Shapely is an open source Python package for construction and analysis of 2D planar geometric objects common to geographic information systems.
953 questions
0
votes
2
answers
2k
views
GEOSGeom_createLinearRing_r returned a NULL pointer
I want to import cartopy on Python3, but it keeps showing me
File "shapely\speedups\_speedups.pyx",
line 408, in shapely.speedups._speedups.geos_linearring_from_py
...
0
votes
1
answer
459
views
Spatial Join does not return no point inside geometry Python
I have a geodataframe containing 200 000 entries with Points, and I want to check which coordinates are inside a geodataframe containing 20 000 polygons that I am creating. The polygons are created ...
0
votes
1
answer
1k
views
How to determine the order of shapely's intersection function between two LineStrings
I want to find all the Point intersections between two shapely LineStrings. It is possible that there are multiple intersections and hence the output can be a MultiPoint. How do I know that the output ...
7
votes
1
answer
2k
views
Convert the geometry column of a GeoDataFrame with mixed geometry types to a unique multi-type
I have a GeoDataFrame where I have a mix of geometry types in its geometry column, some are multi-geometry types, some are single geometry types, some are empty geometry types, and others are None (...
3
votes
1
answer
558
views
Compute the distance from a point to polygon given the point and direction
I want to compute the distance from a point to a polygon given the point and direction. Currently I am using shapely and defining a "somewhat" infinite line string. This is not ideal as I ...
1
vote
1
answer
1k
views
Polygonizing raster cells in rasterio regardless of value?
I would like to polygonize every single cell of a raster dataset using rasterio. I have been experimenting with the following function based on this question:
def polygonize_raster(dataset):
# ...
1
vote
1
answer
1k
views
Python Shapely crop / clip using 'intersection': cropped line is split at self-intersections
In using 'intersection' to crop / clip a single 'braided' line using a rectangle (actually a grown version of that rectangle using 'buffer'), the internal portion of the line gets split on self-...
5
votes
2
answers
5k
views
"ValueError: Must have equal len keys and value when setting with an iterable" when setting geometry for row with .loc and MultiPolygons in GeoPandas
Given the following example:
def merge_with_largest(input_gdf,poly):
# select the polygons bordering polygon
close_by_gdf = input_gdf[input_gdf.geometry.intersects(poly)]
# selects ...
2
votes
1
answer
2k
views
Shapely intersection between LineString and multiple Polygons
I am trying to get a function to return True when a LineString intersects with any polygon in a list of polygons. Currently, I am using a for loop to iterate through all the polygons and check one by ...
1
vote
1
answer
229
views
Splitting LINESTRING at given POINT using split function from shapely
I have a geopandas dataframe that looks likes this:
level_0 id \
0 0 028f342a-b26f-4e36-b5d1-25d3428cac2f
1 1 028f342a-b26f-4e36-b5d1-...
2
votes
1
answer
2k
views
Creating LineString from points using shapely
I am creating a linestring from points using shapely, but I could not generate the linestring using the points on my local system. This code is running fine on Google Colab. Is there any package ...
0
votes
1
answer
3k
views
Converting a WKT column to type Geom
I have the following table in my MariaDB database:
This table contains a column called 'coordinates' (type: LONGTEXT) with a wkt representation of either a MultiPolygon or a Polygon. I am attempting ...
1
vote
1
answer
254
views
Shapely Intersection, registering that there is an intersection but not calculating area properly
I am having trouble calculating the area of an intersection of two shapely GeometryCollections which have been created from two GeoJSON multipolygons that represent drivetimes.
I want to check for two ...
2
votes
4
answers
3k
views
Get a numpy array out of a GeoDataFrame of shapely Points in shapely >=2.0
I had the following code in shapely 1.8.5.post1 which was working but was throwing a warning:
import os
os.environ['USE_PYGEOS'] = '0'
import numpy as np
import geopandas as gpd
from shapely.geometry ...
3
votes
2
answers
597
views
Adding intersection vertices to Shapely's LineString with Python
Assume that I have two shapely LineStrings. I want to find their intersection and then add the intersection point as vertices into the respective LineStrings.
from shapely.geometry import LineString
#...