Questions tagged [shapely]

Shapely is an open source Python package for construction and analysis of 2D planar geometric objects common to geographic information systems.

Filter by
Sorted by
Tagged with
2
votes
1answer
15 views

Matching points to polygons and handling points NOT in polygons

I have two GeoDataFrames: one with 191k address points and another with 18 polygons representing catchment areas for specific schools. Theoretically, every address should fall into one of the zones. ...
1
vote
0answers
23 views

Making a polygon from list of xy coordinates using Shapely

I am new to Python (moving over from Matlab) and am trying check if a set of points are inside a polygon using Shapely as I am not able to install GeoPandas (tried for over a week now and am tired of ...
0
votes
0answers
28 views

Iterating over dataframe and checking points using shapely

I am getting the error when I try to delete row from dataframe. The code checks if polygon contains points. If not I would like to delete this row, but I am getting the error. Why? Error: IndexError: ...
0
votes
1answer
41 views

Counting points and adding to column with shapely

I have a small dataframe and created new column. I would like to add to every record in column 'vertex_counter' value of n. I have the problem because it is doesn't work and I have in every record in ...
3
votes
1answer
32 views

Converting a string to LineString

I have a string read from a csv file: 'LINESTRING (-79.494722 43.777724, -79.494805 43.777636, -79.49503799999999 43.777581, -79.495277 43.777524)' I want to convert this string object to shapely....
1
vote
1answer
32 views

Checking if geopoint is in shapefile containing world cities

I have approximately 13 million (lat,long) geocoordinates. I also have a shapefile containing 3460 cities. I need to find the City in which this geocoordinate can be found. This is what I am currently ...
4
votes
0answers
27 views

Identify U curves in route

I'm trying to identify the mountain roads in a route, and I've thought that a good approach could be get the paths with a very closed curve (like a U turn), but now I can not find any documentation ...
2
votes
1answer
38 views

Shapely strange splits when splitting LineString and Polygon

I noticed a strange behavior while splitting a LineString with e Polygon: in the below image I have a Polygon (in green) and two lines. If I split the blue Linestring with the polygon the result of ...
0
votes
1answer
55 views

How can I set the CRS of a point with shapely

I am working on a tool, which transfers data, including geometries, from different legacy databases to postgis. Currently this means I have a MS-access Database, which contains point geometries, but ...
0
votes
0answers
26 views

Angle in minimum_rotated_rectangle [duplicate]

I have a simple question, but I can't find the answer I am looking for the principal angle of a minimum_rotated_rectangle polygon in relation to a latitude or a longitude. df4....
1
vote
2answers
44 views

Splitting line GeoDataFrame basing on given lengths

I am trying to split line GeoDataFrame into sections. I have lengths on which splits should be made stored in column. My idea was to generate points along the line using shapely.ops.interpolate and ...
1
vote
0answers
30 views

How to merge lines from shapefile using PyShp and Shapely and save them in a new shapefile?

I have files with line segments that cover road network of towns. The issue is that each street with specific name consists of smaller segments that I need to merge into one line covering the whole ...
0
votes
0answers
42 views

What's the theory (principle) behind shapely.ops.polygonize?

I am learning Python package Shapely, but quite confused about the principle behind the polygonize function --- shapely.ops.polygonize. How does this function work to polygonize a set of lines (...
-2
votes
1answer
31 views

Seeking Python solution for point, line, and poly in poly intersections [closed]

I'm just learning Python, and I need a little direction. I've been reading many of the posts on this site, but I haven't found one that puts me on the right path. These operations are trivial in GIS ...
2
votes
1answer
62 views

Create 3D lines at a specific distance and bearing from a 2D polygon using Shapely and Geopandas

I have a shapefile of the runways(polygons) of different airports: I want to build a line that represents the 3D trajectory followed by an airplane 9 km after take off and 18 km before landing and ...
1
vote
1answer
51 views

Dump multiple geometry columns of a GeoDataFrame to Features in a FeatureCollection (GeoJSON) instead of properties?

I have a GeoDataFrame with some of its attributes that are geometries (only the position is the one which was interpreted as the active geometry when loading the data from PostGIS): import psycopg2 ...
0
votes
0answers
63 views

Calculate Distance between 2 Shapely Points in Meters

I am trying to calculate the distance (in meters) between 2 lon/lng points of type shapely.geometry.point.Point using Python and Shapely. These 2 points are returned from PostGIS by SQLAlchemy/...
1
vote
1answer
24 views

Create square grid on raster file

I have tried to create a fishnet(10 by 10) using the below code. But the output is as shown below. What is that I'm missing in the below code? import geopandas as gpd from shapely.geometry import ...
4
votes
0answers
61 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 (...
1
vote
1answer
49 views

Negate the shapely intersection predicate

I have two Shapely geometries: 1 MultiPoint instance named multipoints 1 Polygon instance named polygon I can compute their intersection by: multipoints.intersection(polyon) which results in all ...
4
votes
1answer
90 views

Excluding self-intersections when performing a linestring difference in shapely

I have a (complex) LineString (with 1 self-intersection): ls_self_intersection = LineString([(1, 2), (4, 2), (4, 3), (3, 3), (3, 1)]) and I have a (simple) LineString (with no self-intersection): ls =...
0
votes
1answer
47 views

Interpolating LineString by adding new Point in middle between each two points [closed]

I want to add interpolated points in a LineString using shapely. The interpolated points should be in the middle of every two Points present in the LineString. The shapely interpolate function adds ...
2
votes
1answer
31 views

Error when calculating final polygon after subtracting all intersecting polygons using shapely

This question is a follow-on question from Calculating final polygon after subtracting all intersecting polygons using shapely which was answered. I have a list of centroids that I buffer to 5000 ...
4
votes
1answer
65 views

Obtaining a transform for Affine transformation (Cartesian to geodetic coordinate system)

I have a Line, defined as 2 points in a Cartesian coordinate system. Shapely allows projecting this line with an affine transformation if a transform is specified. from shapely.geometry import ...
2
votes
1answer
46 views

Calculating final polygon after subtracting all intersecting polygons using shapely [closed]

I have a list of centroids that I buffer to 5000 meters radius. I need to take each resulting circle and run it against the remaining centroids(also buffered to 5000 m) and find the final shape after ...
2
votes
1answer
24 views

Can't Form DataFrame from Parallel Offset Output

I've been developing code to take a .csv with lat-long coords and convert them to LineStrings before creating parallel offsets for them. This has been working so far, but yesterday after clearing my ...
5
votes
1answer
72 views

Finding the closest point to a polygon in a shapefile using GeoPandas

I have the following map of statistical regions of Belgium: The blue dots correspond to coordinates for which I have temperature data. Surrounded by the red circle is Brussels. As it can be seen, ...
1
vote
1answer
100 views

Shapely command error: from shapely.geometry import LineString

I am trying to run a program but getting the following error when I am using the command: from shapely.geometry import LineString Error: FileNotFoundError: Could not find module 'C:\Users\SWWB\...
3
votes
1answer
143 views

python rioxarray.clip masking netcdf data with a polygon returns all nan

My question is similar to what others have already asked but the posted solutions haven't worked for me. The similar posts are masking a netcdf file using a shapefile of points with rioxarray and how ...
1
vote
0answers
37 views

Geopandas .difference between two different shapes produces empty difference

I have been puzzled by this, and I feel like it's a geopandas bug. base = gpd.GeoSeries(dist_to_remove).plot(edgecolor='black', color='yellow') gpd.GeoSeries(prec_shape).plot(ax = base, color='red', ...
3
votes
0answers
26 views

Calculating population within a circle excluding intersects with shapely

I have a data of a centroid and a count: centroid population id 0 POINT(38.9081 77.0349) 9004.0 0 1 POINT(38.8521,77.0377) 517.0 1 2 POINT(38.9081 77.0377) 10369.0 ...
1
vote
0answers
21 views

Create Polygons in Python that use the max extents to make a box

I have field collected data that is usually collected with 6 points to create a form of polygon. I can subset those 6 points and create the polygon no problem, with this code: eastList = channelFilter[...
0
votes
1answer
48 views

Finding duplicate shapely polygons (same polygons with different points) [closed]

I am interested in finding out duplicate shapely polygons having different points but covering the same area. For example, let assume I have 2 polygons: poly1 = POLYGON((4 1, 30 1, 45 1, 45 6, 12 6, 4 ...
6
votes
3answers
171 views

Multipolygon supposed to be contained by another but returned False with Shapely

There are two multi-polygons a and A where a is supposed to be contained inside A. Using shapely, the following difference operator b = a.difference(A) print(b) gives POLYGON EMPTY However testing A....
0
votes
1answer
207 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 ...
1
vote
0answers
15 views

Attribute network features (lines) with data from their endpoint

Goal To prioritize water lines in a network based on the building they service Detail I have a shapefile of water lines in a region. The lines are split at their vertices and form a network (more or ...
4
votes
1answer
200 views

What exactly are cap_style and join_style in shapely buffer function?

I was trying to make a function that modifies polygons removing narrow spaces inside (setting a minimum distance between a vertex and a segment that is not adjacent) and at the same time remove sharp ...
1
vote
1answer
122 views

How to create a raster delineating all drainage basins using pysheds python

I am going through the tutorial of "Pysheds" available in the following website https://www.hatarilabs.com/ih-en/elevation-model-conditioning-and-stream-network-delimitation-with-python-and-...
2
votes
1answer
38 views

Affine Tranformation Matrix; shapely asks 6 coefficients, but rasterio delivers 9; how to translate

Some lines have been extracted via scikit-image, now tho goal is to vectorize them within the origin coordinate reference system #some geotif opened with rasterio src = rasterio.open(raster_path) ...
3
votes
1answer
129 views

Buffer around Point is elliptical, not circular

I'm trying to create a circle around a point using the code from this answer here. Adding below for better visibility as well from functools import partial import pyproj from shapely.ops import ...
6
votes
2answers
171 views

Self split geopandas Linestring geodataframe in a fast way without loosing all attributes

I have geodataframe of many LineStrings. The LineStrings intersect but are not split at those intersections. My current solution to achieve this is from here: network = gp.read_file(filenameNetwork) ...
0
votes
1answer
18 views

Drop Linestring geometry from a GeoDataFrame

I try to create a shapefile of the FAO/GAUL/2015/leve1 country regions of the LMIC's countries. For that I decided to use Python as it gave me access to the earthengine API and the geopandas librairy. ...
0
votes
1answer
141 views

How to create a GeoPandas GeoDataFrame from rasterio features?

I try to create a GeoDataFrame of paches of same values in a binary raster using rasterio and GeoPandas. data_file is a binary TIFF raster with 0 where there is no deforestation and 1 if there is a ...
1
vote
2answers
95 views

Masking a NetCDF file using a shapefile of points with rioxarray

I took the proposed solution from this question (How to mask NetCDF time series data from a shapefile in Python?) and tried to implement it. However, whenever I apply this solution it seems to set all ...
2
votes
1answer
177 views

What is the algorithm that Shapely used to check if two polygons intersect?

What is the algorithm that Shapely used to check if two polygons intersect? from shapely.geometry import Polygon p1 = Polygon([(0,0), (3,0), (3,1), (1,1), (1,2), (3,2), (3,3), (0,3)]) p2 = Polygon([(4,...
0
votes
1answer
202 views

Removing duplicate points in GeoPandas using distance and time

I have a list of of coordinates that have areas mapped out on a map user_id id latitude longitude requested_at 84 106 13.0472367 77.5022635 12-10-2020 14:59 84 107 13.0472789 77.5024498 ...
3
votes
2answers
379 views

“Multi-part geometries do not provide a coordinate sequence” error when extracting the long and lat of start and end points in GeoPandas

I am trying to extract the start and endpoint coordinates in GeoPandas. Following this link, I am using this code to extract the start and endpoints for GeoJSON files. def add_start_end_nodes_to_gdf(...
6
votes
1answer
112 views

Creating polygon from two not connected linestrings using shapely

I'd like to know if there is a way to create a polygon in shapely from two not connected linestrings. I've been struggling with this question from some hours now and I can't find a way to deal with it....
0
votes
0answers
77 views

Symmetrical Difference using fiona and shapely

I have a polygon that I want to merge into an existing polygon. To do this I first need to run symmetrical difference between the two overlapping polygons, and then merge them. Before symmetrical ...
0
votes
0answers
22 views

Iteratively polygonize MultiLineString

I have an implementation of alpha-shape below. My goal is to compute the polygons for a list of alphas but do it as fast as possible. LineProfiler showed that almost all of the time is spent in list(...

1
2 3 4 5
14