0

I would like to calculate the intersected area between a shape file and a fishnet grid.

Therefore, I use this approach (in a Python 3.7 environment):

import geopandas as gpd

fnet = gpd.read_file("foo/bar/fnet.shp")
shapes = gpd.read_file("foo/bar/shapes.shp")

geom_fnet  = [x for x in fnet.geometry]
geom_shapes   = [x for x in shapes.geometry]

intersections = []
for i, geolist1 in enumerate(geom_fnet):
    for j, geolist2 in enumerate(geom_shapes):
        if geolist1.intersects(geolist2):
            intersections.append((i, (geolist1.intersection(geolist2).area/geolist1.area)))

# next steps of analysis

The fishnet has a large number of tiles and I would like to use an approach faster than a for loop. Any suggestions?

martineau
  • 119,623
  • 25
  • 170
  • 301
skna.1000
  • 51
  • 8
  • 2
    You could take a look at `geopandas.overlay` (https://geopandas.readthedocs.io/en/latest/set_operations.html). This gives you a new DataFrame with all all intersections of both layers. And based on that you should be able to do the area calculation. – joris Oct 23 '19 at 11:11
  • It indeed worked out. Thanks for the hint! – skna.1000 Oct 24 '19 at 14:50

0 Answers0