Skip to content
Advertisement

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 this:

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 this question. Reproducible

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 get the same Well Known Text (WKT) representation.

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 portions in

Remove a Polygon from a MultiPolygon with shapely in Python

I am working with spatial objects in Python using the shapely library. Given a MultiPolygon, I want to remove from it the Polygons which don’t contain an obstacle. However, I haven’t found a way to do this, even though I can get the coordinates from the MultiPolygon just by using the mapping function. I already know which Polygons I want

Advertisement