shapely

Load / Plot geopandas dataframe with GeometryCollection column

Load / Plot geopandas dataframe with GeometryCollection column Question: I have a dataset like this: You can reproduce this dataframe loading the following dict: {‘entity_ts’: {0: ‘2022-11-01T00:00:56.000Z’, 1: ‘2022-11-01T00:00:56.000Z’}, ‘entity_id’: {0: ‘WAZE.jams.1172133072’, 1: ‘WAZE.jams.1284082818’}, ‘street’: {0: ‘Ac. Monsanto, Benfica’, 1: nan}, ‘position’: {0: {‘type’: ‘GeometryCollection’, ‘geometries’: [{‘coordinates’: [[[-9.168816, 38.741779], [-9.169618, 38.741353], [-9.16976, 38.741289]]], ‘type’: ‘MultiLineString’}]}, …

Total answers: 1

How to extract individual points from the shapely Multipoint data type?

How to extract individual points from the shapely Multipoint data type? Question: I am using shapely2.0; somehow, I can’t iterate through individual points in the MULTIPOINT data type in this version. I wanted to extract and plot individual points from the MULTIPOINT. The MULTIPOINT is obtained from line.intersection(circle_boundary), where I tried to get the intersection …

Total answers: 1

How do I find the smallest surrounding rectangle of a set of 2D points in Shapely?

How do I find the smallest surrounding rectangle of a set of 2D points in Shapely? Question: How do I find the msmallest surrounding rectangle (which is possibly rotated) of a set of 2D points in Shapely? Asked By: nickponline || Source Answers: To create the smallest surrounding rectangle in Shapely, first construct a MultiPoint …

Total answers: 1

Getting "AttributeError: module 'shapely.geos' has no attribute 'lgeos'"

Getting "AttributeError: module 'shapely.geos' has no attribute 'lgeos'" Question: I am trying to do this exercise from momepy (https://github.com/pysal/momepy/blob/main/docs/user_guide/getting_started.ipynb), but on the third codeblock f, ax = plt.subplots(figsize=(10, 10)) buildings.plot(ax=ax) ax.set_axis_off() plt.show() I got the following error AttributeError Traceback (most recent call last) Cell In[12], line 5 1 buildings = gpd.read_file(momepy.datasets.get_path(‘bubenec’), 2 layer=’buildings’) 4 f, …

Total answers: 1

How to construct a minimum bound box tuple for each geometry in a GeoDataFrame

How to construct a minimum bound box tuple for each geometry in a GeoDataFrame Question: I have a geopandas GeoDataFrame of lakes. I am trying to create a new column named ‘MBB’ with the bounding box for each lake. I am using the bounds function from GeoPandas. However, this function exports minx, miny, maxx, and …

Total answers: 1

ShapelyDeprecationWarnings and the use of "geoms"

ShapelyDeprecationWarnings and the use of "geoms" Question: Some lines to look up geographical information by given pair of coordinates, referenced from https://gis.stackexchange.com/questions/254869/projecting-google-maps-coordinate-to-lookup-country-in-shapefile. import geopandas as gpd from shapely.geometry import Point pt = Point(8.7333333, 53.1333333) # countries shapefile from # http://thematicmapping.org/downloads/world_borders.php folder = ‘C:\My Documents\’ data = gpd.read_file(folder + ‘TM_WORLD_BORDERS-0.3.shp’) for index, row in data.iterrows(): poly …

Total answers: 1

Divide a LINESTRING with a list of LINESTRING

Divide a LINESTRING with a list of LINESTRING Question: I’m searching a solution to divide Main Line with more than one overlapped lines. In this example I’ve four lines (I’ve applied an offset on Line 1, Line 2 and Line 3 in this chart to facilitate reading): Below the lines: from shapely import wkt main_line …

Total answers: 1

Equivalent of "points_to_xy" in GeoPandas to generate LineStrings faster?

Equivalent of "points_to_xy" in GeoPandas to generate LineStrings faster? Question: I have a list of lines defined by start and end points. The size is on the order of 100,000s to possibly low 1,000,000. For making a list of points I use points_from_xy in GeoPandas, which is highly optimized, but is there a similar and …

Total answers: 1

WKB string to WKT, GeoJSON in Python

WKB string to WKT, GeoJSON in Python Question: I have a number of WKB strings, couple of examples given below: s1 = "0103000020E6100000010000000F000000BE63303EF1D551C078E289F14742454073F7B8FAD3D551C04B98F57E0F424540FC0EA22ED4D551C04ADE36890F424540ECEB53ACD5D551C07FE2CBCA0F424540D168512BD7D551C07F2DF9F80F42454043DB28ABD8D551C0A108AD13104245406D5A632BDAD551C01D42E31A104245408D378FABDBD551C0D9AB970E10424540AD23382BDDD551C008C1CFEE0F424540C61DEBA9DED551C077EC92BB0F4245403BD33327E0D551C02043F2740F424540E58DA0A2E1D551C0A4CA001B0F4245406245BE1BE3D551C09921DDAD0E424540C8E232ADF7D551C01C11F7CA4A424540BE63303EF1D551C078E289F147424540" s2 = "0103000020E610000001000000060000009F64481FFD3A57C0E3AFF8C1EF7546407CEFEB30FD3A57C00AF4140AE375464018F55F07013B57C06018D414E37546407903F73F023B57C0BDF93E18E37546405F31E72D023B57C08D827D20F07546409F64481FFD3A57C0E3AFF8C1EF754640" 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 …

Total answers: 1