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

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

示例1: saveimageWithMask

​点赞 9

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def saveimageWithMask(img, outname, mask_poly):

dstimg = copy.deepcopy(img)

for mask in mask_poly:

bound = mask.bounds

if (len(bound) < 4):

continue

xmin, ymin, xmax, ymax = bound[0], bound[1], bound[2], bound[3]

for x in range(int(xmin), int(xmax)):

for y in range(int(ymin), int(ymax)):

point = shgeo.Point(x, y)

if point.within(mask):

#print('withing')

dstimg[int(y)][int(x)] = 0

cv2.imwrite(outname, dstimg)

开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,

示例2: removeIgnoredPointsRects

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def removeIgnoredPointsRects(rects,polyList):

ridxs = list(range(len(rects)))

for ridx in range(len(rects)):

points = rects[ridx]["annopoints"][0]["point"]

pidxs = list(range(len(points)))

for pidx in range(len(points)):

pt = geometry.Point(points[pidx]["x"][0], points[pidx]["y"][0])

bIgnore = False

for poidx in range(len(polyList)):

poly = polyList[poidx]

if (poly.contains(pt)):

bIgnore = True

break

if (bIgnore):

pidxs.remove(pidx)

points = [points[pidx] for pidx in pidxs]

if (len(points) > 0):

rects[ridx]["annopoints"][0]["point"] = points

else:

ridxs.remove(ridx)

rects = [rects[ridx] for ridx in ridxs]

return rects

开发者ID:facebookresearch,项目名称:PoseWarper,代码行数:25,

示例3: removeIgnoredPoints

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def removeIgnoredPoints(gtFramesAll,prFramesAll):

imgidxs = []

for imgidx in range(len(gtFramesAll)):

if ("ignore_regions" in gtFramesAll[imgidx].keys() and

len(gtFramesAll[imgidx]["ignore_regions"]) > 0):

regions = gtFramesAll[imgidx]["ignore_regions"]

polyList = []

for ridx in range(len(regions)):

points = regions[ridx]["point"]

pointList = []

for pidx in range(len(points)):

pt = geometry.Point(points[pidx]["x"][0], points[pidx]["y"][0])

pointList += [pt]

poly = geometry.Polygon([[p.x, p.y] for p in pointList])

polyList += [poly]

rects = prFramesAll[imgidx]["annorect"]

prFramesAll[imgidx]["annorect"] = removeIgnoredPointsRects(rects,polyList)

rects = gtFramesAll[imgidx]["annorect"]

gtFramesAll[imgidx]["annorect"] = removeIgnoredPointsRects(rects,polyList)

return gtFramesAll, prFramesAll

开发者ID:facebookresearch,项目名称:PoseWarper,代码行数:25,

示例4: test_vector_concurrent

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def test_vector_concurrent():

def _work(i):

point, = r1.iter_data(None)

return point

ds = buzz.Dataset(max_active=4)

meta = dict(

type='point',

)

p = mp.pool.ThreadPool(4)

with ds.acreate_vector('/tmp/v1.shp', **meta).delete as r1:

pt = sg.Point([42, 45])

r1.insert_data(pt)

r1.deactivate()

points = list(p.map(_work, range(1000)))

assert all(p == pt for p in points)

assert (ds._back.idle_count(), ds._back.used_count(), ds.active_count) == (4, 0, 4)

assert (ds._back.idle_count(r1._back.uid), ds._back.used_count(r1._back.uid), r1.active_count, r1.active) == (4, 0, 4, True)

p.terminate()

开发者ID:airware,项目名称:buzzard,代码行数:25,

示例5: test_points

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def test_points(fps1px):

"""Test points at fps.E's points of interest"""

fps = fps1px

assert fpeq(

fps.E,

fps.AI.intersection(sg.Point(*fps.E.c)),

fps.AI.intersection(sg.Point(*fps.E.t)),

fps.AI.intersection(sg.Point(*fps.E.l)),

fps.AI.intersection(sg.Point(*fps.E.tl)),

)

assert fpeq(

fps.I,

fps.AI.intersection(sg.Point(*fps.E.br)),

)

assert fpeq(

fps.H,

fps.AI.intersection(sg.Point(*fps.E.bl)),

fps.AI.intersection(sg.Point(*fps.E.b)),

)

assert fpeq(

fps.F,

fps.AI.intersection(sg.Point(*fps.E.tr)),

fps.AI.intersection(sg.Point(*fps.E.r)),

)

开发者ID:airware,项目名称:buzzard,代码行数:26,

示例6: _any_geom_to_shapely

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def _any_geom_to_shapely(geom):

"""Any geom to shapely object. Points should have homogeneous dimensions size."""

if isinstance(geom, (sg.LineString, sg.Point, sg.Polygon, sg.MultiPolygon)):

return geom

if isinstance(geom, dict):

return sg.shape(geom['geometry'])

if isinstance(geom, collections.Container):

geom = np.asarray(geom)

if geom.ndim == 1:

return sg.Point(geom.tolist())

elif geom.ndim == 2:

return sg.LineString(geom.tolist())

elif geom.ndim == 3:

return sg.Polygon(*geom.tolist())

elif geom.ndim == 4:

return sg.MultiPolygon([

sg.Polygon(*poly)

for poly in geom.tolist()

])

assert False

开发者ID:airware,项目名称:buzzard,代码行数:22,

示例7: get_autocomplete

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def get_autocomplete(

query: QueryParams = Depends(QueryParams), extra: ExtraParams = Body(ExtraParams())

):

async def get_intentions():

if not query.nlu or query.lang not in nlu_allowed_languages:

return None

focus = None

if query.lon and query.lat:

focus = Point(query.lon, query.lat)

return await nlu_client.get_intentions(text=query.q, lang=query.lang, focus=focus)

autocomplete_response, intentions = await asyncio.gather(

bragi_client.autocomplete(query, extra), get_intentions()

)

if intentions is not None:

autocomplete_response["intentions"] = intentions

return autocomplete_response

开发者ID:QwantResearch,项目名称:idunn,代码行数:21,

示例8: convert_pix_lstring_to_geo

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def convert_pix_lstring_to_geo(wkt_lstring, im_file):

'''Convert linestring in pixel coords to geo coords'''

shape = wkt_lstring # shapely.wkt.loads(lstring)

x_pixs, y_pixs = shape.coords.xy

coords_latlon = []

coords_utm = []

for (x, y) in zip(x_pixs, y_pixs):

lon, lat = apls_utils.pixelToGeoCoord(x, y, im_file)

[utm_east, utm_north, utm_zone, utm_letter] = utm.from_latlon(lat, lon)

coords_utm.append([utm_east, utm_north])

coords_latlon.append([lon, lat])

lstring_latlon = LineString([Point(z) for z in coords_latlon])

lstring_utm = LineString([Point(z) for z in coords_utm])

return lstring_latlon, lstring_utm, utm_zone, utm_letter

###############################################################################

开发者ID:CosmiQ,项目名称:apls,代码行数:21,

示例9: make_record

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def make_record(properties: Dict[str, type], load_num: str, tree_row: Dict[str, str], point: Dict[str, str]):

"""

shp 파일에 입력할 수목 정보 생성

:return:

"""

# 레코드 기본 구조

record = {'properties': {"탐방로": load_num}, 'geometry': None}

# 수목 정보 입력

for key, value in zip(tree_row.keys(), tree_row.values()):

atr_type = properties[key]

# 속성 타입이 int인데 속성값이 ''일 경우 0으로 입력

record['properties'][key] = atr_type(value) if value or atr_type is str else 0

# 위치정보 입력

record['properties']['경도'] = point['경도']

record['properties']['위도'] = point['위도']

record['properties']['고도'] = point['고도']

record['geometry'] = mapping(Point(point['경도'], point['위도']))

return record

开发者ID:awskrug,项目名称:handson-labs-2018,代码行数:21,

示例10: test_filter_heads

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def test_filter_heads(self):

f = get_demo_file('glacier.svg')

coords = read_svgcoords(f)

polygon = shpg.Polygon(coords)

hidx = np.array([3, 9, 80, 92, 108, 116, 170, len(coords)-12])

heads = [shpg.Point(*c) for c in coords[hidx]]

heads_height = np.array([200, 210, 1000., 900, 1200, 1400, 1300, 250])

radius = 25

_heads, _ = centerlines._filter_heads(heads, heads_height, radius,

polygon)

_headsi, _ = centerlines._filter_heads(heads[::-1],

heads_height[::-1],

radius, polygon)

self.assertEqual(_heads, _headsi[::-1])

self.assertEqual(_heads, [heads[h] for h in [2, 5, 6, 7]])

开发者ID:OGGM,项目名称:oggm,代码行数:22,

示例11: _projection_point

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def _projection_point(centerline, point):

"""Projects a point on a line and returns the closest integer point

guaranteed to be on the line, and guaranteed to be far enough from the

head and tail.

Parameters

----------

centerline : Centerline instance

point : Shapely Point geometry

Returns

-------

(flow_point, ind_closest): Shapely Point and indice in the line

"""

prdis = centerline.line.project(point, normalized=False)

ind_closest = np.argmin(np.abs(centerline.dis_on_line - prdis)).item()

flow_point = shpg.Point(centerline.line.coords[int(ind_closest)])

return flow_point

开发者ID:OGGM,项目名称:oggm,代码行数:20,

示例12: main

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def main(filename="output.png", img_width=2000, img_height=2000, palette=random.choice(palettes.PALETTES), count=50):

ims = cairo.ImageSurface(cairo.FORMAT_ARGB32, img_width, img_height)

ims.set_fallback_resolution(300.0, 300.0)

ctx = cairo.Context(ims)

# Background

ctx.rectangle(0, 0, img_width, img_height)

ctx.set_source_rgb(*palettes.hex_to_tuple(palette['background']))

ctx.fill()

existing_shapes = Point([(0, 0), (0, 0)])

for i in range(count):

print("Making disc {}".format(i))

existing_shapes = sphere(ctx, random.choice(palette['colors']), img_width, img_height, existing_shapes)

ims.write_to_png(filename)

开发者ID:anaulin,项目名称:generative-art,代码行数:18,

示例13: main

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def main(filename="output.png", img_width=2000, img_height=2000, palette=random.choice(palettes.PALETTES), count=50):

ims = cairo.ImageSurface(cairo.FORMAT_ARGB32, img_width, img_height)

ims.set_fallback_resolution(300.0, 300.0)

ctx = cairo.Context(ims)

# Background

ctx.rectangle(0, 0, img_width, img_height)

ctx.set_source_rgb(*palettes.hex_to_tuple(palette['background']))

ctx.fill()

existing_shapes = Point([(0, 0), (0, 0)])

for i in range(count):

print("Making sphere {}".format(i))

existing_shapes = sphere(ctx, random.choice(palette['colors']), img_width, img_height, existing_shapes)

ims.write_to_png(filename)

开发者ID:anaulin,项目名称:generative-art,代码行数:18,

示例14: main

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def main(filename="output.png", img_width=IMG_WIDTH, img_height=IMG_HEIGHT, palette=random.choice(palettes.PALETTES), count=50, line_width=80):

ims = cairo.ImageSurface(cairo.FORMAT_ARGB32, img_width, img_height)

ims.set_fallback_resolution(300.0, 300.0)

ctx = cairo.Context(ims)

# Background

ctx.rectangle(0, 0, img_width, img_height)

ctx.set_source_rgb(*palettes.hex_to_tuple(palette['background']))

ctx.fill()

existing_shapes = Point([(0, 0), (0, 0)])

for i in range(count):

print("Making bar {}".format(i))

existing_shapes = bar(ctx, random.choice(

palette['colors']), line_width, img_width, img_height, existing_shapes)

ims.write_to_png(filename)

开发者ID:anaulin,项目名称:generative-art,代码行数:19,

示例15: nearest_neighbor_within

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def nearest_neighbor_within(others, point, max_distance):

"""Find nearest point among others up to a maximum distance.

Args:

others: a list of Points or a MultiPoint

point: a Point

max_distance: maximum distance to search for the nearest neighbor

Returns:

A shapely Point if one is within max_distance, None otherwise

"""

search_region = point.buffer(max_distance)

interesting_points = search_region.intersection(MultiPoint(others))

if not interesting_points:

closest_point = None

elif isinstance(interesting_points, Point):

closest_point = interesting_points

else:

distances = [point.distance(ip) for ip in interesting_points

if point.distance(ip) > 0]

closest_point = interesting_points[distances.index(min(distances))]

return closest_point

开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:26,

示例16: find_isolated_endpoints

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def find_isolated_endpoints(lines):

"""Find endpoints of lines that don't touch another line.

Args:

lines: a list of LineStrings or a MultiLineString

Returns:

A list of line end Points that don't touch any other line of lines

"""

isolated_endpoints = []

for i, line in enumerate(lines):

other_lines = lines[:i] + lines[i + 1:]

for q in [0, -1]:

endpoint = Point(line.coords[q])

if any(endpoint.touches(another_line)

for another_line in other_lines):

continue

else:

isolated_endpoints.append(endpoint)

return isolated_endpoints

开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:23,

示例17: test_cover_geometry_empty_geoms

​点赞 6

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def test_cover_geometry_empty_geoms(tiler):

"""Empty geometries should return empty iterators."""

assert not cover_geometry(tiler, geometry.Point(), 0) == True

assert not cover_geometry(tiler, geometry.Point(), [0, 1]) == True

assert not cover_geometry(tiler, geometry.MultiPoint(), 0) == True

assert not cover_geometry(tiler, geometry.MultiPoint(), [0, 1]) == True

assert not cover_geometry(tiler, geometry.LineString(), 0) == True

assert not cover_geometry(tiler, geometry.LineString(), [0, 1]) == True

assert not cover_geometry(tiler, geometry.MultiLineString(), 0) == True

assert not cover_geometry(tiler, geometry.MultiLineString(), [0, 1]) == True

assert not cover_geometry(tiler, geometry.Polygon(), 0) == True

assert not cover_geometry(tiler, geometry.Polygon(), [0, 1]) == True

assert not cover_geometry(tiler, geometry.MultiPolygon(), 0) == True

assert not cover_geometry(tiler, geometry.MultiPolygon(), [0, 1]) == True

assert not cover_geometry(tiler, geometry.GeometryCollection(), 0) == True

assert not cover_geometry(tiler, geometry.GeometryCollection(), [0, 1]) == True

开发者ID:DigitalGlobe,项目名称:tiletanic,代码行数:18,

示例18: toGDF

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def toGDF(data):

data = pd.DataFrame(data)

data = gpd.GeoDataFrame(

data, geometry=[Point(xy) for xy in zip(data.longitude, data.latitude)]

)

data = data.drop(["latitude", "longitude"], axis=1)

return data

开发者ID:metro-ontime,项目名称:performance_tracker,代码行数:9,

示例19: cut_in_two

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def cut_in_two(line):

"""

Cuts input line into two lines of equal length

Parameters

----------

line : shapely.LineString

input line

Returns

----------

list (LineString, LineString, Point)

two lines and the middle point cutting input line

"""

from shapely.geometry import Point, LineString

# Get final distance value

distance = line.length/2

# Cuts a line in two at a distance from its starting point

if distance <= 0.0 or distance >= line.length:

return [LineString(line)]

coords = list(line.coords)

for i, p in enumerate(coords):

pd = line.project(Point(p))

if pd == distance:

return [LineString(coords[:i+1]), LineString(coords[i:]), pd]

if pd > distance:

cp = line.interpolate(distance)

return [ LineString(coords[:i] + [(cp.x, cp.y)]), LineString([(cp.x, cp.y)] + coords[i:]), cp]

开发者ID:lgervasoni,项目名称:urbansprawl,代码行数:30,

示例20: get_indices_grid

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def get_indices_grid(df_osm_built, df_osm_building_parts, df_osm_pois, step=100):

"""

Creates an input geodataframe with points sampled in a regular grid

Parameters

----------

df_osm_built : geopandas.GeoDataFrame

OSM processed buildings

df_osm_building_parts : geopandas.GeoDataFrame

OSM processed building parts

df_osm_pois : geopandas.GeoDataFrame

OSM processed points of interest

step : int

step to sample the regular grid in meters

Returns

----------

geopandas.GeoDataFrame

regular grid

"""

# Get bounding box

west, south, east, north = pd.concat( [ df_osm_built, df_osm_building_parts, df_osm_pois ], sort=False ).total_bounds

# Create indices

df_indices = gpd.GeoDataFrame( [ Point(i,j) for i in np.arange(west, east, step) for j in np.arange(south, north, step) ], columns=["geometry"] )

# Set projection

df_indices.crs = df_osm_built.crs

return df_indices

开发者ID:lgervasoni,项目名称:urbansprawl,代码行数:29,

示例21: within_area

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def within_area(flight, area_geojson_location):

if not area_geojson_location:

return True

try:

with open(path.expanduser(area_geojson_location), 'r') as geo:

bounds = geojson.loads(geo.read())["features"][0]["geometry"]

flight_loc = Point(f.get("lon", 0), f.get("lat", 0))

return shape(bounds).contains(flight_loc)

except IOError:

print("couldn't find geojson file at %s, ignoring" % area_geojson_location, file=stderr)

return True

开发者ID:jeremybmerrill,项目名称:flyover,代码行数:13,

示例22: _exterior_coords_iterator

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def _exterior_coords_iterator(geom):

if isinstance(geom, sg.Point):

yield np.asarray(geom)[None, ...]

elif isinstance(geom, sg.Polygon):

yield np.asarray(geom.exterior)

elif isinstance(geom, sg.LineString):

yield np.asarray(geom)

elif isinstance(geom, sg.base.BaseMultipartGeometry):

for part in geom:

for coords in _exterior_coords_iterator(part):

yield coords

else:

assert False

开发者ID:airware,项目名称:buzzard,代码行数:15,

示例23: test_iter_data_fields_behavior

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def test_iter_data_fields_behavior(path):

ds = buzz.Dataset()

with ds.acreate_vector(path, fields=[], type='point').remove as v:

pt0, pt1 = sg.Point(1, 1), sg.Point(2, 2)

v.insert_data(pt0)

v.insert_data(pt1)

assert list(v.iter_data(None)) == [

pt0, pt1

]

assert list(v.iter_data(-1)) == [

pt0, pt1

]

assert list(v.iter_data('')) == [

(pt0,), (pt1,)

]

assert list(v.iter_data([])) == [

(pt0,), (pt1,)

]

assert list(v.iter_data([-1])) == [

(pt0,), (pt1,)

]

with ds.acreate_vector(path, fields=[dict(name='toto', type=int)], type='point').remove as v:

pt0, pt1 = sg.Point(1, 1), sg.Point(2, 2)

v.insert_data(pt0, [42])

v.insert_data(pt1, [43])

assert list(v.iter_data(None)) == [

pt0, pt1

]

assert list(v.iter_data(-1)) == [

(pt0, 42), (pt1, 43)

]

assert list(v.iter_data('')) == [

(pt0,), (pt1,)

]

assert list(v.iter_data([])) == [

(pt0,), (pt1,)

]

assert list(v.iter_data([-1])) == [

(pt0, 42), (pt1, 43)

]

开发者ID:airware,项目名称:buzzard,代码行数:42,

示例24: ReadHillslopeTraces

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def ReadHillslopeTraces(DataDirectory, FilenamePrefix):

"""

This function reads in the file with the suffix '_hillslope_traces.csv'

and creates a geopandas GeoDataFrame

Args:

DataDirectory: the data directory

FilenamePrefix: the file name prefix

Returns:

geopandas GeoDataFrame with data from the csv file spatially organised

Author: MDH

"""

# get the csv filename

Suffix = '_hillslope_traces'

Extension = '.csv'

ReadFilename = DataDirectory+FilenamePrefix+Suffix+Extension

# read in the dataframe using pandas and convert to geopandas geodataframe

df = pd.read_csv(ReadFilename)

geometry = [Point(xy) for xy in zip(df.Longitude, df.Latitude)]

df = df.drop(['Easting','Northing','Longitude', 'Latitude'], axis=1)

crs = {'init': 'epsg:4326'}

geo_df = GeoDataFrame(df, crs=crs, geometry=geometry)

return geo_df

开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:30,

示例25: GetBasinCentroids

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def GetBasinCentroids(DataDirectory, basins_fname):

"""

This function takes in the raster of basins and returns a dict where the

key is the basin key and the value is the shapely point of the centroid

In most cases the "basin key" is actually the junction index: it comes

from the basins labeled within the basin raster, which is output with

junction indices rather than junction keys

Args:

DataDirectory (str): the data directory with the basin raster

fname_prefix (str): the prefix for the DEM

Returns:

dict of centroid points

Author: FJC

"""

# get the basin polygons

BasinDict = GetBasinOutlines(DataDirectory, basins_fname)

# get the centroids

CentroidDict = {}

for basin_key, basin in BasinDict.iteritems():

CentroidDict[basin_key] = Point(basin.centroid)

return CentroidDict

开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:29,

示例26: GetPointWithinBasins

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def GetPointWithinBasins(DataDirectory,basins_fname):

"""

This function takes in the raster of basin and returns a dict where the

key is the basin key and the value is a shapely point that is representative

of the basin (guaranteed to be within the polygon)

In most cases the "basin key" is actually the junction index: it comes

from the basins labeled within the basin raster, which is output with

junction indices rather than junction keys

Args:

DataDirectory (str): the data directory with the basin raster

fname_prefix (str): the prefix for the DEM

Returns:

dict of representative points

Author: FJC

"""

# get the basin polygons

BasinDict = GetBasinOutlines(DataDirectory, basins_fname)

# get the centroids

PointDict = {}

for basin_key, basin in BasinDict.items():

PointDict[basin_key] = Point(basin.representative_point())

return PointDict

开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:30,

示例27: GetPointsWithinMultipleBasins

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def GetPointsWithinMultipleBasins(DataDirectory,basins_fname):

"""

This function takes in rasters of basins and returns a dict where the

key is the basin key and the value is a shapely point that is representative

of the basin (guaranteed to be within the polygon)

In most cases the "basin key" is actually the junction index: it comes

from the basins labeled within the basin raster, which is output with

junction indices rather than junction keys

Args:

DataDirectory (str): the data directory with the basin raster

fname_prefix (str): the prefix for the DEM

Returns:

dict of representative points

Author: FJC

"""

# get the basin polygons

BasinDict = GetMultipleBasinOutlines(DataDirectory)

print("BASIN DICT IS")

print(BasinDict)

# get the centroids

PointDict = {}

for basin_key, basin in BasinDict.iteritems():

PointDict[basin_key] = Point(basin.representative_point())

print("POINT DICT IS")

print(PointDict)

return PointDict

开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:35,

示例28: ReadTerraceData

​点赞 5

# 需要导入模块: from shapely import geometry [as 别名]

# 或者: from shapely.geometry import Point [as 别名]

def ReadTerraceData(DataDirectory,FilenamePrefix):

"""

This function reads in the file with the suffix '_terrace_info.csv'

and creates a geopandas GeoDataFrame

Args:

DataDirectory: the data directory

FilenamePrefix: the file name prefix

Returns:

geopandas GeoDataFrame with data from the csv file spatially organised

Author: FJC

"""

# get the csv filename

Suffix = '_terrace_info'

Extension = '.csv'

ReadFilename = DataDirectory+FilenamePrefix+Suffix+Extension

# read in the dataframe using pandas and convert to geopandas geodataframe

df = pd.read_csv(ReadFilename)

geometry = [Point(xy) for xy in zip(df.Longitude, df.Latitude)]

df = df.drop(['X','Y','Longitude', 'Latitude'], axis=1)

crs = {'init': 'epsg:4326'}

geo_df = GeoDataFrame(df, crs=crs, geometry=geometry)

return geo_df

开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:29,

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

python中geometry用法_Python geometry.Point方法代码示例相关推荐

  1. python中fact用法_Python covariance.EllipticEnvelope方法代码示例

    本文整理汇总了Python中sklearn.covariance.EllipticEnvelope方法的典型用法代码示例.如果您正苦于以下问题:Python covariance.EllipticEn ...

  2. python中config命令_Python config.config方法代码示例

    本文整理汇总了Python中config.config方法的典型用法代码示例.如果您正苦于以下问题:Python config.config方法的具体用法?Python config.config怎么 ...

  3. python中output使用_Python output.Output方法代码示例

    # 需要导入模块: import output [as 别名] # 或者: from output import Output [as 别名] def __init__(self,param,grid ...

  4. python中gettext文件格式_Python locale.gettext方法代码示例

    # 需要导入模块: import locale [as 别名] # 或者: from locale import gettext [as 别名] def get_file_items(self, wi ...

  5. python中stringvar的用法_Python tkinter.StringVar方法代码示例

    本文整理汇总了Python中tkinter.StringVar方法的典型用法代码示例.如果您正苦于以下问题:Python tkinter.StringVar方法的具体用法?Python tkinter ...

  6. python中font的用法_Python font.nametofont方法代码示例

    本文整理汇总了Python中tkinter.font.nametofont方法的典型用法代码示例.如果您正苦于以下问题:Python font.nametofont方法的具体用法?Python fon ...

  7. python中formatter的用法_Python pyplot.FuncFormatter方法代码示例

    本文整理汇总了Python中matplotlib.pyplot.FuncFormatter方法的典型用法代码示例.如果您正苦于以下问题:Python pyplot.FuncFormatter方法的具体 ...

  8. python中bind的用法_Python socket.bind方法代码示例

    本文整理汇总了Python中socket.bind方法的典型用法代码示例.如果您正苦于以下问题:Python socket.bind方法的具体用法?Python socket.bind怎么用?Pyth ...

  9. python end用法_Python turtle.end_fill方法代码示例

    本文整理汇总了Python中turtle.end_fill方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.end_fill方法的具体用法?Python turtle.end_ ...

  10. python中tree 100 6_Python spatial.KDTree方法代码示例

    本文整理汇总了Python中scipy.spatial.KDTree方法的典型用法代码示例.如果您正苦于以下问题:Python spatial.KDTree方法的具体用法?Python spatial ...

最新文章

  1. JavaWeb学习笔记①——Java向下转型在JavaEE中运用——登陆验证
  2. python详细安装教程环境配置-如何安装Python(环境设置)?详细安装步骤图解
  3. Nodejs的express使用教程
  4. 实现和调用API接口
  5. java 时间戳验证_Java中带有时间戳的数字签名
  6. DXperience 8.2.4 简繁体汉化,本地化,Skins包含webform,winform
  7. Linux xargs命令
  8. 全球再迎超级飓风,黑客可利用微软“蠕虫级”高危漏洞暴击全球
  9. Enews博客/CMS/双模式主题源码
  10. 监听器入门看这篇就够了
  11. pandas series 判断是否包含某个值
  12. 打开非遗文化新呈现方式 三七互娱“非遗广州红”游园会即将开幕
  13. 这两个漏洞暴露 Facebook Group 成员,有个用手机就能发现,获奖$9000
  14. Picasso源码的简单解析(一)
  15. 超级计算机app网易,网易有道超级计算器
  16. vs2013 安装VSIX 插件
  17. 网络1711-12信管1711-12 图 作业评分
  18. 第四章:字处理软件Word 2010——知识点整理
  19. 母亲节为什么要定在5月的第二个星期日? [节假日]
  20. [ble_mesh]3.9 Mesh beacon

热门文章

  1. “共识2018”北京区块链大会上BNET创始人刘建军发表了“通信网的未来”的重要演讲
  2. LCD液晶屏表面存在的缺陷及检测应用分析
  3. Tableau 与 Power BI的比较
  4. Vue - 列表拖曳排序 / 鼠标拖动改变顺序排列高效简洁组件(支持PC端与移动端触屏拖动,也可在滚动条内排序自动滚动,流畅丝滑无 BUG)
  5. Android Jetpack Compose 播放器动画
  6. 软件项目生命周期模型
  7. 自然语言处理菜鸟学习笔记(一)
  8. 显示器接口_如何选择显示器连接线?VGA、DVI、HDMI、DP四种主流接口知识
  9. MySQL隔离级别--未提交读,提交读,可重复读,序列化--详解(有示例)
  10. firefox不兼容a标签文件下载