statnmap / HatchedPolygons

Create a hatched area for SpatialPolygons in R
https://statnmap.github.io/HatchedPolygons/
GNU General Public License v3.0
10 stars 5 forks source link

possible with sf objects? #2

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi,

I love your hatched polygons library, but I was wondering if there is a way to use it on sf rather than sp objects? I tried it with an sf data frame and it gave me an error "object 'pO' not found", even though I have no idea what pO is or what it's referring to. It works great on sp data frames, but I was just wondering if you were thinking about adding sf compatibility too.

Thanks! James Cutler

statnmap commented 3 years ago

Thanks.
I never took time to add this compatibility as pure {sf}. The only way for now is to transform {sf} to {sp} using as(my_sf_obj, "Spatial")
And then the way back using st_as_sf(my_hatched_obj) as at the end of the blog post: https://statnmap.com/2017-05-23-how-to-fill-a-hatched-area-polygon-with-holes-in-leaflet-with-r/
Maybe one day...

ghost commented 3 years ago

That's good to know. Thank you for getting back so quick! I love the hatched polygons library, so thank you for sharing this amazing work!

Thanks, James

On Mon, Nov 30, 2020 at 3:47 PM Sébastien Rochette notifications@github.com wrote:

Thanks. I never took time to add this compatibility as pure {sf}. The only way for now is to transform {sf} to {sp} using as(my_sf_obj, "Spatial") And then the way back using st_as_sf(my_hatched_obj) as at the end of the blog post: https://statnmap.com/2017-05-23-how-to-fill-a-hatched-area-polygon-with-holes-in-leaflet-with-r/ Maybe one day...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/statnmap/HatchedPolygons/issues/2#issuecomment-736076169, or unsubscribe https://github.com/notifications/unsubscribe-auth/AINUXL4JSM4WRQD4FQ5WZMTSSQHI7ANCNFSM4UIARKXA .

statnmap commented 3 years ago

If this package inspires you to propose a pull request for a native compatibility with {sf}, I'll be happy to review it.

ghost commented 3 years ago

Well, when the day comes that I can call myself an R ninja capable of something like that, then I will definitely think about it! Unfortunately a project like that seems way over my head at the moment. But I hope to get there one day! Any advice on how to take my coding skills to the next level where I could do something like that? I've been using R for about 3 years, and consider myself very familiar with it, but I honestly have no idea how to do something like what you've done with the hatched polygons package.

Thanks! James

On Wed, Dec 2, 2020 at 2:10 PM Sébastien Rochette notifications@github.com wrote:

If this package inspires you to propose a pull request for a native compatibility with {sf}, I'll be happy to review it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/statnmap/HatchedPolygons/issues/2#issuecomment-737467598, or unsubscribe https://github.com/notifications/unsubscribe-auth/AINUXLZNMDFGHMJOSUQU2ETSS2NMNANCNFSM4UIARKXA .

statnmap commented 3 years ago

If you can write a code that works, then you can add it in a package. Then, this is a question of method. Here is my method : https://rtask.thinkr.fr/when-development-starts-with-documentation/

ghost commented 3 years ago

Wow! That's cool! This really makes writing my own package look easy! Thanks!

On Sat, Dec 5, 2020 at 11:47 AM Sébastien Rochette notifications@github.com wrote:

If you can write a code that works, then you can add it in a package. Then, this is a question of method. Here is my method : https://rtask.thinkr.fr/when-development-starts-with-documentation/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/statnmap/HatchedPolygons/issues/2#issuecomment-739326640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AINUXLZKVNKXBRG6TERYKK3STJW4JANCNFSM4UIARKXA .

statnmap commented 3 years ago

I partially updated the package to allow for hatched area directly with {sf}. Although this is a workaround that transforms as {sp}, then back to {sf}. But for now it does the job. More examples here in the vignette : https://statnmap.github.io/HatchedPolygons/articles/leaflet_shading_polygon.html

ghost commented 3 years ago

Awesome, thanks! I'll take a look at that soon for sure! I love this hatched polygons package, thanks again for the good work!

On Sun, Jan 10, 2021 at 1:59 PM Sébastien Rochette notifications@github.com wrote:

I partially updated the package to allow for hatched area directly with {sf}. Although this is a workaround that transforms as {sp}, then back to {sf}. But for now it does the job. More examples here in the vignette : https://statnmap.github.io/HatchedPolygons/articles/leaflet_shading_polygon.html

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/statnmap/HatchedPolygons/issues/2#issuecomment-757534497, or unsubscribe https://github.com/notifications/unsubscribe-auth/AINUXLYN2MI4SJ4HROGKYDTSZIBJVANCNFSM4UIARKXA .