Skip to content

BUG: get/set_coordinates modifies the original geometries #94

@jorisvandenbossche

Description

@jorisvandenbossche

The set_coordinates docstring indicates that it "Returns a copy of a geometry array with different coordinates."

However, this doesn't seem to be working correctly:


In [32]: arr
Out[32]: 
array([<pygeos.Geometry POINT (1 1)>, <pygeos.Geometry POINT (2 2)>,
       <pygeos.Geometry POINT (3 3)>], dtype=object)

In [33]: coords = pygeos.get_coordinates(arr) 

In [35]: new_coords = coords * 2 

In [36]: arr2 = pygeos.set_coordinates(arr, new_coords) 

In [37]: arr2  
Out[37]: 
array([<pygeos.Geometry POINT (2 2)>, <pygeos.Geometry POINT (4 4)>,
       <pygeos.Geometry POINT (6 6)>], dtype=object)

In [39]: arr  
Out[39]: 
array([<pygeos.Geometry POINT (2 2)>, <pygeos.Geometry POINT (4 4)>,
       <pygeos.Geometry POINT (6 6)>], dtype=object)

where the original array was modified in place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions