Fix invalid polygon in Shapely

Shapely defines a Polygon as invalid if any of its segments intersect, including segments that are colinear. Many software packages will create a region or area with a "cutout" as shown here which...

shapely and matplotlib point-in-polygon not accurate with geolocation

I am testing the point-in-polygon function with matplotlib and shapely. Here is a map contains a Bermuda triangle polygon. Google maps's point-in-polygon functions clearly shows testingPoint and...

Find the area between two curves plotted in matplotlib (fill_between area)

I have a list of x and y values for two curves, both having weird shapes, and I don't have a function for any of them. I need to do two things: (1) plot it and shade the area between the curves...

how to successfully install pyproj and geopandas?

I have tried to install geopandas via I python by running !pip install geopandas, but this fails with "python setup.py egg_info" failed with error code 1 and then Path to long directory. I read...

Splitting self-intersecting polygon only returned one polygon in Shapely

I am using Python 3.5 64 bit in Windows 7 64 bit, shapely version 1.5.13. I have the following code that returned me a self-intersecting polygon: import numpy as np from shapely.geometry import...

distance from point to polygon (when inside)

I'm trying to find an efficient way to compute the distance from a point to the nearest edge of a polygon in python. I thought shapely would be perfect for this, but it only computes the distance...

Shapely OSError: Could not find lib c or load any of its variants []

I'm just trying to use the demo code. I run the following in Jupyter Notebook: from shapely.geometry import shape Which gives me the following: OSError Traceback...

Algorithm to close a polygon

I have a part of perimeter of a polygon and need to close it.Please refer this image As I can see there is only one unique way to close the polygon without dividing the polygon and without the...

Override custom-logo parameters in WordPress child theme

I'm making a child theme based off of Shapely. In Shapely's functions.php, custom-logo support is declared. /** * Add support for the custom logo functionality */ add_theme_support(...

Python dependency hell: A compromise between virtualenv and global dependencies?

I've tested various ways to manage my project dependencies in Python so far: Installing everything global with pip (saves spaces, but sooner or later gets you in trouble) pip & venv or virtualenv...

Error installing geopandas:" A GDAL API version must be specified " in Anaconda

This error raised while installing geopandas. I've looking for its solution on the web, but none of them really explain what happened and how to solve it.. This is the full error: Collecting...

Python: why do I get an error when I import geopandas?

I try to import geopandas in my jupyter notebook. import geopandas as gp and I get the following error: ImportError:...

How do I plot Shapely polygons and objects using Matplotlib?

I want to use Shapely for my computational geometry project. I need to be able to visualize and display polygons, lines, and other geometric objects for this. I've tried to use Matplotlib for this...

How to use geopanda or shapely to find nearest point in same geodataframe

I have a geodataframe showing ~25 locations represented as point geometry. I am trying to come up with a script that goes through each point, identifies the nearest location and returns the name...

How to run st_makevalid in shapely or similar pure python library?

Is there a method in shapely or a similar library that is exactly equivalent to postGIS method st_makevalid? As it stands, using .buffer(0) as recommended here is not enough. Are there any pure...

PyInstaller: StopIteration Error when I import geopandas

I am trying to execute PyInstaller on a my script. I installed all of the required packages and the .exe is succesfully created. But when I execute it on another machine, I get he Following...

OSError: Could not find geos_c.dll or load any of its variants

I'm trying to use shapley, and to use it for what I need it for, I have to import "from shapely import geometry" but I get the error OSError: Could not find lib geos_c.dll I've tried to install...

Shapely .contains() method but including boundaries?

I'm working with Shapely polygons and I need a way to delete all smaller polygons contained within a bigger polygon. I tried using the .contains() method which Shapely provides, but the method...

ImportError: cannot import name 'rcParams' from 'matplotlib'

I have tried to uninstall and reinstall matplotlib in my tf-gpu enviornment I made but I keep getting this error: ImportError: cannot import name 'rcParams' from 'matplotlib' This is the entire...

Convert a column of GeoJSON-like strings to geometry objects in GeoPandas

I have a column in a GeoPandas dataframe with strings like this one '{type=Point, coordinates=[37.55, 55.71]}' or this '{type=MultiPoint, coordinates=[[37.6, 55.4]]}'. It can be a polygon or any...

Bad result after geoJSON export from geopandas GDF : Invalid field type <class 'cx_Oracle.LOB'>

I have a script, which takes data from oracle, puts data to pandas.DataFrame -> geopandas df and exports to geoJSON: import cx_Oracle import pandas as pd import geopandas as gpd from...

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...

How to fill holes in Multi-polygons created when dissolving geodataframe with geopandas?

I'm aiming to plot the boundaries of clusters of MSOAs (contiguous geographical units in UK) to do so I've downloaded a shapefile of MSOA boundaries from here. I then add a column of cluster...

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...

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...

How to deploy fastapi to google cloud run

I have a fastapi app that I want to deploy to google cloud run. With a gRPC python project, We deploy it as gcloud beta run deploy countries --source . But this doesn't deploy as expected. I...

how to convert geojson to shapely polygon?

i have a geoJSON geo = {'type': 'Polygon', 'coordinates': [[[23.08437310100004, 53.15448536100007], [23.08459767900007, 53.15448536100007], [23.08594514600003, 53.153587050000056], ...

ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly. Importing fiona resulted in:

Trying to read a shapefile (.shp) and received an ImportError after executing the below line of code. I even pip installed GDAL, geopandas, fiona and shapely before executing the below...

GeoJSON and MuliPolygon: shape polygon data into dataframe (python, shapely)

I have to find if the point belongs to an area. Information is given by geojson file. I created DataFrame by: choro = pd.concat([pd.DataFrame({'name':block['properties']['name'], 'area':...

How to find the intersection time of a parameterized curve with a shape?

I have a curve parameterized by time that intersects a shape (in this case just a rectangle). Following this elegant suggestion, I used shapely to determine where the objects intersect, however...