New answers tagged

0 votes

Labelling a Map

To make a text label follow a curve you could use the CurvedText class. In the example below, I placed that class in the library "curved_text": import matplotlib.pyplot as plt import cartopy....
Ratislaus's user avatar
  • 184
1 vote

How to extract biggest Polygon from MultiPolygon in GeoPandas?

As of shapely 2.0.2 (and may be earlier versions), you need to append .geoms: max(multipolygon.geoms, key=lambda a: a.area)
Victor Boussange's user avatar
1 vote

Intersecting a circle and a geodataframe

You are doing a left join (how="left"), so (only) the geometry of the left_df, so the circle, is retained in the output as explained in the documentation of the how parameter here. If I ...
Pieter's user avatar
  • 1,520
1 vote
Accepted

Intersecting a circle and a geodataframe

You need to set a crs when you create the circle df: circle_gdf=gpd.GeoDataFrame(geometry=[circle], crs=????)
BERA's user avatar
  • 71.2k
0 votes

Affine Tranformation Matrix; shapely asks 6 coefficients, but rasterio delivers 9; how to translate

rasterio.affine.Affine has a to_shapely method to do just that: shapely.affinity.affine_transform(geom, rio_affine.to_shapely()) Unfortunately, you won't find anything about to_shapely in rasterio's ...
P-Gn's user avatar
  • 101
0 votes

Creating GeoPandas GeoDataFrame from rasterio features

Rasterio provides with features.dataset_features a generator for GeoJSON-like Features which can be fed directly into GeoDataFrame.from_features, so no need to iterate over feature.shapes and build ...
NielsFlohr's user avatar
0 votes

Shapely intersection cuts LineString into MultiLineString instead of LineString

The problem is that there are duplicate nodes (coordinates) and thus, duplicate segments, in your LineString (points in red) from collections import Counter duplicates = [node for node, count in ...
gene's user avatar
  • 54.7k
0 votes

Shapely intersection cuts LineString into MultiLineString instead of LineString

The issue comes from your input Line wich is not a real Linestring because it is made up of superfluous points. Your are in a particular case, if your take a closer look at your geometries there is a ...
Magic Mushroom's user avatar
0 votes

Extract shapely polygon from matplotlib hexbin polycollection

I'm going to add on to Sam Comber's amazing answer to add the hex data value as a geopandas column. Might as well make it a function at the same time. # Imports import numpy as np import geopandas as ...
Rejexx's user avatar
  • 13
1 vote
Accepted

Interpolate intermediate sections

Assuming that the distance is measured between the middle points of those lines, you could: find their middle points find how many more points must be between those middle points to keep the distance ...
Ratislaus's user avatar
  • 184

Top 50 recent answers are included