joris
  • Member for 9 years, 5 months
  • Last seen this week
Plotting large shapefiles with matplotlib
3 votes

Using geopandas, the code would look like: import geopandas df = geopandas.read_file(shpFilePath) df.plot() and this should also be faster (at least starting from geopandas 0.3.0)

View answer
Calculating areas of polygons inside other polygons with GeoPandas
Accepted answer
2 votes

I think you are looking for the overlay operation (see docs): merged = geopandas.overlay(GDF1, GDF2, how='intersection') This gives a GeoDataFrame with all intersections of all combinations of both ...

View answer
Rotating a map/projection in GeoPandas
Accepted answer
2 votes

The rotate method has an origin parameter. By default it used the center of each geometry individually, but you can also pass a single point so that the same origin is used for all geometries. Using ...

View answer
Geoplot/GeoPandas missalignment in Windows (no Anaconda)
Accepted answer
2 votes

This a bug caused by a mismatch between geoplot and contextily (the package that geoplot uses for adding the web map background), see https://github.com/ResidentMario/geoplot/issues/214. That will ...

View answer
GeoPandas gdf.geometry.buffer for spatial join
2 votes

Consider this piece of you code: buffer_gdf = hikr_gdf print(f"print1:\n{hikr_gdf.geometry}") buffer_gdf.geometry = buffer_gdf.geometry.buffer(150) print(f"print2:\n{hikr_gdf.geometry}") You can ...

View answer
Using vmin and vmax does not change anything for my plots
2 votes

You need to pass the vmin and vmax to the geopandas .plot() call: # create map pm10_base.plot(column=variable, cmap='autumn_r', vmin=vmin, vmax=vmax, linewidth=0.8, ax=ax, edgecolor='0.8') Note that ...

View answer
Turn detached coordinate values into linestring in GeoPandas
Accepted answer
2 votes

Assuming you want a linestring for each row, you can do the following: In [1]: from shapely.geometry import LineString In [2]: df = pd.DataFrame(np.random.randn(2,4), columns=['x1', 'y1', 'x2', 'y2'...

View answer
How to create a multiple buffer using geopandas
Accepted answer
2 votes

In the next version of GeoPandas this will be possible with the buffer method (https://github.com/geopandas/geopandas/pull/781), but for now you do it manually like this: track['geometry'] = track....

View answer
Cannot find polygons that are inside a big polygon using GeoPandas
2 votes

I think what you want is a "spatial join", where we add information of the second dataframe (the land use dataframe, information on the type of land use) to the first dataframe (the buildings) based ...

View answer
Wildcards in feature selection using geopandas?
Accepted answer
2 votes

You can use simple patterns or more advanced regex patterns in the str.contains() method: data[data['field'].str.contains('do')] For the case where the strings needs to start with a pattern, you can ...

View answer
How to keep empty entity during Geopandas Spatial Join
Accepted answer
2 votes

By default sjoin does a 'inner' join, meaning that only those records are kept that actually joined with a record in grouped_aquis. To also keep the ones that did not have a joining match, you can ...

View answer
Using CRS EPSG:3857 but misalignment between Stamen background and coordinates of polygons in GeoPandas
Accepted answer
1 votes

The root cause seems to be an incorrect (or incomplete) definition of the CRS of your data. Your data is actually using EPSG:28992 (https://epsg.io/28992), and if you look at the PROJ.4 definition on ...

View answer
turn back shapefile from pandas to geopandas
Accepted answer
1 votes

When joining 2 GeoDataFrames by an attribute (so a merge with pandas and not a spatial join, which can certainly be sensible for a given application), the result will be a pandas DataFrame and not a ...

View answer
float() argument must be a string or a number, not 'LineString'
Accepted answer
1 votes

Assigning values that itself are seen as a list-like or collection (in this case the MultiLineString) is a bit tricky in pandas, and gives rise to corner cases / bugs as you run into here. But, in ...

View answer
Rasterizing multiple features using rasterio?
1 votes

Based on Extract raster values within shapefile with pygeoprocessing or gdal, we can write the following function to extract values from the raster dataset based on a geometry: from shapely.geometry ...

View answer
Intersect does not remove features, leaves them empty. Python
1 votes

When you pass a GeoSeries of geometries to network.intersection(..), it will try to 'align' the passed series with the calling one, meaning that geopandas will try to take the intersection of the ...

View answer
1
2