Questions tagged [shapely]

PostGIS-ish operations outside a database context for Pythoneers and Pythonistas.

Shapely is a BSD-licensed Python package (see Shapely · PyPI) for manipulation and analysis of planar geometric objects. It is based on the widely deployed GEOS (the engine of PostGIS) and JTS (from which GEOS is ported) libraries. This C dependency is traded for the ability to execute with blazing speed. Shapely is not concerned with data formats or coordinate systems, but can be readily integrated with packages that are. For more details, see the Shapely manual.

1113 questions
4
votes
1 answer

AttributeError: 'GeoSeries' object has no attribute '_geom'

Getting this strange error while merging two regions using shapely's unary_union. Shapely version: 1.6.4.post2 Python 3.5 Data Polygons (side by side) I want to add Gujranwala 1 and Gujranwala 2 to make it a single polygon. Code from shapely.ops…
Ahsaan-566
  • 603
  • 3
  • 6
  • 21
4
votes
1 answer

Shapely Polygon Union with Holes Result

I'm looking for approach to merge polygons which produce holes that covers between polygons. I already tried to use cascading union in Shapely, but it gives polygon that cover holes. Reference question : polygon union without holes expected output
4
votes
2 answers

Checking if a geocoordinate point is land or ocean using cartopy and Natural Earth 10m data

The answer to a previous question "Check if a geocoordinate point is land or ocean using cartopy" See…
B. Leas
  • 41
  • 3
4
votes
1 answer

Remove a duplicate point from polygon in Shapely

To remove duplicate lists from a list, there are several nice ways in Python - for example: a = [[ 9.1514622, 47.1166004 ], [ 9.1513045, 47.1164599 ], [ 9.1516278, 47.1163001 ], [ 9.1517832, 47.1164408 ], [ 9.1514622, 47.1166004 ] ] print len(a) #…
philshem
  • 24,761
  • 8
  • 61
  • 127
4
votes
0 answers

How to save a shapely object as an image

I have a shapely object in python. It is the outline of the map of the US. How do I save it as an EPS or PDF?
Karthik
  • 69
  • 6
4
votes
3 answers

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

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…
user5897587
4
votes
1 answer

Packing an irregular polygon with different sized circles

I'm trying to write a program in Python with Shapely that takes in shape files (right now congressional districts) and "packs" them with circles. The end goal is to have the center points and radii of the circles. I'd like to cover the maximum area…
4
votes
2 answers

Find non-overlapping polygons in GeoDataFrame

I have a GeoDataFrame with a column of shapely.polygons. Some of them distinct, some - not: In [1]: gdf Out[2]: geometry 1 POLYGON ((1 1, 1 2, 2 2, 2 1, 1 1)) 2 POLYGON ((1 3, 1 4, 2 4, 2 3, 1 3)) 3 POLYGON ((1 1, 1 2, 2 2, 2 1, 1 1)) 4 …
Headshaker
  • 51
  • 4
4
votes
2 answers

How can I mirror a polygon using Python?

I have a set of images over which polygons are drawn. I have the points of those polygons and I draw these using Shapely and check whether certain points from an eye tracker fall into the polygons. Now, some of those images are mirrored but I do…
Jancso
  • 43
  • 1
  • 5
4
votes
1 answer

Shortest distance of a location from a route (Python)

I have a location with its lat and long information loc = (28.469723, 77.065292) and a route (polyline) given by five lat long pairs route = [(28.478324, 77.093916), (28.471647, 77.092457), (28.465498, 77.086105), (28.461273, 77.077651)] Is there…
Saquib
  • 273
  • 3
  • 9
4
votes
1 answer

union overlapping polygons until no overlap

I have a list of geometries(could be a point or polygon) and I need to union the geometries that overlap(or contained within another geometry) in to one geometry. Any ideas on how to do this efficiently using shapely? I believe I should be using…
Prash
  • 43
  • 1
  • 6
4
votes
3 answers

Shortest path between many 2D points (travelling salesman within Shapely LineString?)

I was trying to create river cross-section profiles based on the point terrestical measurements. When trying to create a Shapely LineString from a Series of points with the common id, I realized that the order of given points really matters as the…
Marjan Moderc
  • 2,747
  • 23
  • 44
4
votes
1 answer

shapely is_valid for polygons in 3D

I'm trying to validate some polygons that are on planes with is_valid, but I get Too few points in geometry component at or near point for polygons where the z is not constant. Is there a way to validate these other polygons? Here's an…
user3747260
  • 465
  • 1
  • 5
  • 14
4
votes
4 answers

Import mssql spatial fields into geopandas/shapely geometry

I cannot seem to be able to directly import mssql spatial fields into geopandas. I can import normal mssql tables into pandas with Pymssql without problems, but I cannot figure out a way to import the spatial fields into shapely geometry. I know…
Dryden
  • 106
  • 1
  • 7
4
votes
1 answer

Fix up shapely polygon object when discontinuous after map projection

This demo program (intended to be run in an IPython notebook; you need matplotlib, mpl_toolkits.basemap, pyproj, and shapely) is supposed to plot increasingly large circles on the surface of the Earth. It works correctly as long as the circle does…
zwol
  • 135,547
  • 38
  • 252
  • 361