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


Python crs.Projection方法代码示例

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


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

示例1: __init__

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def __init__(
        self,
        traffic: "Traffic",
        clustering: ClusteringProtocol,
        nb_samples: Optional[int],
        features: List[str],
        *args,
        projection: Union[None, crs.Projection, pyproj.Proj] = None,
        transform: Optional[TransformerProtocol] = None,
    ) -> None:

        self.traffic = traffic
        self.clustering = clustering
        self.nb_samples = nb_samples
        self.features = features
        self.projection = projection
        self.transform = transform
        self.X = None 
开发者ID:xoolive,项目名称:traffic,代码行数:20,代码来源:clustering.py

示例2: prepare_features

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def prepare_features(
    traffic: "Traffic",
    nb_samples: Optional[int],
    features: List[str],
    projection: Union[None, crs.Projection, pyproj.Proj] = None,
    max_workers: int = 1,
) -> np.ndarray:
    if "last_position" in traffic.data.columns:
        traffic = traffic.drop(columns="last_position")

    resampled = traffic
    if nb_samples is not None:
        _resampled = traffic.resample(nb_samples).eval(max_workers=max_workers)
        # TODO LazyTraffic/LazyOptionalTraffic
        assert _resampled is not None
        resampled = _resampled

    if all(
        [
            "x" in features,
            "y" in features,
            "x" not in resampled.data.columns,
            "y" not in resampled.data.columns,
        ]
    ):
        if projection is None:
            raise RuntimeError(
                "No 'x' and 'y' columns nor projection method passed"
            )
        resampled = resampled.compute_xy(projection)

    return np.stack(list(f.data[features].values.ravel() for f in resampled)) 
开发者ID:xoolive,项目名称:traffic,代码行数:34,代码来源:clustering.py

示例3: centroid

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def centroid(
    traffic: "Traffic",
    nb_samples: Optional[int],
    features: List[str],
    projection: Union[None, crs.Projection, pyproj.Proj] = None,
    transform: Optional[TransformerProtocol] = None,
    max_workers: int = 1,
    *args,
    **kwargs,
) -> "Flight":
    """
    Returns the trajectory in the Traffic that is the closest to all other
    trajectories.

    .. warning::
        Remember the time and space complexity of this method is **quadratic**.

    """

    X = prepare_features(traffic, nb_samples, features, projection, max_workers)
    ids = list(f.flight_id for f in traffic)

    if transform is not None:
        X = transform.fit_transform(X)

    return traffic[
        ids[squareform(pdist(X, *args, **kwargs)).mean(axis=1).argmin()]
    ] 
开发者ID:xoolive,项目名称:traffic,代码行数:30,代码来源:clustering.py

示例4: centroid

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def centroid(
        self,
        nb_samples: Optional[int],
        features: Optional[List[str]] = None,
        projection: Union[None, crs.Projection, pyproj.Proj] = None,
        transformer: Optional["TransformerProtocol"] = None,
        max_workers: int = 1,
        *args,
        **kwargs,
    ) -> "Flight":
        """
        Returns the trajectory in the Traffic that is the closest to all other
        trajectories.

        .. warning::
            Remember the time and space complexity of this method is in O(n^2).

        *args and **kwargs are passed as is to `scipy.spatial.pdist
        <https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html#scipy.spatial.distance.pdist>`_

        """

        if features is None:
            features = ["x", "y"]

        return centroid(
            self,
            nb_samples,
            features,
            projection,
            transformer,
            max_workers,
            *args,
            **kwargs,
        ) 
开发者ID:xoolive,项目名称:traffic,代码行数:37,代码来源:traffic.py

示例5: compute_xy

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def compute_xy(
        self: T, projection: Union[pyproj.Proj, crs.Projection, None] = None
    ) -> T:
        """Enrich the structure with new x and y columns computed through a
        projection of the latitude and longitude columns.

        The source projection is WGS84 (EPSG 4326).
        The default destination projection is a Lambert Conformal Conical
        projection centered on the data inside the dataframe.

        Other valid projections are available:

        - as ``pyproj.Proj`` objects;
        - as ``cartopy.crs.Projection`` objects.
        """

        if isinstance(projection, crs.Projection):
            projection = pyproj.Proj(projection.proj4_init)

        if projection is None:
            projection = pyproj.Proj(
                proj="lcc",
                ellps="WGS84",
                lat_1=self.data.latitude.min(),
                lat_2=self.data.latitude.max(),
                lat_0=self.data.latitude.mean(),
                lon_0=self.data.longitude.mean(),
            )

        transformer = pyproj.Transformer.from_proj(
            pyproj.Proj("epsg:4326"), projection, always_xy=True
        )
        x, y = transformer.transform(
            self.data.longitude.values, self.data.latitude.values,
        )

        return self.__class__(self.data.assign(x=x, y=y)) 
开发者ID:xoolive,项目名称:traffic,代码行数:39,代码来源:mixins.py

示例6: contour

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def contour(self, x=None, y=None, z=None, data=None, filled=False):
        from holoviews.operation import contours

        if 'projection' in self._plot_opts:
            import cartopy.crs as ccrs
            t = self._plot_opts['projection']
            if isinstance(t, ccrs.CRS) and not isinstance(t, ccrs.Projection):
                raise ValueError('invalid transform:'
                                 ' Spherical contouring is not supported - '
                                 ' consider using PlateCarree/RotatedPole.')

        opts = self._get_opts('Contours')
        qmesh = self.quadmesh(x, y, z, data)

        if self.geo:
            # Apply projection before contouring
            import cartopy.crs as ccrs
            from geoviews import project
            projection = self._plot_opts.get('projection', ccrs.GOOGLE_MERCATOR)
            qmesh = project(qmesh, projection=projection)

        if filled:
            opts['line_alpha'] = 0

        if opts['colorbar']:
            opts['show_legend'] = False
        levels = self.kwds.get('levels', 5)
        if isinstance(levels, int):
            opts['color_levels'] = levels
        return contours(qmesh, filled=filled, levels=levels).opts(**opts) 
开发者ID:holoviz,项目名称:hvplot,代码行数:32,代码来源:converter.py

示例7: add_shp

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def add_shp(
    ax: Any,
    proj: ccrs.Projection,
    coastline: bool = False,
    style: str = "black",
    extent: Optional[Array_T] = None,
):
    shp_crs = ccrs.PlateCarree()
    shps = get_shp()
    if style == "black":
        line_colors = ["grey", "lightgrey", "white"]
    elif style == "white":
        line_colors = ["lightgrey", "grey", "black"]
    ax.add_geometries(
        shps[0],
        shp_crs,
        edgecolor=line_colors[0],
        facecolor="None",
        zorder=3,
        linewidth=0.5,
    )
    ax.add_geometries(
        shps[1],
        shp_crs,
        edgecolor=line_colors[1],
        facecolor="None",
        zorder=3,
        linewidth=0.7,
    )
    ax.add_geometries(
        shps[2],
        shp_crs,
        edgecolor=line_colors[2],
        facecolor="None",
        zorder=3,
        linewidth=1,
    )
    if coastline:
        ax.coastlines(resolution="10m", color=line_colors[2], zorder=3, linewidth=1) 
开发者ID:CyanideCN,项目名称:PyCINRAD,代码行数:41,代码来源:utils.py

示例8: create_geoaxes

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def create_geoaxes(fig: Any, proj: ccrs.Projection, extent: List[Number_T]) -> GeoAxes:
    ax = fig.add_axes(GEOAXES_POS, projection=proj)
    ax.background_patch.set_visible(False)
    ax.outline_patch.set_visible(False)
    x_min, x_max, y_min, y_max = extent[0], extent[1], extent[2], extent[3]
    ax.set_extent([x_min, x_max, y_min, y_max], crs=ccrs.PlateCarree())
    return ax 
开发者ID:CyanideCN,项目名称:PyCINRAD,代码行数:9,代码来源:utils.py

示例9: __init__

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def __init__(self):
        """Initializes the Projection pane."""
        super().__init__()
        self.is_geo = pn.widgets.Checkbox(name='is_geo', value=False,
                                          disabled=True, width=200)
        self.alpha = pn.widgets.FloatSlider(name='alpha', start=0, end=1,
                                            step=0.01, value=0.7, width=200)

        basemap_opts = [None] + list(gvts.tile_sources.keys())
        self.basemap = pn.widgets.Select(name='basemap',
                                         options=basemap_opts,
                                         value=None, width=150)
        self.projection = pn.widgets.Select(name='projection',
                                            options=[None] + sorted(projections_list),
                                            value=None, width=150)
        self.crs = pn.widgets.Select(name='crs',
                                     options=sorted(projections_list),
                                     value='PlateCarree', width=150)
        self.project = pn.widgets.Checkbox(name='project', value=False, width=150)
        self.global_extent = pn.widgets.Checkbox(name='global_extent',
                                                 value=False, width=150)
        self.crs_params = pn.widgets.TextInput(name='crs params',
                                               value="{}", width=400)
        self.proj_params = pn.widgets.TextInput(name='projection params',
                                                value="{}", width=400)

        self.feature_ops = ['None', 'borders', 'coastline', 'grid', 'land',
                            'lakes', 'ocean', 'rivers']
        self.features = pn.widgets.MultiSelect(name='features',
                                               options=self.feature_ops,
                                               value=self.feature_ops[1:], width=150)

        self._register(self.is_geo, 'geo_changed')
        self._register(self.is_geo, 'geo_disabled', 'disabled')
        self._register(self.crs, 'add_crs_params')
        self._register(self.projection, 'add_proj_params')
        self._register(self.basemap, 'show_basemap')

        self.connect('geo_changed', self.setup)
        self.connect('geo_disabled', self.setup)
        self.connect('add_crs_params', self.add_crs_params)
        self.connect('add_proj_params', self.add_proj_params)
        self.connect('show_basemap', self.show_basemap)

        self.panel = pn.Column(
            pn.pane.Markdown(TEXT, margin=(0, 10)),
            pn.Row(self.is_geo,  self.project, self.global_extent),
            pn.Row(self.alpha, self.basemap, self.features),
            pn.Row(self.crs, self.crs_params, name='crs'),
            pn.Row(self.projection, self.proj_params, name='proj'),
            name='Projection')
        self.setup()
        self.add_crs_params(self.crs.value)
        self.add_proj_params(self.projection.value) 
开发者ID:intake,项目名称:xrviz,代码行数:56,代码来源:projection.py

示例10: closest_point_of_approach

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Projection [as 别名]
def closest_point_of_approach(
        self,
        lateral_separation: float,
        vertical_separation: float,
        projection: Union[pyproj.Proj, crs.Projection, None] = None,
        round_t: str = "d",
        max_workers: int = 4,
    ) -> Optional["CPA"]:
        """
        Computes a Closest Point of Approach (CPA) dataframe for all pairs of
        trajectories candidates for being separated by less than
        lateral_separation in vertical_separation.

        The problem of iterating over pairs of trajectories is of unreasonable
        complexity O(n**2). Therefore, instead of computing the CPA between all
        pairs of trajectory, we do it for all pairs of trajectories coming
        closer than a given ``lateral_separation`` and ``vertical_separation``.

        lateral_separation: float (in **meters**)
            Depending on your application, you could start with 10 * 1852 (for
            10 nautical miles)

        vertical_separation: float (in ft)
            Depending on your application, you could start with 1500 (feet)

        projection: pyproj.Proj, crs.Projection, None
            a first filtering is applied on the bounding boxes of trajectories,
            expressed in meters. You need to provide a decent projection able to
            approximate distances by Euclide formula. By default, EuroPP()
            projection is considered, but a non explicit argument will raise a
            warning.

        round_t: str
            an additional column will be added in the DataFrame to group
            trajectories by relevant time frames. Distance computations will be
            considered only between trajectories flown in the same time frame.
            By default, the 'd' pandas freq parameter is considered, to group
            trajectories by day, but other ways of splitting ('h') may be more
            relevant and impact performance.

        max_workers: int
            distance computations are spread over a given number of
            processors.

        Returns a CPA DataFrame wrapper.

        """

        return closest_point_of_approach(
            self,
            lateral_separation,
            vertical_separation,
            projection,
            round_t,
            max_workers,
        ) 
开发者ID:xoolive,项目名称:traffic,代码行数:58,代码来源:traffic.py


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