本文整理汇总了Python中fiona.crs.from_epsg方法的典型用法代码示例。如果您正苦于以下问题:Python crs.from_epsg方法的具体用法?Python crs.from_epsg怎么用?Python crs.from_epsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fiona.crs
的用法示例。
在下文中一共展示了crs.from_epsg方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: latlon_to_shp
# 需要导入模块: from fiona import crs [as 别名]
# 或者: from fiona.crs import from_epsg [as 别名]
def latlon_to_shp(lon, lat, shapefile):
shapefile = str(shapefile)
schema = {'geometry': 'Point',
'properties': {'id': 'str'}}
wkt = loads('POINT ({} {})'.format(lon, lat))
with collection(shapefile, "w",
crs=from_epsg(4326),
driver="ESRI Shapefile",
schema=schema) as output:
output.write({'geometry': mapping(wkt),
'properties': {'id': '1'}})
示例2: projectShapes
# 需要导入模块: from fiona import crs [as 别名]
# 或者: from fiona.crs import from_epsg [as 别名]
def projectShapes(features, toCRS):
import pyproj
from functools import partial
import fiona.crs as fcrs
from shapely.geometry import shape, mapping
from shapely.ops import transform as shpTrans
project = partial(
pyproj.transform,
pyproj.Proj(fcrs.from_epsg(4326)),
pyproj.Proj(toCRS))
return list(
{'geometry': mapping(
shpTrans(
project,
shape(feat['geometry']))
)} for feat in features
)
示例3: generate_empty_md_graph
# 需要导入模块: from fiona import crs [as 别名]
# 或者: from fiona.crs import from_epsg [as 别名]
def generate_empty_md_graph(name: str,
init_crs: Dict=crs.from_epsg(WGS84)):
"""
Generates an empty multi-directed graph.
Parameters
———————
name : str
The name of the graph
init_crs : dict
The coordinate reference system to be assigned to the graph. Example \
CRS would be `{'init': 'epsg:4326'}`
Returns
——
G : nx.MultiDiGraph
The muti-directed graph
"""
return nx.MultiDiGraph(name=name, crs=init_crs)
示例4: make_shp
# 需要导入模块: from fiona import crs [as 别名]
# 或者: from fiona.crs import from_epsg [as 别名]
def make_shp(tree_csv, points, hashid):
"""
수목정보와 좌표정보를 매칭시켜 shp파일을 생성합니다
:param tree_csv:
:param points:
:return:
"""
shp_driver = 'ESRI Shapefile'
properties = OrderedDict([
# tree_csv에서 가져올 정보
('탐방로', str), ('구간', int), ('좌우', str), ('종명', str), ('개화', int), ('결실', int), ('비고', str),
# point_csv에서 가져올 정보
('경도', float), ('위도', float), ('고도', int)
])
# 타입별 기본값
shp_schema = {
#
'properties': [(atr, properties[atr].__name__) for atr in properties],
'geometry': 'Point'
}
shp_crs = crs.from_epsg(4326)
file = f'/tmp/{hashid}.shp'
with fiona.open(file, 'w', encoding="utf-8", driver=shp_driver, schema=shp_schema, crs=shp_crs) as shp:
for row in tree_csv:
# 구간 번호
point_num = int(row['구간'])
# 수목의 구간번호에 매칭하는 좌표 정보
point_info = points[point_num]
# shp에 입력될 형식
record = make_record(properties, 1, row, point_info)
shp.write(record)
return file
示例5: to_crs
# 需要导入模块: from fiona import crs [as 别名]
# 或者: from fiona.crs import from_epsg [as 别名]
def to_crs(self, crs):
"""
Returns the trajectory reprojected to the target CRS.
Parameters
----------
crs : pyproj.CRS
Target coordinate reference system
Returns
-------
Trajectory
Examples
--------
Reproject a trajectory to EPSG:4088
>>> from pyproj import CRS
>>> reprojected = trajectory.to_crs(CRS(4088))
"""
temp = self.copy()
temp.crs = crs
temp.df = temp.df.to_crs(crs)
if type(crs) == CRS:
temp.is_latlon = crs.is_geographic
else:
temp.is_latlon = crs['init'] == from_epsg(4326)['init']
return temp
示例6: extract_tile_items
# 需要导入模块: from fiona import crs [as 别名]
# 或者: from fiona.crs import from_epsg [as 别名]
def extract_tile_items(
raster_features, labels, min_x, min_y, tile_width, tile_height
):
"""Extract label items that belong to the tile defined by the minimum
horizontal pixel `min_x` (left tile limit), the minimum vertical pixel
`min_y` (upper tile limit) and the sizes ̀tile_width` and `tile_height`
measured as a pixel amount.
The tile is cropped from the original image raster as follows:
- horizontally, between `min_x` and `min_x+tile_width`
- vertically, between `min_y` and `min_y+tile_height`
This method takes care of original data projection (UTM 37S, Tanzania
area), however this parameter may be changed if similar data on another
projection is used.
Parameters
----------
raster_features : dict
Raw image raster geographical features (`north`, `south`, `east` and
`west` coordinates, `weight` and `height` measured in pixels)
labels : geopandas.GeoDataFrame
Raw image labels, as a set of geometries
min_x : int
Left tile limit, as a horizontal pixel index
min_y : int
Upper tile limit, as a vertical pixel index
tile_width : int
Tile width, measured in pixel
tile_height : int
Tile height, measured in pixel
Returns
-------
geopandas.GeoDataFrame
Set of ground-truth labels contained into the tile, characterized by
their type (complete, unfinished or foundation) and their geometry
"""
area = get_tile_footprint(
raster_features, min_x, min_y, tile_width, tile_height
)
bdf = gpd.GeoDataFrame(
crs=from_epsg(raster_features["srid"]), geometry=[area]
)
reproj_labels = labels.to_crs(epsg=raster_features["srid"])
tile_items = gpd.sjoin(reproj_labels, bdf)
if tile_items.shape[0] == 0:
return tile_items[["condition", "geometry"]]
tile_items = gpd.overlay(tile_items, bdf)
tile_items = tile_items.explode() # Manage MultiPolygons
return tile_items[["condition", "geometry"]]
示例7: __init__
# 需要导入模块: from fiona import crs [as 别名]
# 或者: from fiona.crs import from_epsg [as 别名]
def __init__(self, df, traj_id, obj_id=None, parent=None):
"""
Create Trajectory from GeoDataFrame.
Parameters
----------
df : GeoDataFrame
GeoDataFrame with point geometry column and timestamp index
traj_id : any
Trajectory ID
obj_id : any
Moving object ID
parent : Trajectory
Parent trajectory
Examples
--------
Creating a trajectory from scratch:
>>> import pandas as pd
>>> import geopandas as gpd
>>> import movingpandas as mpd
>>> from fiona.crs import from_epsg
>>>
>>> df = pd.DataFrame([
... {'geometry':Point(0,0), 't':datetime(2018,1,1,12,0,0)},
... {'geometry':Point(6,0), 't':datetime(2018,1,1,12,6,0)},
... {'geometry':Point(6,6), 't':datetime(2018,1,1,12,10,0)},
... {'geometry':Point(9,9), 't':datetime(2018,1,1,12,15,0)}
... ]).set_index('t')
>>> gdf = gpd.GeoDataFrame(df, crs=from_epsg(31256))
>>> traj = mpd.Trajectory(gdf, 1)
For more examples, see the tutorial notebooks_.
.. _notebooks: https://mybinder.org/v2/gh/anitagraser/movingpandas/binder-tag?filepath=tutorials/0_getting_started.ipynb
"""
if len(df) < 2:
raise ValueError("Trajectory dataframe must have at least two rows!")
self.id = traj_id
self.obj_id = obj_id
df.sort_index(inplace=True)
self.df = df[~df.index.duplicated(keep='first')]
#self.df['t'] = self.df.index
self.crs = df.crs
self.parent = parent
if self.crs is None:
self.is_latlon = False
return
try:
crs = CRS.from_user_input(self.crs)
self.is_latlon = crs.is_geographic
except NameError:
self.is_latlon = self.crs['init'] == from_epsg(4326)['init']