当前位置: 首页>>代码示例>>Python>>正文


Python shapereader.Reader方法代码示例

本文整理汇总了Python中cartopy.io.shapereader.Reader方法的典型用法代码示例。如果您正苦于以下问题:Python shapereader.Reader方法的具体用法?Python shapereader.Reader怎么用?Python shapereader.Reader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cartopy.io.shapereader的用法示例。


在下文中一共展示了shapereader.Reader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_geoms

# 需要导入模块: from cartopy.io import shapereader [as 别名]
# 或者: from cartopy.io.shapereader import Reader [as 别名]
def _get_geoms(self, _f, attname):
        """Get Shapely geometries of locations from Natural Earth.
        
        Parameters
        ----------
        _f : str
            Natural Earth file name
        attname : str
            Expected attribute name
            
        Returns
        -------
        self.geoms : list of geometries
        """
        filename = shapereader.natural_earth(resolution='10m',
                                             category='cultural',
                                             name=_f)
        reader = shapereader.Reader(filename)
        records = list(reader.records())
        for _loc in records:
            if _loc.attributes[attname] in self.loc_names:
                if _loc.attributes[attname] == 'France':
                    # Only want mainland France. Not its territories
                    try:
                        self.geoms += _loc.geometry[-1]
                    except TypeError:
                        self.geoms.append(_loc.geometry[-1])
                else:
                    try:
                        self.geoms += _loc.geometry
                    except TypeError:
                        self.geoms.append(_loc.geometry)                    
        return self 
开发者ID:raybellwaves,项目名称:cfanalytics,代码行数:35,代码来源:cfplot.py

示例2: __extract

# 需要导入模块: from cartopy.io import shapereader [as 别名]
# 或者: from cartopy.io.shapereader import Reader [as 别名]
def __extract():
    """
    读取中国省级行政区划.shp文件
    provinces_geometrys:geometry列表
    provinces_attributes:attribute列表
    """
    shpname = r"China_province"
    provinces_records = list(shpreader.Reader(shpname).records())
    provinces_geometrys = [x.geometry for x in provinces_records]
    provinces_attributes = [x.attributes for x in provinces_records]
    return provinces_geometrys, provinces_attributes 
开发者ID:Mo-Dabao,项目名称:pyMeteo,代码行数:13,代码来源:China_province.py

示例3: from_shapefile

# 需要导入模块: from cartopy.io import shapereader [as 别名]
# 或者: from cartopy.io.shapereader import Reader [as 别名]
def from_shapefile(cls, shapefile, *args, **kwargs):
        """
        Loads a shapefile from disk and optionally merges
        it with a dataset. See ``from_records`` for full
        signature.

        Parameters
        ----------
        records: list of cartopy.io.shapereader.Record
           Iterator containing Records.
        dataset: holoviews.Dataset
           Any HoloViews Dataset type.
        on: str or list or dict
          A mapping between the attribute names in the records and the
          dimensions in the dataset.
        value: str
          The value dimension in the dataset the values will be drawn
          from.
        index: str or list
          One or more dimensions in the dataset the Shapes will be
          indexed by.
        drop_missing: boolean
          Whether to drop shapes which are missing from the provides
          dataset.

        Returns
        -------
        shapes: Polygons or Path object
          A Polygons or Path object containing the geometries
        """
        reader = Reader(shapefile)
        return cls.from_records(reader.records(), *args, **kwargs) 
开发者ID:holoviz,项目名称:geoviews,代码行数:34,代码来源:geo.py

示例4: map_detecs

# 需要导入模块: from cartopy.io import shapereader [as 别名]
# 或者: from cartopy.io.shapereader import Reader [as 别名]
def map_detecs(catalog, prefix, minmag=-5, mindep=-50, title=''):
    """Make scatter plot of detections with magnitudes (if applicable)."""
    catalog = catalog[(catalog['mag'] >= minmag)
                      & (catalog['depth'] >= mindep)].copy()

    if len(catalog) == 0:
        print('\nCatalog contains no events deeper than %s.' % mindep)
        return

    # define map bounds
    lllat, lllon, urlat, urlon, _, _, _, clon = qcu.get_map_bounds(catalog)

    plt.figure(figsize=(12, 7))
    mplmap = plt.axes(projection=ccrs.PlateCarree(central_longitude=clon))
    #mplmap.set_extent([lllon, urlon, lllat, urlat], ccrs.PlateCarree())
    mplmap.coastlines('50m', facecolor='none')

    # if catalog has magnitude data
    if not catalog['mag'].isnull().all():
        bins = [0, 5, 6, 7, 8, 15]
        binnames = ['< 5', '5-6', '6-7', '7-8', r'$\geq$8']
        binsizes = [10, 25, 50, 100, 400]
        bincolors = ['g', 'b', 'y', 'r', 'r']
        binmarks = ['o', 'o', 'o', 'o', '*']
        catalog.loc[:, 'maggroup'] = pd.cut(catalog['mag'], bins,
                                            labels=binnames)

        for i, label in enumerate(binnames):
            mgmask = catalog['maggroup'] == label
            rcat = catalog[mgmask]
            lons, lats = list(rcat['longitude']), list(rcat['latitude'])
            if len(lons) > 0:
                mplmap.scatter(lons, lats, s=binsizes[i], marker=binmarks[i],
                               c=bincolors[i], label=binnames[i], alpha=0.8,
                               zorder=10, transform=ccrs.PlateCarree())

        plt.legend(loc='lower left', title='Magnitude')

    # if catalog does not have magnitude data
    else:
        lons, lats = list(catalog['longitude']), list(catalog['latitude'])
        mplmap.scatter(lons, lats, s=15, marker='x', c='r', zorder=10)

    shape_feature = ShapelyFeature(Reader(china_border_file).geometries(),
                                   ccrs.PlateCarree(), edgecolor='black',
                                   facecolor='none')
    shape_feature1 = ShapelyFeature(Reader(fault_file).geometries(),
                                   ccrs.PlateCarree(), edgecolor='red',
                                   facecolor='none')        
    mplmap.add_feature(shape_feature)
    mplmap.add_feature(shape_feature1)

    plt.title(title, fontsize=20)
    plt.subplots_adjust(left=0.05, right=0.95, top=0.95, bottom=0.05)

    if mindep != -50:
        plt.savefig('%s_morethan%sdetecs.png' % (prefix, mindep), dpi=300)
    else:
        plt.savefig('%s_mapdetecs.png' % prefix, dpi=300)

    plt.close() 
开发者ID:igp-gravity,项目名称:geoist,代码行数:63,代码来源:QCreport.py

示例5: plot_base

# 需要导入模块: from cartopy.io import shapereader [as 别名]
# 或者: from cartopy.io.shapereader import Reader [as 别名]
def plot_base(self, bous = 1, bmap = None, 
                  features = ['land','ocean','lake','river'], 
                  gridline = True, lic = True):
        """
        Plot map base

        Parameters
        ----------
        bous : TYPE, optional
            DESCRIPTION. The default is 1.
        bmap : TYPE, optional
            DESCRIPTION. The default is None.
        features : TYPE, optional
            DESCRIPTION. The default is ['land','ocean','lake','river'].
        gridline : TYPE, optional
            DESCRIPTION. The default is True.
        lic : TYPE, optional
            DESCRIPTION. The default is True.

        Returns
        -------
        None.

        """
        if self.engine == 'gmt':
            self.gmt_plot_base(self.region)
        else:
            self.fig.set_extent([72, 137, 10, 55])
            self.fig.stock_img()
            self.fig.coastlines()
            self.fig.add_feature(cfeature.LAND)
            self.fig.add_feature(cfeature.OCEAN)
            self.fig.add_feature(cfeature.LAKES)
            self.fig.add_feature(cfeature.RIVERS)
            self.fig.gridlines(crs=ccrs.PlateCarree(), draw_labels=True)
            datapath = Path(Path(catalog.__file__).parent,'data')
            fname = Path(datapath, 'bou1_4l.shp')
            f2name = Path(datapath, 'bou2_4l.shp')
            faults = Path(datapath, 'gem_active_faults.shp')
            
            self.fig.add_geometries(Reader(str(faults)).geometries(),
                              ccrs.PlateCarree(),facecolor = 'none',
                              edgecolor='red')
            
            self.fig.add_geometries(Reader(str(f2name)).geometries(),
                              ccrs.PlateCarree(),  facecolor = 'none', 
                              edgecolor='gray', linestyle=':')
            
            self.fig.add_geometries(Reader(str(fname)).geometries(),
                              ccrs.PlateCarree(),  facecolor = 'none', 
                              edgecolor='black') 
开发者ID:igp-gravity,项目名称:geoist,代码行数:53,代码来源:gratools.py


注:本文中的cartopy.io.shapereader.Reader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。