[go: up one dir, main page]

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

Spatial analysis issues #20

Open
aspina7 opened this issue Jan 10, 2019 · 19 comments
Open

Spatial analysis issues #20

aspina7 opened this issue Jan 10, 2019 · 19 comments

Comments

@aspina7
Copy link
Member
aspina7 commented Jan 10, 2019

I have added a basic section to spatial analysis using the "tmap" package (with "tmaptools" too).
I chose this because it allows both sf and sp files and has similar syntax to ggplot2 but simpler for manipulating spatial data.
The reason I decided against ggmap - is that it really didnt work well in the field on poor internet connection (would often just get kicked out and it wouldnt download at all) - and the style options arent great either.
In general tmap is quite a nice package, allowing for static and interactive maps.
That comes with issues though as it has a lot of dependencies!

The biggest issue is that to get static tiles it uses the "openstreetmap" package which is rjava dependent and produces quite poor resolution rasters.
For interactive maps it uses leaflet package. Which has great tile backgrounds but only interactive ones. Leaflet also has more server options, and particularly important is that it supports openstreetmap black&white as well as humanitarian openstreetmap (no other packages seem to provide these and they are the most important ones!!).

It would be really awesome if we could somehow manage to pull leaflet backgrounds in to static tiles. Alternatively "openstreetmap" package allows to specify server destinations to pull tiles from - so maybe theres a possible work around in there?? (just need to find a stable server with an api?)

The second thing I couldnt seem to get to work is creating kernel density (or heatmaps) - using the smooth_map function from the "tmaptools" package - based on points data.

If we manage a work around for getting tiles in (and dont want all the dependencies of tmap) then using the sf package with ggplot2 is equally simple and functional!

@aspina7
Copy link
Member Author
aspina7 commented Jan 10, 2019

note to self: spatial random sample workaround fails occasionaly, - change to sp version?

@aspina7 aspina7 mentioned this issue Jan 10, 2019
4 tasks
@dirkschumacher
Copy link
Member

I think we should have two options:

  • One option that quickly pulls in a base map from some server (Bonus points: if that can also be downloaded beforehand: e.g. download in HQ and render maps in the field)
  • Another option that shows how to do a map from a shap file / geojson (ideally as it would come from an MSF GIS person)

@aspina7
Copy link
Member Author
aspina7 commented Jan 11, 2019

so in the current template there is the option to download in advance and save/send as a .rda, from hq to field for example.
Shapefile also in there, but not geojson (though i wouldve thought geojson more rare...)

@dirkschumacher
Copy link
Member

Ok nice. Yeah whatever is more common. Maybe it is just my bubble where nobody uses shapefiles ;)

@aspina7
Copy link
Member Author
aspina7 commented Jan 11, 2019

@aspina7
Copy link
Member Author
aspina7 commented Jan 18, 2019

chris - see zhian's point about rjava and dependencies - we definitely need a better solution for basemaps.
Thinking more and more that a simple wrapper with osmdata to pull land water and roads may just do enough (with option for pulling buildings in smaller areas.

@zkamvar
Copy link
Member
zkamvar commented Jan 23, 2019

The rosm package may be a solution, but don't count on it being updated anymore, only maintained: https://github.com/paleolimbot/rosm#readme

@zkamvar
Copy link
Member
zkamvar commented Jan 23, 2019

Just realized that ggspatial imports functions from rosm.

I think it may be possible to pre-download tiles for a given region with their API, and store it in a folder, then use file:/// construct to pass the folder's path as a URL to ggspatial/rosm

@aspina7
Copy link
Member Author
aspina7 commented Jan 23, 2019

yep, rosm only available for baseplot though. ggspatial same functionality but makes available for ggplot.
Its possible to predownload and save as a .rda - the other additional benefit of ggspatial is that it makes tiles from humanitarian osm as well as black/white osm.
So the solution is to use ggspatial for tiles and SF for shapefiles etc.... all of these can be passed to ggplot.

@zkamvar
Copy link
Member
zkamvar commented Jan 23, 2019

After I polish the template a bit, I'll work on trying to get a reasonable workflow for getting the tiles.

@aspina7
Copy link
Member Author
aspina7 commented Jan 23, 2019

pretty sure chris is on it

@zkamvar
Copy link
Member
zkamvar commented Jan 23, 2019

Then I will hold off

@jarvisc1
Copy link
Contributor

Have been looking at this today. As far as I can tell ggspatial only downloads the tiles when you add a spatial geom after annotation_map_tile, it doesn't appear to allow you to just specify that you want to download the tiles.

If you add a cache directory then it will create the folder and store the tiles there. These tiles can be used offline. It's works but the tiles don't look great with the ggplot maps. I'll see if can improve them but speaking to Alex perhaps we can look at the internals of annotation_map_tile and change it so we can just download the tiles we want without having to create a map each time.

@aspina7
Copy link
Member Author
aspina7 commented Jul 21, 2019

There might be an easier work around in here than in our current setup.... Will look in to eventually
https://github.com/hypertidy/ceramic/blob/master/README.md

@kdoyle514
Copy link
Contributor

I associate tiles with raster files -- will downloading tiles allow for admin-2 or admin-3 level divisions? or is this just to provide a base map? Ceramic uses NE to define the tile extent, but then we'd also need to load NE.

Also, a word of caution that health districts in many countries are different from admin levels...in both Chad and DRC, this was the case.

@aspina7
Copy link
Member Author
aspina7 commented Aug 7, 2019 via email

@zkamvar
Copy link
Member
zkamvar commented Aug 7, 2019

I believe the last commit where the outbreak report existed was here:
322623e

@aspina7
Copy link
Member Author
aspina7 commented Apr 4, 2020

Note to self: see latest carto release and slippymap package to improve image res https://t.co/6OvNpqLoSC?amp=1

alternatively use {maptiles} (which uses {terra}) and then plot with tidyterra::geom_spatraster_rgb - or potentially with terrainr::geom_spatial_rgb

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

5 participants