# Tag Info

Accepted

### Calculating area of lat/lon polygons without transformation using GeoPandas

Overview Since version 0.7.0 geopandas has embedded the pyproj library as the crs object. pyproj, since version 2.3.0, has the ability to calculate the area of arbitrary polygons on a sphere. (see ...
Accepted

### GeoPandas Warnings unless wrong EPSG is used

You get that warning because EPSG:4326 (WGS84) is geographic CRS and its unit is degree. The key message here is "Geometry is in a geographic CRS". You don't get a warning when using EPSG:...
Accepted

### Converting polygon to list of coordinates with shapely

Here is another solution using the mapping(): returns a new, independent geometry with coordinates copied from the context. import json from shapely.geometry import Polygon, mapping poly = Polygon([...

### Filtering by geometry type in GeoPandas

Using geometry.type=="MULTIPOLYGON" is (15 times in my computer) faster. at_geometries[at_geometries.geometry.type=="MULTIPOLYGON"]`
Accepted

### Filtering by geometry type in GeoPandas

There are many solutions (see How to filter a geodataframe by geometry type? for example) With .loc as you but with geometry.type or geom_type gdf0 = gdf.loc[gdf.geometry.geometry.type=='MultiPolygon']...
Accepted

### Calculating polygon area within other polygon using GeoPandas

Use GeoPandas Overlay polygons = gpd.read_file("Polygons.shp") small_polygon = gpd.read_file("Small_polygon.shp") Intersection of the two GeoDataFrames: result = gpd.overlay(...
Accepted

### Pandas DataFrame to GeoDataFrame with Polygon geometry using groupby and lambda

Instead of using apply this can be done using the agg method with named aggregations. The only thing is that agg cannot yet operate on multiple columns, so the points must be condensed to a single ...

### Fastest way to extract the neighbours of a GPS point among millions of other points?

There are many clustering algorithms you can use, for example DBSCAN: Very large n_samples, medium n_clusters import geopandas as gpd import pandas as pd from sklearn.cluster import DBSCAN import ...
Accepted

### GeometryCollection causing RuntimeError in Python

intersection process must have returned different geometries. In this case, it is usual to get GeometryCollection. For layers in the image, intersection may return all geometry types (point, line, ...
Accepted

### How to get all records if WFS output limited to 1000?

Check the service capabilities https://geoservices.noord-holland.nl/ags/services/oi_dataservice_alg/MapServer/WFSServer?request=GetCapabilities&service=WFS&version=2.0.0 <ows:Constraint ...

### GeoPandas write esri-shape file failure: AttributeError: 'DataFrame' object has no attribute 'to_file'

The error clearly states that grid_up2geo is not a GeoDataFrame, but DataFrame. You need to create a GeoDataFrame to be able to use to_file method. You can easily create a GeoDataFrame from a ...

### Converting polygon to list of coordinates with shapely

Input data you have is probably a string(?) and it is almost in WKT (Well-known Text) format. Therefore, shapely.wkt.loads method helps you. But first, you have to have closed coordinates. That's, the ...

### Converting polygon to list of coordinates with shapely

Easier with simple list comprehension: poly = Polygon([[14.471329,46.037286],[14.467378,46.036733],[14.468441,46.034822]]) poly.wkt POLYGON ((14.471329 46.037286, 14.467378 46.036733, 14.468441 46....
Accepted

### Creating minimal enveloping polygon to set of geometries in GeoPandas

What you need is a concave hull. Create a list of all polygons coordinates and concave hull them. This takes about 30 s for two polygon groups so try it on a subset if you have a very large dataset. ...
Accepted

### How to create a simple polygon from coordinates in GeoPandas with Python?

This simple code is working for Python 3.9 and geopandas 0.9.0, and it works for older versions too: import geopandas as gpd from shapely.geometry import Polygon lat_point_list = [50.854457, 52....

### Plotting multiple maps using GeoPandas

I usually plot multiple maps as following. import pandas as pd import geopandas as gpd import matplotlib.pyplot as plt fig, axs = plt.subplots(5, 5, figsize=(25, 25)) axs = axs.flatten() for idx in ...
Accepted

### Geopandas spatial join giving empty result

You need to specify the how parameter which is "inner" by default (see docu here). "inner" keeps only the left geometries once the condition ("within") is True for both ...
Accepted

### How does GeoPandas' representative_point() work?

Geopandas uses shapely for geometry manipulations. In shapely representative_point is a call to the GEOSPointOnSurface method in the GEOS C library. The GEOS library is also used by PostGIS, so I'm ...

### Calculating polygon area within other polygon using GeoPandas

I don't use geopandas but in any GIS system what you are describing is a Union or Intersect style operation. This you can apply at the dataset level and I suspect would be far more efficient than ...

### Get the right SRID (AUTHORITY) of the .shp

EPSG codes don't just define CRS, which is I think what you are seeking here. In your example none of the EPSG authority codes using in the WKT describe the CRS and GIS applications that parse the ...
Accepted

### Extracting the space between polygons

Try unary_union to dissolve all obstacles to a big multipolygon. Then create a rectangle around the multipolygon and difference: import geopandas as gpd df = gpd.read_file(r'C:\GIS\data\tempdata\my....

### Converting multiple x,y coordinates to new coordinate system using GeoPandas

Just convert to GeoSeries (geometry) and reproject them one at a time: import geopandas as gpd import numpy as np EPSG_ITM = 2157 EPSG_Irish = 29902 # load csv file gdf = gpd.read_file(r"file....

### Converting multiple x,y coordinates to new coordinate system using GeoPandas

You can make a multipoint-typed GeoDataFrame using the following script. Sample CSV: M1_EASTING,M1_NORTHING,M2_EASTING,M2_NORTHING,M3_EASTING,M3_NORTHING -361065,7600889,-361310,7600913,-361205,...
Accepted

### Reading Inspire XML with GeoPandas

This is a GML file with layers. To read a layer, pass the layer name: In : db = gpd.read_file("DB-Netz_INSPIRE_20200217.xml",layer="RailwayLine") /home/rowlings/.local/lib/...

### Reading Inspire XML with GeoPandas

You can list all the layers using fiona.listlayers(datasource): import fiona as fio import geopandas as gpd gml = "/vsizip/DB_Inspire_XML_2019.zip" for layer in fio.listlayers(gml): ...

### Count overlapping features using Geopandas

It took quite a bit of head scratching, but I finally got there! Here is how you can do it in GeoPandas. def count_overlapping_features(in_gdf): # Get the name of the column containing the ...

### Geopandas simplify results in gaps between polygons

As mentioned, you need a topology aware simplification algorithm. For this I use the topojson package: gdf = <geopandas dataframe> import topojson as tp topo = tp.Topology(gdf.to_crs({'init':'...

### Grouping GeoDataFrame by column while comparing feature area and adding values to new column with GeoPandas

With such a question you will probably find more luck on the Stack Overflow. However, I may try to resolve it. There are several hints regarding your code: there are more columns than just "...