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
22 views

How do I create centroids inside polygons in Python?

When creating centroids from polygons, ArcMap has an option to placing the centroids inside (within the bounds of) the polygons. I am attempting to create centroids in Python. I have tried '''df['...
1
vote
1answer
39 views

Pandas dataframe to Shapely LineString using GroupBy & SortBy

I have a pandas dataframe that contains information to construction (poly)lines, and I want to use shapely & geopandas tools to make a SHP. In the example below, I have 3 lines differentiated by &...
3
votes
1answer
67 views

How buffering works in GeoPandas?

I try to add a buffer on a set of lines via the buffer attribute of geopandas. But by testing on a simple case (see code below) I realize that the size of the buffer is not kept according to the ...
5
votes
1answer
93 views

Get points within maximum distance from any point in GeoPandas

Given a set of points (with meters coordinates), I am trying to create lines between them. But I don't want to create lines of each pair of points, Iwant to create thoses lines if the distance between ...
1
vote
1answer
35 views

Convert Linestrings from OSMnx into Multipolygon

I'm retrieving some geometries from OpenStreetMap with OSMnx library with the following code: G = ox.graph_from_place('Casco Viejo, Bilbao, Spain', network_type='walk', ...
0
votes
1answer
22 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
26 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: ...
1
vote
1answer
22 views

Invalid geometry objects in Shapely list

I have a creating a list of shapely polygons. While I am trying to create a geodataframe from that list it gives an error: intersec_ls = [poly1, poly2, poly3] cu = cascaded_union(intersec_ls) differ =...
2
votes
1answer
44 views

Finding closest point to shapefile coastline Python

I have a dataset consisting of 2,2 million houses in a Norway, and I want to find the distance to the coast for each dwelling. The location of the house is made up by latitude and longitude ...
2
votes
1answer
44 views

Find nearest polygon (from GeoSeries) to point (from GeoSeries)

I have two GeoSeries, consisting of points and polygons. I want to find the polygon in dataframe B that is closest to each point in dataframe A. The polygons are rooftops from https://github.com/...
0
votes
0answers
19 views

Assigning attribute field to polygons within Multipolygon

I have a geodataframe with geometry column having MultiPolygons. For each index I have a Multipolygon having 4 polygons. I have a name label for each polygon within MultiPolygon. How can I assign the ...
2
votes
1answer
104 views

Intersection of two shapely polygon geometries

I have Shapely polygon geometries, A circle(c) and list of polygons within the circle. I want to find the union of the circle with the intersections. (circle + intersections) I was trying to ...
0
votes
1answer
22 views

Rotation using shapely

I am trying to rotate a Polygon type(see below) with the center of rotation(not necessary in the center) but somewhere within the boundary. How can I do this? I am looking at rotate and ...
1
vote
1answer
59 views

How do you validate longitude and latitude coordinates in Python?

I am working on a bunch of shapefile data, and I need to process it and after some kind of processing, I need to feed the data to an indexer (in this case ElasticSearch). The problem is I just ...
1
vote
0answers
17 views

Points within “normal bounds” of a linestring in Python

I am working in Python (using Shapely). I have a list of Point(s) (the small circles in the image) and a LineString (the solid line with an arrow). I want to select only the points which are within ...
1
vote
0answers
44 views

Value error when trying to load line and polygon GEOJSONs into PyCharm/Python

I'm a newb so apologies if there's incorrect formatting etc here. I'm trying to use GEOJSON files to visualise some data in Python using GeoPandas (GDAL, fiona, shapely, numpy, matplotlib are all ...
4
votes
1answer
88 views

Plotting a CSV with coordinates one row at a time via GeoPandas

I have a CSV of all earthquakes in my country for the last 10 years arranged by date and time. My goal is to plot each line chronologically one by one, so that I can compile these maps and produce a "...
0
votes
1answer
15 views

shapely examples use 'figures', what is this library?

For example https://shapely.readthedocs.io/en/latest/code/polygon.py uses a library 'figures'. I can't seem to locate this library. There are several libraries on PyPi with figures in the name, ...
2
votes
2answers
157 views

Divide a polygon into multiple small polygons using a MultiLineString

I'm trying to divide a polygon grid into multiple smaller polygons basis their intersection with a MultiLineString using Shapely. Following code works good for LineString but not for intersecting ...
0
votes
0answers
29 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 ...
1
vote
0answers
71 views

Parallel Offset of a Polygon Edge with Shapely

I need to offset edges of a polygon by different amounts. buffer() will parallel-offset all the edges by the same amount, and each in its edge-normal direction (and in both directions if applied to a ...
0
votes
0answers
28 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 ...
1
vote
0answers
62 views

How to find and remove invalid geometry in a multilinestring python geodataframe?

I have original data as a 700000's rows excel, with geometry data in hexwkb format. I want to plot it and make some spatial operations on it like intersect, distance and buffer, on a jupyter notebook. ...
0
votes
1answer
24 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
1answer
29 views

Errors relating to merging point shapefiles

I have created two different point shapefiles which represent towns within a state. However I want to know the distance between both towns, but first I want to draw a line between them. Is this ...
0
votes
1answer
28 views

Merging two point shapefiles as one in using shapely and fiona

I am a little bit confused. I have two point shapefile in the same Co-ordinate reference system, and I am trying to merge them using shapely to merge them together as one and output the geom with ...
1
vote
1answer
42 views

Shapely affine transformations with bounds of GeoDataFrame

I understand that I can use Shapely's affinity.translate to translate a geometry like the below: from shapely import affinity from shapely.geometry import Polygon poly = Polygon([(0, 0), (1, 0), (1, ...
-1
votes
1answer
36 views

How to add a geocode in long,lat instead of lat,long [closed]

I am a bit confused. I am trying to geocode coordinates of a point shapefile, but in long lat instead of lat long and add the address to a new shapefile. Any ideas? import fiona from geopy.geocoders ...
2
votes
1answer
172 views

Python function to get the co-ordinate pair of a point

I am trying to geocode a point shape. But first I want to determine the coordinate pair of the point shapefile before geocoding. The error I get is: **ERROR** :ValueError: Must be a coordinate pair ...
0
votes
0answers
16 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 ...
3
votes
1answer
306 views

Computing convex hull of points using shapely

I have a points shapefile and I want to compute the convex hull of the points using shapely, and output the result as a shapefile using Fiona. Does anyone know how I can do that? This is what I have ...
0
votes
1answer
25 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
38 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
163 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 ...
3
votes
0answers
42 views

How do I find where a line intersects itself?

I am using Python 3.7 with Shapely and GeoPandas. I have a big line of 181,000 points, and would like to find all the points where the line intersects itself. It does so a lot. I don't need a new ...
0
votes
1answer
54 views

Splitting polygons based on points density [closed]

I have a geojson file with polygons representing administrative regions. I also have a shapefile from which I can extract a list of points of interest (schools). I can iterate over this list of ...
0
votes
0answers
79 views

shapely wkt.loads - skip bad geometries?

I'm trying to convert an excel file into a Geopandas dataframe. I'm trying to use shapely and wkt to do so. After reading the file into pandas, I have a geometry column. I'm trying to do the ...
1
vote
1answer
47 views

Typerror when using Geopandas.to_file

I am trying to save some Shapely Polygons to a .shp so that I can view and map them in QGIS. This data resides in my projects.hull column. I am running into a Typeerror which I am finding difficult to ...
2
votes
1answer
258 views

Convex Hull in GeoPandas

I have a shapefile with a number of points. Using GeoPandas, I am trying to create a convex hull around the set of points. However, my output layer returns the same points as were fed in. My ...
1
vote
1answer
15 views

Apparent miscalculation of intersection area

I am trying to calculate the fraction of one area inside another. I confess to not understanding geopandas vs shapely shapes too well. But an example should show my confusion. My python calculation ...
3
votes
1answer
56 views

CSV containing GeoJSON format geometries to DataFrame

I have a CSV file I open as a DataFrame. Among the columns is one named geom 1 : df.loc[:, 'geom 1'] >>> 0 {'type': 'Polygon', 'coordinates': [[[2.826589... 1 {'type': 'Polygon', ...
1
vote
1answer
40 views

How do you create a “donut hole” / cut-out-effect using folium?

I've tried adjusting parameters and changing the order in which these circles are added. I can't get the interior circle, or "hole", to remain transparent. The outer circle always predominates. m = ...
3
votes
1answer
215 views

Find traveling distance between line and point

Is there a clever way to traverse a line string up until a point and return the distance to that point? As an example: a = LineString([(1, 1), (9, 1), (9, 6), (4, 6), (4, 3)]) p = Point((4,4,)) The ...
1
vote
0answers
39 views

Calculate distance in kilometers with shapely

I am for the first time needing to use geolocation and geodata resources in a WEB application. As the application is being developed in python / flask I decided to make use of the shapely library. The ...
1
vote
2answers
97 views

Extract polygon name dataframe if the geo-point is inside polygon?

I have two dataset one with polygon name and polygon and other with location name and latitude and longitude. Data 1 (Geopandas Dataframe) import geopandas as gpd data_poly = gpd.read_file(path + "...
1
vote
1answer
37 views

Converting to Linestring using Dataframe Column

I'm attempting to convert tuples from a dataframe into a linestring. This is part of my dataframe imported from a csv file. Unnamed: 0 name route ...
0
votes
1answer
70 views

Attempting to get the distance between two Point objects. Getting AttributeError: 'GeoSeries' object has no attribute '_geom'

I am a beginner in GIS. Using the code below to get the distance between two Point objects from two separate GeoDataframe. Using the shapely distance function. Can someone please explain to me what I ...
0
votes
0answers
8 views

saving and reopening alters coordinates geopandas [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-...
1
vote
2answers
86 views

Erasing line features based on intersecting polygons using GeoPandas?

I have two interesecting geopandas.GeoDataFrame datasets, one containing line features (lines_gdf) and one containing polygons (polygons_gdf): import matplotlib.pyplot as plt import geopandas as gpd ...

1
2 3 4 5
12