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

Filter Shapely Polygons By Centroid, Clip, or Something Else?

I drew this flower of life by buffering points to polygons. I wanted each overlapping region to be its own polygon, so I used union and polygonize on the lines. I have filtered the polygons by area to eliminate sliver polygons, and now I'd like to…
Doda
  • 285
  • 1
  • 9
4
votes
1 answer

Use GeoPandas / Shapely to find intersection area of polygons defined by latitude and longitude coordinates

I have two GeoDataFrames, left and right, with many polygons in them. Now I am trying to find the total intersection area of each polygon in left, with all polygons in right. I've managed to get the indices of the intersecting polygons in right for…
jchristiaanse
  • 103
  • 12
4
votes
2 answers

get coordinate of points where a line crosses a polygon

I would like to find the points where a line intersects with a polygon. I obtain this polygon using a concave outline calculation from this thread. import alphashape from shapely.geometry import LineString import matplotlib.pyplot as plt from…
Alejandro
  • 879
  • 11
  • 27
4
votes
1 answer

Can't build zip file for AWS lambda using Linux Alpine docker

I have Dockerfile based on Alpine linux that builds lambda.zip file for AWS Lambda. Here's Dockerfile: FROM alpine:3.12 # -- Install OS packages: RUN apk add gcc RUN apk add --update --no-cache \ bash \ build-base \ cargo \ curl \ …
Stark
  • 336
  • 1
  • 3
  • 14
4
votes
4 answers

Fastest way to produce a grid of points that fall within a polygon or shape?

I am using shapely in python and trying to generate evenly spaced points in a grid that fall within a shape in the fastest O(n) time. The shape may be any closed polygon, not just a square or circle. My current approach is: Find min/max y & x to…
negfrequency
  • 1,801
  • 3
  • 18
  • 30
4
votes
1 answer

Can't import geopandas to python when running in docker container

I installed both shapely and geopandas in the docker image: COPY ["requirement.txt", "/app/"] RUN pip install -r requirement.txt The base of the image: FROM python:3.7-slim In the requirement.txt, I have geopandas, shapely and pygeos…
Keru Chen
  • 387
  • 1
  • 3
  • 11
4
votes
1 answer

Test if a variable is a Shapely geometry

I want to test if a variable is any kind of Shapely geometry. The variable might also be a list or a datetime. I can test for all kinds of Shapely geometries separately, like: if type(var) in [shapely.geometry.linestring.LineString,…
user8188435
  • 191
  • 5
  • 14
4
votes
2 answers

Checking the valid state of shapely.geometry.LinearRing object with is_valid property, bug or misconception from my side?

I'm currently developing a software which is doing a lot of spatial analysis and checks overall, if the user has done something which is discouraged. To check the validity of a Polygon (LinearRing with no interior vertices), I generate a…
4
votes
1 answer

Filling a hole in a MultiPolygon with shapely - Netherlands 2 digit postal codes

I've found a shapefile for 4 digit postal codes in the Netherlands here: https://public.opendatasoft.com/explore/dataset/openpostcodevlakkenpc4/export/?location=9,52.16172,5.56595&basemap=jawg.streets What I'm trying to do is to combine postcodes…
Frank
  • 223
  • 3
  • 11
4
votes
1 answer

Merging Polygon Shapefiles in Python

My python3 script created the variable geometries_list whose value is a list of shapefiles, each a polygon representing a geographic area [, ,
rightsized
  • 130
  • 1
  • 8
4
votes
1 answer

Correctly install shapely into system interpreter to avoid segfaults

Right now I have the following code which crashes with segfault: from shapely import geometry print(geometry.Polygon([[0, 0], [0, 1], [1, 1], [1, 0]])) Process finished with exit code 139 (interrupted by signal 11: SIGSEGV) I tried reinstalling…
sanyassh
  • 8,100
  • 13
  • 36
  • 70
4
votes
1 answer

Find if point is located inside or on the border of a polygon (Python - Shapely)

Well, I need to check if a point is within or located on a border of a polygon, but for this particular case I can´t get it working. First some functions and variables: from matplotlib import pyplot as plt from shapely.geometry import…
4
votes
2 answers

Alpine error during installing python shapely

I need to install Shapely into Python+Alpine based docker container. What I already have inside the container: make, gcc, geos-dev, musl-dev What I got with this command: pip install shapely Collecting shapely Downloading…
lovesuper
  • 323
  • 3
  • 12
4
votes
2 answers

PyInstaller not able to create exe using geopandas and fiona. Even if I create with some changes in .spec file exe is not working

I am using simple code to create exe using pyinstaller using geopandas and fiona as imports. Sample code: import glob import geopandas as gpd from pyproj import _datadir, datadir import fiona from osgeo import gdal, ogr, osr from fiona.ogrext import…
4
votes
2 answers

How to extract coordinates of a geometric object without array in Shapely

How to extract only the value from an array without the text "array" and "typecode"? Array is shapely.linestring.centroid.xy: a = LineString.centroid.xy print(a) >> (array('d', [-1.72937...45182697]), array('d',…
Izak Joubert
  • 906
  • 11
  • 29