Skip to content

Tag: shapely

WKB string to WKT, GeoJSON in Python

I have a number of WKB strings, couple of examples given below: I want to convert them to WKT or GeoJSON type as I am able to do using the following online tool: https://rodic.fr/blog/online-conversion-between-geometric-formats/ Is there a way for me to do the same on Python? Answer You can use shapely for th…

Converting a list of coordinates to point geometry

My geopandas df looks like this: As you can see, the geometry column is a list containing longitude and latitude values. Is there an efficient way to convert them to points? This works but is very inefficient: When I put this in a loop I get TypeError: len() of unsized object Basically I need the inverse of t…

Difference between wkt and str

I have a shapely Polygon. What is the difference between converting it to wkt and converting it to string: Is the result always the same? And can these two be used interchangeably? Answer They are the same. Looking at the source code BaseGeometry.__str__() method returns self.wkt. So with P.wkt or str(P) you …

Delete polygons that have one or more side parts in common

I am trying to solve a particular case of comparison of polygons to others. I have five polygons distributed as in the figure below. The black polygon is the one with the largest area. There may be other similar cases, the main rule is to remove the smallest polygons among all those that have one or more side…