Coordinate-Tuple-Listから形の良いポイントを作成する

Stophface

私はそのように見える座標リストを持っています

myCoordinates
> [(2, -6), (21, 19)]

それらをshapely geometryオブジェクトに変換して、それらを使用していくつかの計算を実行できるようにします。

from shapely.geometry import Point
for i in myCoordinates:
    c = [Point(i[0], i[1])]

print c
> [<shapely.geometry.point.Point object at 0x1044033d0>]

ただし、これでは1つ(!)のジオメトリオブジェクトしか得られません。

しかし、私がこれを行うとき

circles = [Point(random.random(), random.random()).buffer(random.random() * 0.1) for i in range(3)]

3つのジオメトリオブジェクトを取得します。

print circles
> [<shapely.geometry.polygon.Polygon object at 0x1043f6890>, <shapely.geometry.polygon.Polygon object at 0x10442f8d0>, <shapely.geometry.polygon.Polygon object at 0x10442f910>]

私は何が間違っているのですか?リスト内の2つではなく、1つのポイントのみをジオメトリオブジェクトに変換するのはなぜですか?

Trev Davies

ループの各反復で変数を上書きしています。cリストを作成してから追加する必要があります。

from shapely.geometry import Point
c = []
for i in myCoordinates:
    c.append([Point(i[0], i[1])])

print c

または、リスト内包表記を使用してすべてを1行で実行できます。

c = [Point(coord[0], coord[1]) for coord in myCoordinates]

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Compare Tuple with a List of Tuples

分類Dev

Converting a List into a Tuple in Elm

分類Dev

String of list or strings to a tuple

分類Dev

形の良いポイントのリストから形の良いポリゴンを作成するにはどうすればよいですか?

分類Dev

Python - Find a tuple in list of lists

分類Dev

Test if tuple exist in python list

分類Dev

Loop a list with a Tuple C#

分類Dev

std :: tupleの入力

分類Dev

GenExpとListCompのTuple()

分類Dev

Coordinate MatrixSparkの行ごとの最大値

分類Dev

List <Tuple>の扱い方

分類Dev

Scala:seqからtupleへ

分類Dev

Apache Storm Tupleの使い方

分類Dev

std::initializer_list が std::get<>、std::tuple_size および std::tuple_element をサポートしないのはなぜですか

分類Dev

std :: tupleを初期化する要素コンストラクターが別のstd :: tupleからのオブジェクトを必要とする

分類Dev

How to init List of tuple and add item in scala

分類Dev

LISTおよびTUPLE代入操作

分類Dev

Sorting a Dictionary by Key and then Value (list or tuple?)

分類Dev

Set Tuple of List to ViewData Mvc C#

分類Dev

Generate Random numbers from tuple list in Python

分類Dev

Merge nested lists into groups in a list of tuple of lists

分類Dev

Combine 2 lists into 1 list with tuple elements

分類Dev

Is there anyway to structure data to python list or tuple that is efficient

分類Dev

Normalize multiple columns of list/tuple data

分類Dev

How to change items in a tuple without casting to a list?

分類Dev

Using list instead of tuple in module __all__

分類Dev

Accessing a range of the first element of a tuple in a list of tuples

分類Dev

Convert a mixed nested list to a nested tuple

分類Dev

TypeErrorが発生するのはなぜですか: '<'は 'int'と 'tuple'のインスタンス間でサポートされていませんか?

Related 関連記事

  1. 1

    Compare Tuple with a List of Tuples

  2. 2

    Converting a List into a Tuple in Elm

  3. 3

    String of list or strings to a tuple

  4. 4

    形の良いポイントのリストから形の良いポリゴンを作成するにはどうすればよいですか?

  5. 5

    Python - Find a tuple in list of lists

  6. 6

    Test if tuple exist in python list

  7. 7

    Loop a list with a Tuple C#

  8. 8

    std :: tupleの入力

  9. 9

    GenExpとListCompのTuple()

  10. 10

    Coordinate MatrixSparkの行ごとの最大値

  11. 11

    List <Tuple>の扱い方

  12. 12

    Scala:seqからtupleへ

  13. 13

    Apache Storm Tupleの使い方

  14. 14

    std::initializer_list が std::get<>、std::tuple_size および std::tuple_element をサポートしないのはなぜですか

  15. 15

    std :: tupleを初期化する要素コンストラクターが別のstd :: tupleからのオブジェクトを必要とする

  16. 16

    How to init List of tuple and add item in scala

  17. 17

    LISTおよびTUPLE代入操作

  18. 18

    Sorting a Dictionary by Key and then Value (list or tuple?)

  19. 19

    Set Tuple of List to ViewData Mvc C#

  20. 20

    Generate Random numbers from tuple list in Python

  21. 21

    Merge nested lists into groups in a list of tuple of lists

  22. 22

    Combine 2 lists into 1 list with tuple elements

  23. 23

    Is there anyway to structure data to python list or tuple that is efficient

  24. 24

    Normalize multiple columns of list/tuple data

  25. 25

    How to change items in a tuple without casting to a list?

  26. 26

    Using list instead of tuple in module __all__

  27. 27

    Accessing a range of the first element of a tuple in a list of tuples

  28. 28

    Convert a mixed nested list to a nested tuple

  29. 29

    TypeErrorが発生するのはなぜですか: '<'は 'int'と 'tuple'のインスタンス間でサポートされていませんか?

ホットタグ

アーカイブ