2

I am attempting to count how many dissemination areas are in a group of school catchment areas. I am using two shapefiles from different sources and use GeoPandas' overlay function to generate a dataframe with the overlapping areas.

In the attached image, the coloured areas represent catchments, the solid lines represent the boundary of dissemination areas. catchments and dissemination areas

This code generates the dataframe with the overlaps.

import geopandas as gpd    

schools = gpd.read_file(path to shapefile)
schools=schools.to_crs(epsg=26917)

da = gpd.read_file(path to shapefile)
da=da.to_crs(epsg=26917)


overlaps = gpd.overlay(da,schools, how='intersection')

The code functions properly, but gave me unexpected results: the counts were WAY high. The issue seems to be that each catchment has points where it overlaps minimally with the adjacent dissemination areas. For example, the second image is zoomed in area and you'll notice the purple catchment just barely squeaks over the line which is in the middle of a river. As it stands, the script captures that as being part of the purple and green catchment areas, which would be fine if it were truly part of both catchment areas.

One idea I had was possibly trimming a few meters from the edge of each polygon to reduce the number of "collisions" between adjacent polygons, but I don't know if such a thing is possible. Other suggestions are welcome too.

The purple catchment area extends into the adjacent dissemination area (solid line)

0

1 Answer 1

2

What you call trimming is a negative buffer if I understand it correctly. That can be done using buffer() method. Here "trimming" by 20 meters (assuming the projection is in meters).

da.geometry = da.buffer(-20)

One alternative would be to use an areal interpolation method which should deal with these issues. For that have a look at tobler https://pysal.org/tobler/ and specifically at tobler.area_weighted.area_interpolate function.

1
  • This is exactly what I needed. Thanks!
    – pubb
    Apr 6, 2021 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.