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

Integration with tmaps #37

Open
josoga2 opened this issue Aug 7, 2022 · 2 comments
Open

Integration with tmaps #37

josoga2 opened this issue Aug 7, 2022 · 2 comments

Comments

@josoga2
Copy link

josoga2 commented Aug 7, 2022

Hello @BroVic ,
Just out of curiosity, is it possible to get the geometry data for state-level data for later use with tmaps? I specified tmaps because of its interactive mode.

@BroVic
Copy link
Collaborator

BroVic commented Aug 8, 2022

Hi @josoga2

The map_ng function returns a list as specified in ?maps::map.. The documentation says this about the return value:

The return value is a list with x, y, range, and names components. This object can be used as a database for successive calls to map and functions. If fill is FALSE, the x and y vectors are the coordinates of successive polylines, separated by NAs. If fill is TRUE, the x and y vectors have coordinates of successive polygons, again separated by NAs. Thus the return value can be handed directly to lines or polygon, as appropriate

I think tmaps expects "simple feature" objects, so if you work with the sf package, I suppose you can use this list to create objects that can be passed on to tmaps. Although the naijR package is not strictly designed for geospatial analyses, one can look into providing richer objects in future.

@BroVic
Copy link
Collaborator

BroVic commented Mar 6, 2023

@josoga2 check out this code for a simple way to use this package with {tmap}.

I am yet to decide whether to bake this functionality into the package or not.

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

2 participants