Plotting shapefile using LineCollection shows all edges, but partially fills them

前端 未结 2 1901
有刺的猬
有刺的猬 2020-12-07 04:19

For the past few days I have been trying to get weather station data interpolated in a map for my country only. I do this as follows:

  • Loading the data, I crea
2条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 04:41

    You haven't plotted the Netherlands.

    # Create map
    ...
    # Draw contours
    ...
    # Plot seas from shapefile
    sf = shp.Reader(r'/DIR_TO_SHP/shapefiles/northsea')
    ...
    # Plot France from shapefile
    sf = shp.Reader(r'/DIR_TO_SHP/shapefiles/FRA_adm0')
    ...
    # Plot Belgium from shapefile
    sf = shp.Reader(r'/DIR_TO_SHP/shapefiles/BEL_adm0')
    ...
    # Plot Germany from shapefile
    sf = shp.Reader(r'/DIR_TO_SHP/shapefiles/DEU_adm0')
    ...
    # Finish plot

    So parts of the Netherlands are filled in with your plotted data, The coastlines are there (from drawing the seas?), but the rest of the country isn't there because you haven't drawn it.

    I would steer away from this method of drawing from each shapefile individually, and try to just use basemap for your coastlines, etc. If you must do it from the shapefiles, I would encourage you to define a function that does something like:

    def drawContentsOfShapeFile(mymap, path_to_shapefile):
        
    
    #and use it:
    m = Basemap(...)
    myshapefiles = []
    myshapefiles.append("/DIR_TO_SHP/shapefiles/FRA_adm0")
    myshapefiles.append("/DIR_TO_SHP/shapefiles/norway")
    
    for sf in myshapefiles: drawContentOfShapefile(m, sf)
    

提交回复
热议问题