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
6
votes
4 answers

Is it possible to correctly point to Python Shapely library's LIBGEOS_C in AWS Lambda environment?

I am attempting to write a AWS python Lambda function that utilize's Shapely for simple "point in polygon" operations. I spun up an AWS linux EC2 instance, installed Shapely and had a working script. I then downloaded the linux specific…
6
votes
1 answer

How move a multipolygon with geopandas in python2

I'm novice in GIS world in python (geopandas, shapely, etc). I need "move" a Multipolygon upwards, but I don't know how to do that. The Problem import pandas as pd import numpy as np import matplotlib from matplotlib import pyplot as plt import…
mmngreco
  • 516
  • 5
  • 14
6
votes
2 answers

python, shapely: How to determine if two polygons cross each other, while allowing their edges to overlap

I'm trying to find out whether two polygons cross each other. By 'cross' I mean their exteriors are allowed to touch each other, but their interior cannot: Only the two rightmost solutions below are allowed: I've tried using shapely intersects or…
Yair
  • 859
  • 2
  • 12
  • 27
6
votes
1 answer

Geodesic buffering in python

Given land polygons as a Shapely MultiPolygon, I want to find the (Multi-)Polygon that represents the e.g. 12 nautical mile buffer around the coastlines. Using the Shapely buffer method does not work since it uses euclidean calculations. Can…
ARF
  • 7,420
  • 8
  • 45
  • 72
6
votes
2 answers

Shapely: Cut a piece from a linestring at two cutting points

the well known function from shapely.geometry import * from shapely.wkt import loads def cut(line, distance): # Cuts a line in two at a distance from its starting point if distance <= 0.0 or distance >= line.length: return…
sal
  • 1,199
  • 1
  • 13
  • 31
6
votes
1 answer

How to extract interior polygon coordinates using Shapely?

I am new to Shapely (but enthusiastic about it), and recently I've discovered a bit of a road bump. I have a polygon shapefile that I am reading in via Fiona. This shapefile contains BOTH polygon and multipolygon items and I need to build an array…
user14696
  • 657
  • 2
  • 10
  • 30
6
votes
2 answers

Adding a matplotlib colorbar from a PatchCollection

I'm converting a Shapely MultiPolygon to a PatchCollection, and first colouring each Polygon like so: # ldn_mp is a MultiPolygon cm = plt.get_cmap('RdBu') num_colours = len(ldn_mp) fig = plt.figure() ax = fig.add_subplot(111) minx, miny, maxx, maxy…
urschrei
  • 25,123
  • 12
  • 43
  • 84
5
votes
0 answers

Pyrosm Loading Nodes and Edges - Input must be valid geometry objects

Good morning all, I am trying to load a .pbf file using the pyrosm library's documentation. My code below. import pyrosm # Get filepath to test PBF dataset fp = pyrosm.get_data("wisconsin") # Initialize the OSM object osm = pyrosm.OSM(fp) nodes,…
Circonflexe
  • 93
  • 1
  • 1
  • 5
5
votes
2 answers

How can I create grid of coordinates from a center point in python?

Is there a method to extract a grid of coordinates (purple dots) from a center coordinate, with a 100 meters distance between each coordinate for example? For example having an input of latitude and longitude center coordinate (red dot): lat =…
Lucas Mengual
  • 263
  • 6
  • 21
5
votes
1 answer

How to create a line in Shapely using starting point, length, and an angle

I found this code but it requires both first and second point to create a line. How can I change it so it works with only first point, length of the line, and an angle? from shapely.geometry import LineString from shapely.geometry import Point p =…
user15636383
  • 51
  • 1
  • 2
5
votes
1 answer

How do you triangulate a polygon in Shapely?

How do you triangulate a polygon in Shapely? Shapely actually offers a triangulate() function, but that only triangulates the vertices of the polygon as a point set. For convex polygons the solution is the same, but for non-convex you get extra…
Jann Poppinga
  • 444
  • 4
  • 18
5
votes
1 answer

Shapely intersection with multiple MultiPolygons where a percentage of Multipoloygons intersect?

I'm using Shapely's polygons for human-generated data. Multiple humans were asked to draw polygons around certain features in images. For each image, we thus have n MultiPolygon's, where n equals the number of participants per image. I can plot each…
Mitchell van Zuylen
  • 3,905
  • 4
  • 27
  • 64
5
votes
2 answers

How to split a LineString to segments

My data set consists of a LineString and I want to filter out the individual line segments of this LineString. More precisely, every single street segment. Until now I have extracted the individual points from the data set and saved them in a…
brez_123
  • 63
  • 1
  • 7
5
votes
1 answer

Shapely linestring .length units

I'm trying to find the length (in metres) of linestrings in Shapely, but can't seem to achieve the expected result. It's almost guaranteed I'm making some mistake in terms of coordinate systems, but I haven't been able to figure it out. Here's some…
EllRob
  • 145
  • 1
  • 3
  • 11
5
votes
0 answers

Simplify line string considering angles

Objective Creating a simple skeleton line from 2D polygon (CAD-Based) for CAD purpose. Small lines shall be avoided. State of work Created Voronoi Diagram for polygon Used DFS for identifying branches of voronoi vertices/edges Used Shapely Line…
BennyS
  • 115
  • 1
  • 9