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
0answers
19 views

Using Single Polygon for entire dataframe in PySAL?

Not being a GIS specialist I wanted to check my intuition on this Q&A site first before proceeding further in my project. I'm using Shapely, GeoPandas and PySAL. Code follows, then question: ...
0
votes
0answers
19 views

Install shapely windows using pip

My question is related to Why is Shapely not installing correctly? However it is not working and I am struggling to find information/understand how to install it. I am running my own environment ...
2
votes
1answer
31 views

How to dissolve overlapping polygons using GeoPandas

Assuming the following: from shapely.affinity import translate from shapely.geometry import Polygon import geopandas p0 = Polygon( [(0,0), (2,0), (2,2), (0,2)] ) p1 = translate(p0, xoff=1) p2 = ...
0
votes
1answer
85 views

OSError: Could not find lib geos_c.dll

After a system re-imaging, I am seeing this error message when trying to run a script involving shapely: OSError: Could not find lib geos_c.dll or load any of its variants ['C:\\Users\\myusername\\...
3
votes
1answer
84 views

Convert contours to polygons maintaining attributes using Python?

I have a series of polylines(contours) that i want to convert to polygons using Python (GeoPandas, Fiona, Shapely). Because these are contours, there will be donut polygons, can anyone point me to how ...
0
votes
0answers
17 views

Faster calculation of Shapely polygon-line intersection

I am running a Python Shapely where I have a rotating and translating polygon for which I obtain some probe signals in the following way: for theta_index, theta in enumerate(thetas): rotated = ...
0
votes
1answer
42 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?
3
votes
1answer
39 views

Find duplicate point geometries in a shapefile [closed]

How to find a duplicate point geometries in point shapefile (around one lakh geometries) using Python OGR/GDAL
2
votes
1answer
56 views

Polygon area from Google Earth so different to QGIS & Shapely/PyProj?

I have a set of points defined by their longitudes and latitudes in WGS84 that define a polygon that I need to calculate the area of. I originally tried to approach this using pyproj and Shapely as ...
1
vote
0answers
51 views

Is the Albers Equal Area projection only useful for calculating the area over small differences in longitude?

I've been trying to calculate the area of a map, given its WGS 84 coordinates, with the following code: import pyproj import shapely import shapely.ops as ops from shapely.geometry.polygon import ...
1
vote
0answers
27 views

Set-overlay collection of polygons on itself [closed]

I have a GeodataFrame in Geopandas, that consists of a number of polygons, each overlapping its neighbors. What I want is to generate every single possible polygon from all the intersections, so that ...
3
votes
1answer
3k views

Error installing Shapely package using pip command

I'm using Windows 10 and python 2.7. Even though I updated pip it's getting error: ERROR: Command errored out with exit status 1: command: 'c:\python27\python.exe' -c 'import sys, setuptools, ...
0
votes
0answers
46 views

CRS of Shapely Object

I've imported a row from a Postgres DB using sqlalchemy. One of the column types is GEOMETRY from postgis and upon import >>>> type(row[0].geom) returns class 'geoalchemy2.elements....
1
vote
0answers
14 views

Improving performance of shapely crosses

I am unsure if this is the fastest way to test if LineStrings cross each other. Is there a better method. for line_1, line_2, in itertools.combinations(lines, 2): crosses = line_1.crosses(line_2) ...
1
vote
0answers
77 views

Converting a raster pixel by pixel to vector cells in Python

Problem Today I needed to convert raster to a shapefile with rectangular polygons representing each pixel of the raster in Python, including the pixels with value 0. Related questions: Converting ...
0
votes
0answers
24 views

Speed- and COG-aware trajectory interpolation/resampling using Python

I have a set of ship trajectory points that were irregularly sampled and I would like to resample them to a fixed frequency (e.g. every minute). Rather than just linearly interpolating between ...
2
votes
0answers
24 views

Creating Swath View from Point data using Python?

My situation Input: point data from planting file Feature Attribute: [('DeletionFlag', 'C', 1, 0), ['Field', 'C', 254, 0], ['Dataset', 'C', 254, 0], ['Product', 'C', 254, 0], ['Obj__Id', 'N', 15,...
1
vote
1answer
55 views

Errors importing shapely.geometry into QGIS 3.6

I got error messages when executing 2nd statement below in python console of QGIS 3.6 (and QGIS 3.8) import shapely from shapely.geometry import Polygon If I execute the 2nd statement again, there ...
2
votes
1answer
106 views

Creating equally spaced coordinates on California state map created with basemap?

I have created a California state map with basemap Python library and this shapefile. Code is below from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt fig, ax = plt.subplots(...
2
votes
1answer
67 views

Populating layer field with dict.values() in PyQGIS 3?

I've coded the script below in PyQGIS 3 to get the azimuth of starting or ending points for a line layer that touches a border. It works fine, but I want to populate the azimuth field layer with the ...
1
vote
1answer
25 views

Splitting or decomposing LineString into original single lines or segments using shapely?

I am trying to split a LineString into single segments: from shaply import LineString,MultiPoint from shapely.ops import split xp = [-2,1,2,2.5,4,1,-1,2,4,5,6] yp = [-2,1,1,0,1,2,2,3,4,4,4] ...
1
vote
1answer
73 views

Finding shortest distance from point(s) to number of polygons at varying angles using shapely?

My aim is to calculate the distance a point is from land in Python, trying to replicate the functionality of fetchR. Given an origin and distance, I create shapely LineStrings which radiate out from ...
2
votes
1answer
61 views

Why is a projection conversion off by factor of SQRT(2)?

I am attempting to draw a 3 km ring around downtown Minneapolis. Let downtown be defined as Government Plaza (-93.2661, 44.9765). I am using this ring to calculate census tracts within a distance of a ...
7
votes
2answers
285 views

Getting geometries of hurricane's 'cone of uncertainty' using shapely?

I'm trying to plot hurricane forecast maps using python. I have several forecast positions derived from official advisories, and interpolate them into a smoothed curve, then draw a polygon of 'cone of ...
3
votes
1answer
195 views

Getting Unique Intersections of Multiple Polygons Efficiently in Python

I would like to get a list of all polygons that are intersections of other polygons. However, that list of intersections cannot self-overlap. For example, if I have a triple Venn diagram, I would ...
1
vote
1answer
98 views

Error: Input [<shapely.geometry.point.Point>, <shapely.geometry.point.Point>] is the wrong shape for a LineString

I'm trying to create a linestring out of a dataframe of latitudes and longitudes. geometry = [Point(xy) for xy in zip(linkdf.lon, linkdf.lat)] linkgdf = GeoDataFrame(linkdf, geometry=geometry) ...
0
votes
1answer
113 views

Buffering geometry with points in WGS84 using shapely?

I have a polygon in python shapely that I would like to buffer with a 100 foot buffer. If the polygon is stored as a series of WGS84 lon/lat points how would I go about calculating the distance of ...
1
vote
0answers
162 views

Geopandas simplify results in gaps between polygons

The goal is to simplify the geometries of a shapefile containing multipolygons. However, when I use Shapely's simplify in geopandas, the result contains gaps between the polygons. I was hoping that ...
1
vote
1answer
78 views

MULTIPOINT Text to list of POINT objects

I need to convert a MULTIPOINT string to a list of POINT objects. For example, suppose I have a query with ST_AsText() producing an output that is captured in my_points: >>>print(my_points) ...
1
vote
1answer
37 views

Determining whether the geometry field in a SQLite table has z coordinates using Python

In the Shapely package, there is a function that allows you to determine whether coordinates include a Z value. It is object.has_z. Is there a way that a similar command can be carried on the ...
1
vote
0answers
23 views

Transforming TM75(29903) squares to ETRS89(3035)?

A bit of a long winded explanation here so please bear with me. I have received grid square data in ETRS89(3035) which I need to cross reference with out own grid squares which are in TM75(29903). ...
0
votes
1answer
89 views

geopandas: “LineStrings must have at least 2 coordinate tuples” when reading gpx files

I am trying to use geopandas to read in some gpx files (generated from a Garmin vista HCX). For many gpx files, given this code: >>> import geopandas as gpd >>> data = gpd....
0
votes
1answer
80 views

Testing intersection between shapely object and geopandas GeoSeries?

This is a Python question, involving geopandas and the libraries it calls, primarily pandas and shapely. tl;dr: I am trying to run a test using if foo.intersects(bar): and am repeatedly getting one ...
2
votes
1answer
37 views

Normalized interpolation doesn't work for WGS84

I am trying to interpolate linestring on WGS84 coordinate system by factor 0.5. LineString length is 427 meters (measured by different tools), so I expect to get line with length=213.5 meters. But I ...
1
vote
1answer
45 views

GeoPandas does not identify points inside polygon

I am trying to intersect some points with a polygon in GeoPandas. First I create a Point GeoDataFrame from a text file. import geopandas as gp import numpy as np import pandas as pd from shapely....
0
votes
1answer
72 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 ...
1
vote
1answer
333 views

Removing self-intersection from invalid polygon using shapely?

This geometry is invalid: POLYGON ((234107.4999285005 581107.0000356995, 234250.1399285011 581055.220035702, 234347.470028501 581007.8300357014, 234427.899928499 580959.1000357009, 234483.1350285001 ...
0
votes
2answers
97 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
2answers
42 views

Using dictionary of file names and DD coordinates to create points in shapefile using shapely?

I'm working on a Python script that strips the GPS info from images and uses that info to create a shapefile from that info. Right now I have all the file names as keys to tuples of decimal degrees ...
0
votes
0answers
27 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 ...
2
votes
0answers
152 views

Intersecting shapefile/GeoDataFrame using Geopandas, shapely etc?

I'm currently transferring from ESRI to open source GIS by recreating basic ArcGIS tasks in Python, mainly using Geopandas since I have some experience with Pandas. Now I'm trying to intersect a ...
0
votes
0answers
27 views

Getting zip code from string geom using shapely?

I have a list of geoms each in string form. I can convert them either to our or python shapely geom but does any have a function to find a zipcode from that geom? I was unable to find one. I can use ...
0
votes
2answers
700 views

Converting list of polygons to multipolygon using shapely?

I have a list of polygons where each polygon is a wkt form as follows: list_polygons = ['POLYGON ((-88.131229288 41.900200029,-88.12973798 41.900104202,-88.129785999 41.894907769,-88.131352409 41....
4
votes
1answer
163 views

Making Shapely box larger using GeoPandas?

I'm creating a box that covers the the area of a GeoPandas GeoDataFrame, so that I can use it as an inverted map to later cover up unwanted spill-over data. import geopandas as gpd import geoplot as ...
1
vote
1answer
41 views

How to reverse the MultiLineString command to a list of arrays

Let's you have a list of coordinates that you can convert to a line string: coords = [((0.0, 0.0), (0.0, 20.0)), ((20.0, 0.0), (20.0, 20.0)), ((1.0569687968009744, 14.934839039628798), (5....
2
votes
0answers
69 views

Dissolve Line Strings to one string - “No Shapely geometry can be created from null value”

I have a layer with 7000 LineStrings, all represent bus routes: It seems that all the bus routes are contiguous, but I'm not sure of it. I'm trying to use python shapely to dissolve all those ...
3
votes
1answer
91 views

Using libraries other than PyQGIS to develop plugin for QGIS?

I develop a plugin for QGIS. Before to integreted it in the QGIS I developped it with GIS library (Fiona, shapely, geopandas, ...) and it work well. Now I try to build it with plugin_builder of QGIS. ...
2
votes
1answer
30 views

I have the following multilinestring, and I am looking for finding the intersection between each pair

I have a pair of lines, which I like to find the intersect of each of one them with each other. I know for two lines I can do the following: from shapely.geometry import LineString line1 = ...
1
vote
0answers
40 views

Cut line at intersection using Shapely

I'm trying to cut a line at the intersection, if a line crosses another line within a single multilinestring then and the end of the line is below a maximum distance threshold then it swaps the end of ...
2
votes
2answers
382 views

How to extract biggest Polygon from MultiPolygon in GeoPandas?

Given a Shapely MultiPolygon, how can I extract the biggest Polygon? For example, given a MultiPolygon as follows: from shapely.geometry import Polygon, MultiPolygon multipolygon = MultiPolygon([...