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
0
votes
1answer
187 views

Add attributes to an output shapefile schema (via meta)

I am trying to copy the schema of an existing shapefile and add to it in an output shapefile. Somehow I am not getting anywhere with this...though the docs seem very clear (and the download page : ...
0
votes
1answer
1k views

Calculating intersection between points and polygon in shapefile

I want accomplish the following using command line python tools only (shapely + fiona) I was wondering if there was a straightforward way for me to do the following: Read in a shapefile (all ...
0
votes
1answer
116 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
1answer
15 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
0answers
110 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 ...
0
votes
0answers
48 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(...
0
votes
1answer
53 views

GeoPandas setting geometry for a row with .loc and Multipolygons

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 ...
0
votes
0answers
34 views

Shapely adds more vertices to a polygon for smother snapping

I'm using shapely to snap together some polygons. The problem is that snapping in shapley only supports vertices to vertices snapping (i.e. a vertices from a polygon can only ever snapped to the ...
0
votes
1answer
36 views

Find vertices of LineStrings within Polygon - Shapely

I would like to use Shapely to find the vertices that are located within the boundaries of a Shapely Polygon. So far, I could only manage to get it running by converting the LineString and the Polygon ...
0
votes
1answer
21 views

Implement Rtree index to custom objects list

I'm trying to improve a spatial calculation, and I think the most efficient way is to add a spatial index, but I'm not sure how to do it. In one hand I have a list of custom objects, with a geom ...
0
votes
1answer
41 views

shapely split function does not work on short line

I am trying to split a line with multiple points. I adopt the solution in here, but sometimes it does not work. from shapely.geometry import LineString, MultiPoint from shapely.ops import split line =...
0
votes
2answers
188 views

How to convert shapely geometry linestring into shapefile?

I have extracted linestring from Landsat images. now, I am literally stuck what to do? I want to convert it into shapefile. It is actually coastline geometry. **In[1]:** type(water_lines_smooth) ...
0
votes
1answer
18 views

How to add intersection vertices to a ShapelyLinestring?

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 #...
0
votes
0answers
1k views

Python Shapely could not find 'geos_c.dll' in Windows 10

I was trying to install and work on 'Shapely' library of python on Windows 10. Installation was successful but when I tried to import it then it gave error : OSError: Could not find lib geos_c.dll or ...
0
votes
0answers
160 views

Shapely WKT dumps and loads does not always preserve rounding_precision

Shapely's WKT loads and dumps can be useful for rounding overprecise geometries, as pointed out here (Rounding all coordinates in shapely?) and here (Geopandas [Shapely] spatial difference: ...
0
votes
1answer
35 views

Problem with intersection between two Geopandas Dataframes

I have 2 shape files one "country.shp" (containing the tiles geometry covering the whole country) & other "district.shp"(containing one particular district). Now I want to get the tiles ...
0
votes
0answers
31 views

How do I get shapely polygon intersection area?

In an example case, at debug point, y=40000, x=1500, z=0. Small polygon is totally inside big and I thought z should be 1500. contains doesn't find the case at all. for big_polygon in big_polygons: ...
0
votes
0answers
35 views

Plotting via GeoPandas but only one point shows. What's wrong with my code? Map and points are in same projection

I've been stuck at this for two weeks and have tried already solutions online. I am using Python 3.8. from shapely.geometry import Point import geopandas as gpd from geopandas import GeoDataFrame ...
0
votes
0answers
89 views

Shapely's unary_union very slow!

I am trying to execute unary_union on a GeoDataFrame to run Shapely's nearest_points() method. It is taking a very long time! The set is around 6,500 points. Is there a better way to find nearest ...
0
votes
1answer
27 views

Computing linestring between two different point shapefiles

I have two point shapefile representing towns within a state and I want find the distance between them. Since the points are in different shapefiles, should I merge them so they would be in the same ...
0
votes
0answers
18 views

how to output convex_hull polygon of points shapefile [duplicate]

i have a shapefile of more than 8 points and i have written a code get the convex_hull geometry of of the points and output it as a shapefile using fiona. however the code returns an error saying: ...
0
votes
0answers
24 views

how to dervive co-ordinates of points from a Multipoint shapefile [duplicate]

i have a point shape that i extracted from a polygon and now i want to get the co-ordinates of those points before using them to create a convex hull. do anyone know how i can get the co-ordinates in ...
0
votes
1answer
273 views

How to drop rows from a GeoPandas dataframe that are raising errors, in this case: TopologyException, Ring Self-intersection

I am trying to find the points from a geopandas frame that are inside the polygons from another geopandas frame. The code that I am using is the following: points[points.geometry.within(polygons....
0
votes
0answers
50 views

Error whenever I try to geocode

I used this code to calculate my centroid and the centriod co-ordinates I get is "314167.7583680855,239312.8503371872". however whenever I try to geocode this co-ordinate I get an error. ERROR: ...
0
votes
0answers
757 views

Geopandas geodataframe copy with where clause causes geometry issues

Question up front: What is likely happening here, where when I take copy of the dataframe with a where clause present that there is an apparent break in the geometry, as implied by the linestring ...
0
votes
0answers
11 views

GeoPandas alters coordinates after saving and reopening [duplicate]

I have a Linestring out of which I take the last coordinate tuple and define it as a Point. I save both objects with geopandas as two shapefiles. Later I reopen both objects and I find the Point-...
0
votes
0answers
9 views

Linear projection going astray

I have developed a tool that tries to find a path connecting a set of telecommunication network equipment along a given road network. Since the equipment is located at various distance from the road ...
0
votes
0answers
42 views

Create vector mbtiles file from Shapely geometry using GDAL/OGR

I am looking for an example of creating vector mbtiles file from Shapely geometry using GDAL/OGR. Like this: from osgeo import ogr from shapely.geometry import Polygon poly = Polygon([(0, 0), (0, 1),...
0
votes
0answers
42 views

Issue exporting GeoPandas dataframe

I am trying to export a GeoPandas Dataframe looking like this to an external file: id geometry 0 POLYGON ((39.92713 1.41394, 39.92703 1.41394, ... 1 POLYGON ((39.95126 1.41866, 39.95116 1....
0
votes
0answers
78 views

How to find the points of hausdorff_distance()?

The Shapely hausdorff_distance() function returns a single (scalar) value. Is there a way to get the/a pair of points on both geometries that fit this distance? Similar to how we have ...
0
votes
0answers
42 views

Where can I find the source code of shapely.geometry.multilinestring.interpolate() function?

When I use shapely.geometry.multilinestring.interpolate() function, it creates points at every 50 m along the multiline. I try to create a points at a given interval (lets say the distance between ...
0
votes
0answers
220 views

How to count a radius of a polygon

I have a Polygon (shapely) and the centroid of this Polygon (with longitude and latitude). Is there any way to count radius of the Polygon?
0
votes
2answers
1k views

Python convert lines string to polygon if closed

I have a series of contour linestrings some are closed and some are not. The linestring values are between -1 and 1. I am trying to create polygons from the linestrings if they close and keep the ...
0
votes
0answers
49 views

Using Single Polygon for entire dataframe in PySAL?

I'm trying to calculate the queen contiguity weights using pysal's queen_from_shapefile() helper method based on this page Not being a GIS specialist I wanted to check my intuition on this Q&A ...
0
votes
1answer
58 views

Finding intersection point between two arcs? [closed]

I am trying to find the intersection between two arcs. I have done this for line segments using shapely package. Does anyone have any advice?
0
votes
1answer
307 views

Extending (buffering) set of polygons into empty space only using Shapely?

I have a set of polygons of which I would like to extend the boundaries a bit into empty space, using Shapely. They are not allowed to overlap each other at all. For example creating buffers and then ...
0
votes
2answers
537 views

How to create a weighted square lattice as well as a weighted network graph

I am planning to create a weighted square lattice for different sizes, and then label each edge with its associated weight. It's similar to this thread "How to load a weighed shapefile in networkX" ...
0
votes
0answers
35 views

Coordinate System shows up incorrect after converting a shapely object to a shapefile [duplicate]

I am trying to convert a simple point object created using shapely to a shapefile using fiona as instructed in this post. I pretty much followed line by line except that I changed the crs as I need it ...
0
votes
0answers
136 views

Writing only one of the input vector fields to output vector using Fiona/ Python?

I'm working on a function to perform operations on folders of vector files. These files might have differing attribute fields but there will be a common field between them. I'm using fiona in python ...
0
votes
1answer
858 views

Dissolving polygons to single part features with Python (shapely and fiona)?

I used the code from Dissolving polygons based on multiple attributes with Python (shapely and fiona)? to dissolve a shapefile using shapely and fiona. However the output creates multi-part geometries....
0
votes
0answers
452 views

Python/shapely: unary_union raises AttributeError: 'map' object has no attribute '_geom'

I am updating from Python 2.7 to Python 3.6. I have code that worked before and now raises an error where it uses shapely.ops.unary_union(). The argument used with that call is a GeoJSON object {'...
0
votes
1answer
1k views

Create Shapely linestring from string of coordinates in text format

I have a DataFrame where one column consists of lines stored like so: '[[-7.61, 42.15],[-6.62, 43.16],[-8.9, 41.0],[-9.2, 40.5]]' Is there an easy way to read these lines directly into shapely ...
0
votes
0answers
302 views

Shapely intersection operation gives non-intersecting results

I generated two lines by calculating the intersection of each of two overlapping Polygon objects with an overlapping LineString object that goes through both. In pictures: Here is the code: src = ...
0
votes
0answers
178 views

Spatial join in Geopandas is only finding itself

I ran my code successfully last week, cleared the kernel and now it does not work. It must be something simple I'm missing, but I cannot seem to puzzle it out. The purpose of the code is to find all ...
0
votes
2answers
634 views

including SRID in WKBWriter in Shapely doesn't work

I want to encode coordinates of LineString in WKB with the SRID included wkbwriter = shapely.geos.WKBWriter(shapely.geos.lgeos, big_endian=False, include_srid=True) geo = wkbwriter.write_hex(...
0
votes
1answer
589 views

Circles projected from AEQD to WGS84 too elongated [closed]

I'm trying to draw circles around lat-long (WGS84) points by: transforming the point into AEQD space creating a shapely buffer on the projected point projecting the shapely buffer back to WGS space `...
0
votes
0answers
22 views

Out schema for dissolving shapes

I have a code which goes like this with fiona.open(some_file, 'r') as to_dissolve: out = to_dissolve.schema with fiona.open(another_file, 'w', 'ESRI Shapefile', out) as dissolved: # ...
0
votes
0answers
43 views

Shapely not detecting Manhattan point in Pluto dataset

I have a shapefile for Manhattan taken from the Pluto dataset: https://www1.nyc.gov/site/planning/data-maps/open-data/dwn-pluto-mappluto.page Removing it from the zip, I load it with Fiona. import ...
0
votes
0answers
1k views

Shapely and lines intersection

Is there a way in Shapely to calculate intersections of geometries with some tolerance? Imagine we have lines that are the same, but their coordinates are written with different precision. ...