0

I am successfully able to use map.readshapefile('square', 'dir', drawbounds=True, linewidth=1.5, color='k') to read shape files in. However, I'm having trouble filling them with colors. Filling built-in shapes is quite easy, simply "fill_color=" in the argument. This doesn't seem to work for custom shapes imported via readshapefile. Is there a different syntax? Is this possible at all?

EDIT:

m = Basemap(projection='merc',
            llcrnrlat = 37.807788,
            llcrnrlon = -79.654973,
            urcrnrlat = 39.8277290,
            urcrnrlon = -74.864372,
            resolution = 'c')

m.readshapefile('square', 'dir', drawbounds=True, linewidth=1.5, color='k')
MattM
  • 317
  • 4
  • 12
  • I think you're looking for `facecolor`, not `fill_color`. – farenorth Mar 09 '18 at 16:38
  • Thanks for the response. I've tried facecolor as well but that isn't an accepted argument: 'readshapefile() got an unexpected keyword argument 'facecolor'' – MattM Mar 09 '18 at 16:40
  • Always provide a [mcve] if you have a problem with code. Otherwise how can anyone help here? – ImportanceOfBeingErnest Mar 09 '18 at 16:49
  • I didn't provide a full snippet because this inherently involves loading in a shape file that others do not have access to. I've added lines of code to the original question that currently work for loading a shape border. However, there isn't really a problem with this code - I am trying to understand how to add fill. – MattM Mar 09 '18 at 16:52
  • The code you show loads the shapefile, but it does not draw anything, so it's not clear how you draw it and hence we cannot know why `facecolor` is not working. – ImportanceOfBeingErnest Mar 09 '18 at 16:58
  • The [duplicate](https://stackoverflow.com/questions/37859994/basemap-shapefile-visualizing) shows how to use a polycollection to draw the shapes. You may also use individual polygons like shown in the answer to [this question](https://stackoverflow.com/questions/42639981/how-to-show-shapefile-label-in-python-basemap-legend). – ImportanceOfBeingErnest Mar 09 '18 at 17:06

0 Answers0