0

I have (lon,lat) data that mark a high resolution coastline. It is a very irregular coastline (estuary) and so when I use matplotlib's fill or fill_between functions, it does not work as it is supposed to, as it also fills parts outside the coast, inside the estuary, as well. I cannot use cartopy or basemap since their "full" resolution is not enough for what I need...

I have read a bunch of other posts (e.g.):

shapefile and matplotlib: plot polygon collection of shapefile coordinates

https://gis.stackexchange.com/questions/131716/plot-shapefile-with-matplotlib

That had the same issue as I do, but they work with shapefile, so I am not sure how can I use it with my data.

For what I have read so far, I think the answer to my problem is to create a closed polygon using path where one side is the coastline (from the data I have), and the others can be straight lines outside of my boundaries...I have read the documentation for path and Patch but have not been able to make it work. How can I do this?

Here is what I get using:

plt.plot(lonc,latc,'.')

plt.plot(lonc,latc,'.') and

plt.fill(lonc,latc)

plt.fill(lonc,latc) (I am sorry I cannot provide the actual data I am working with)...

  • 1
    It looks like your lat / long coords are out of order. If that is the case, you'll have to use some sort of algorithm to "shrink wrap" your vertices. Most of the stuff I've seen on that is for skinning 3D point clouds into triangle or quad surfaces, but it should be extensible to 2D. – Aaron Aug 06 '18 at 14:31
  • Thanks for you answer! I tried to do some sorting of the lat/long coords but had no success! I am not sure what you mean by "shrink wrap"...but I will have a look into that! What I have learned is that the data contains the coastline information as separate polygons that should be plotted separately, I have been trying to figure out how to do that now... –  Aug 07 '18 at 08:42
  • If the separate polygons are easy to separate into lists of coords, you probably could just use [`mpl.patches.polygon()`](https://matplotlib.org/api/_as_gen/matplotlib.patches.Polygon.html#matplotlib-patches-polygon) – Aaron Aug 07 '18 at 13:53

0 Answers0