Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] pydeck.Layer modifies data. Documentation should make this clear! #8322

Open
KS-HTK opened this issue Nov 29, 2023 · 0 comments
Open
Assignees
Milestone

Comments

@KS-HTK
Copy link

KS-HTK commented Nov 29, 2023

Link

https://deckgl.readthedocs.io/en/latest/layer.html

Description

When using 'GeoJsonLayer' and passing a python-geojson object to the data attribute the geojson object gets modified. This sideeffect is not documented.
I spent a while trying to figure out why the geojson geometry suddenly appeared in the properties of a feature as well as in the feature itself. This was due to me using the geojson object after passing it to a Layer. So the layer seems to modify the object.

import geojson
from pydeck import Layer

gj_obj = geojson.FeatureCollection([geojson.Feature(geometry=geojson.Point((0, 0)))])
before = geojson.dumps(gj_obj)
print(before)
layer = Layer('GeoJsonLayer', gj_obj)
after = geojson.dumps(gj_obj)
print(after)
print(before == after)

{"features": [{
"geometry": {"coordinates": [0, 0], "type": "Point"},
"properties": {"geometry": {"coordinates": [0, 0], "type": "Point"}},
"type": "Feature"
}], "type": "FeatureCollection"}

I don't really know why adding the geometry to the properties is neccessary as it is present in the feature anyway, but if it is required it should at least be documented that this is happening.

@KS-HTK KS-HTK added the doc label Nov 29, 2023
@Jesus89 Jesus89 self-assigned this Dec 14, 2023
@donmccurdy donmccurdy added this to the v9.0 milestone Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants