1

How can I add a geopandas geodataframe to a cartopy map? My objective is to create a large number of PNGs to turn into a GIF. The geopandas default plotting options are limited so I would like to leverage the abilities of cartopy.

For Shapefiles, I prefer the ease of use of geopandas over shapely (which geopandas uses under the hood) or other polygon libraries. Is there a way to combine the power of cartopy with the power of geopandas?

I found this article but it doesn't really combine geopandas with cartopy

This is what I tried so far. Also I noticed that cartopy can add Shapely Geometries to its Feature class but not geoDataframes. So far my conclusion is that using Cartopy's reader is easier than using geopandas if your goal is to add the data to cartopy.

2
  • 1
    I haven't tried so not adding an answer, but geopandas geodataframe geometry field contains shapely objects, so you could plot them individually. Alternatively, cartopy can read shapefiles directly - from cartopy.io.shapereader import Reader – user2856 Nov 13 '17 at 1:24
  • a tiny difference matters a lot: parse the geomtery to a list[] and then feed it into cartopy: feature = ShapelyFeature([row.geometry],ccrs.PlateCarree(),facecolor=facecolor,edgecolor=edgecolor,alpha=alpha) – RutgerH Nov 13 '17 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.