0

I am plotting some raster data on a map using geopandas.

Even though all polygons are exactly adjectent, when plotting it appears as if there is space in between them, so it looks like there is a white grid on the plot.

I have tried casting to a different crs, but that didn't change anything. Adding padding to the polygons isn't a great solution, there's nothing wrong with the polygons - I've checked they are exactly adjecent.

Here is an example of runnable code where you can clearly see the problem.

import geopandas as gpd
import matplotlib.pyplot as plt

geometries = gpd.read_file('https://confluence.govcloud.dk/download/attachments/53086340/10x10km-Grid.zip?version=1&modificationDate=1644923591000&api=v2')

geometries.plot()

plt.show()

Which gives this output for me

1 Answers1

0

If you specify the edgecolor parameter to be the same color as the polygons, I believe this will render the way you want.

import geopandas as gpd

geometries = gpd.read_file('https://confluence.govcloud.dk/download/attachments/53086340/10x10km-Grid.zip?version=1&modificationDate=1644923591000&api=v2')
geometries.plot(edgecolor='tab:blue')

map plot without white edges

Zach Flanders
  • 1,224
  • 1
  • 7
  • 10
  • Thanks for your response. Do you have any idea of how to get this to work when using a colormap? – TiemvdDeure Jan 16 '23 at 14:26
  • Sorry, not having any luck with a color map. I tried `geometries.plot(snap=True)`, which is better but still leaves some white slivers. – Zach Flanders Jan 18 '23 at 03:38
  • I didn't know about snap - that already helps. If I need something more neat I'll convert my data to an actual raster/array and plot that way. – TiemvdDeure Jan 18 '23 at 09:49