import numpy as np
import shapefile
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

sf = shapefile.Reader('D:\\ne_10m_land.shp')

lons, lats = [], []

for shape in sf.shapes():
    parts = shape.parts
    parts.append(len(shape.points))

    lon, lat = [], []

    for pi, pf in zip(parts[:-1], parts[1:]):
        points = np.array(shape.points[pi:pf])
        lo = points[:,0]
        la = points[:,1]

        if west == -180:
            lon.append(lo)
            lat.append(la)
            continue

        idc_frames = np.where((lo[:-1]==lo[1:]) & (abs(abs(lo[:-1])-180)<0.001))[0]
        lo[lo < west] += 360.0

        if idc_frames.size > 0:
            idci = np.r_[0,idc_frames+1]
            idcf = np.r_[idc_frames+1,lo.size]
            for idxi, idxf in zip(idci, idcf):
                lon.append(lo[idxi:idxf])
                lat.append(la[idxi:idxf])

        else:
            lon.append(lo)
            lat.append(la)

    lon_new, lat_new = [], []
    for i, (lo, la) in enumerate(zip(lon, lat)):

        idc_bounds = np.where(abs(lo[1:]-lo[:-1]) > 180)[0]

        if idc_bounds.size > 0:
            idx0 = 0
            for idx in np.r_[idc_bounds+1,lo.size]:
                lon_new.append(lo[idx0:idx])
                lat_new.append(la[idx0:idx])
                idx0 = idx
        else:
            lon_new.append(lo)
            lat_new.append(la)

    lons.append(lon_new)
    lats.append(lat_new)