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

sfheaders #13

Open
dcooley opened this issue Nov 4, 2019 · 1 comment
Open

sfheaders #13

dcooley opened this issue Nov 4, 2019 · 1 comment

Comments

@dcooley
Copy link

dcooley commented Nov 4, 2019

This isn't an issue, but I found this repo after your issue on jsonify and thought another of my libraries may be of use - sfheaders

like rapidjsonr and jsonify you can link to it and call the Rcpp code directly. Of interest may be the sfc_point() (plus a few overloaded functions), which will create the sfc object, without you needing to require sf.

Hope that helps.

@knapply
Copy link
Owner

knapply commented Nov 16, 2019

Thanks @dcooley . I saw that on Twitter or elsewhere at some point, but couldn't remember the name when I was looking for it.

It's unclear how useful the spatial piece will be. All I do right now is take take the JSON bounding box...

[
  [
    -63.784544,
    -35.689402
  ],
  [
    -63.784544,
    -35.641737
  ],
  [
    -63.724717,
    -35.641737
  ],
  [
    -63.724717,
    -35.689402
  ]
]

... and flatten it into a vector.

[1] -63.78454 -35.68940 -63.78454 -35.64174 -63.72472 -35.64174 -63.72472 -35.68940

The only difference between what I do and what {rtweet} does is that I leave empty coordinates as empty vectors instead of having 8 NA_real_s hanging out in most rows.

I haven't pushed the latest work, but the only sf "functionality" I'm using in C++ is the prep_bbox_() function that turns non-empty vectors into matrices (and close the polygon), then slap the appropriate classes on it.

[[1]]
          [,1]      [,2]
[1,] -63.78454 -35.68940
[2,] -63.78454 -35.64174
[3,] -63.72472 -35.64174
[4,] -63.72472 -35.68940
[5,] -63.78454 -35.68940

attr(,"class")
[1] "XY"      "POLYGON" "sfg"    

All of that said, I'm trying to lock in some more critical things at the moment. My C++ is improving, but it's an uphill battle.

I'll eventually re-investigate what can be done spatial-wise and probably bring {sfheaders} in. Thanks again for pointing me to it.

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

2 participants