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

Attributes #37

Closed
Harshpanday opened this issue Mar 26, 2022 · 5 comments
Closed

Attributes #37

Harshpanday opened this issue Mar 26, 2022 · 5 comments

Comments

@Harshpanday
Copy link

Hello everyone,
How can I access the attributes of the Geodataframe that I use to add the agents?
In the project, I am working on I want to access the coordinates of each agent and use them. Is there a way I can do that?
I already did "set_attributes = True", but I am confused as to how can I access their attributes.

I will be very grateful if anyone can point me in the right direction.

With kindest regards,
Harsh Panday

@wang-boyu
Copy link
Member

I guess the attributes should be part of the GeoAgent object that you create, with the same name as the GeoDataFrame columns (except the geometry column which renames to shape)?

For example if your GeoDataFrame looks like this:

name geometry
0 Alice POINT (1.00000 2.00000)
1 Bob POINT (2.00000 1.00000)

Then the name should be available as agent.name and the geometry is agent.shape.

@Corvince
Copy link
Contributor

Yes you are correct. agent.shape is named due to historical reasons, since originally everything was based on shapely shapes. But definitely should be renamed to agent.geometry.

@wang-boyu
Copy link
Member

Thanks for your clarification, it helps a lot. I was always wondering why agent.shape was used instead of agent.geometry, and whether to just change it back.

I'll send a PR to rename to agent.geometry.

@wang-boyu
Copy link
Member

With #57, geometry is no longer renamed to shape. As I mentioned in #57 (comment), The current behavior is:

  1. If we have the following data:
name geometry
0 Alice POINT (1.00000 2.00000)
1 Bob POINT (2.00000 1.00000)

then it gets loaded as agent.name and agent.geometry respectively.

  1. If the active geometry of the GeoDataFrame is of other name, then it's also gets loaded as geometry. For example:
name home work
0 Alice POINT (1.00000 2.00000) POINT (3.00000 4.00000)
1 Bob POINT (2.00000 1.00000) POINT (4.00000 5.00000)

If home is the active geometry column, then gdf.geometry and gdf.home are essentially the same thing. And it'll be loaded as agent.name, agent.geometry, and agent.work respectively.

@Harshpanday
Copy link
Author

Thank you for the clarification and changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants