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

Remove ows4R from book #825

Closed
Robinlovelace opened this issue Jul 2, 2022 · 5 comments
Closed

Remove ows4R from book #825

Robinlovelace opened this issue Jul 2, 2022 · 5 comments

Comments

@Robinlovelace
Copy link
Collaborator

For now. For context see #817.

Content below for future reference.

As of October 2018, only ows4R is on CRAN.
The package's basic functionality is demonstrated below, in commands that get all FAO_AREAS as we did in the previous code chunk:^[
To filter features on the server before downloading them, the argument cql_filter can be used. Adding cql_filter = URLencode("F_CODE= '27'") to the command, for example, would instruct the server to only return the feature with values in the F_CODE column equal to 27.
]

library(ows4R)
wfs = WFSClient$new("http://www.fao.org/figis/geoserver/wfs",
                      serviceVersion = "1.0.0", logger = "INFO")
fao_areas = wfs$getFeatures("area:FAO_AREAS")
# not shown as too verbose an example already
area_27 = wfs$getFeatures("area:FAO_AREAS",
                          cql_filter = URLencode("F_CODE= '27'"))

There is much more to learn about web services and much potential for development of R-OWS interfaces, an active area of development.
For further information on the topic, we recommend examples from European Centre for Medium-Range Weather Forecasts (ECMWF) services at github.com/OpenDataHack and reading-up on OCG Web Services at opengeospatial.org.

# checking out WFS using German datasets
library(ows4R)
library(sf)
base_url = "http://www.lfu.bayern.de/gdi/wfs/naturschutz/schutzgebiete?"
wfs = WFSClient$new(base_url, "1.0.0", logger = "INFO")
# wfs$getUrl()
# wfs$getClassName()

caps = wfs$getCapabilities()
caps
tmp = caps$findFeatureTypeByName("")
# find out about the available feature types
sapply(tmp, function(x) x$getName())
# ok, let's download the national parcs of Bavaria
ft = caps$findFeatureTypeByName("lfu:nationalpark")
ft$getDescription()  # some problem here, I guess due to German spelling (umlaut, etc.). BTW the same happens when using the data from the Netherlands
ft$getBoundingBox()  # no bounding box
ft$getDefaultCRS()  # default CRS
nps = ft$getFeatures()
# this does not work properly, however, it downloads the data to the temporary
# directory, hence, we can load them into R ourselves
file = grep("gml", dir(tempdir()), value = TRUE)
file = file.path(tempdir(), file)
# assuming there is only one file
layer = read_sf(file)
plot(layer$geometry)
library(ows4R)
library(sf)
# data gathered from https://catalog.data.gov/dataset?res_format=WFS
# downloading US national parks
base_url = paste0("http://gstore.unm.edu/apps/rgis/datasets/",
                  "7bbe8af5-029b-4adf-b06c-134f0dd57226/services/ogc/wfs?")
# downloading public US airports
base_url = paste0("http://gstore.unm.edu/apps/rgis/datasets/",
                 "7387537d-dff6-48d1-9004-4f089f48dea1/services/ogc/wfs?")
# establish the connection
wfs = WFSClient$new(base_url, "1.0.0", logger = "INFO")
# wfs$getUrl()
# wfs$getClassName()

caps = wfs$getCapabilities()
caps
# find out about the available feature types
tmp = caps$findFeatureTypeByName("")
tmp$getName()
# ok, let's download all US national parcs 
ft = caps$findFeatureTypeByName("nps_boundary")
# ft = caps$findFeatureTypeByName("tra2shp")  # airports
ft$getDescription()
ft$getBoundingBox()  
ft$getDefaultCRS()  
nps = ft$getFeatures()
# this returns an sf object
plot(nps$msGeometry)
Robinlovelace added a commit to geocompx/geocompkg that referenced this issue Jul 2, 2022
@eblondel
Copy link
Contributor

eblondel commented Jul 5, 2022

So just to understand you removed ows4R section because your bookdown complains about about rgdal and warning on the fact it will be dismissed next year?

@eblondel
Copy link
Contributor

eblondel commented Jul 5, 2022

I'm going to have a look at the rgdal use in ows4R, and if I can remove its suggested use by another stuff. I believe it would be worth extending ows4R section to other than features/vector. ows4R now supports other standards, including coverage data access through WCS, data processing through WPS, and partly data grabing through WMS.

@Robinlovelace
Copy link
Collaborator Author

Robinlovelace commented Jul 5, 2022

So just to understand you removed ows4R section because your bookdown complains about about rgdal and warning on the fact it will be dismissed next year?

Hi @eblondel thanks for getting back about this and apologies for the sudden decision. Broadly yes, I removed the code section:

https://github.com/Robinlovelace/geocompr/blob/8615eaf42e11a334a785ca1123d53ecb69675351/08-read-write-plot.Rmd#L294-L314

but not because of warnings, but because it seems the package could not be installed on the image on which the book was being build, causing not only the book build to fail but I think also the geocompkg CI also. I have had issues installing ows4R on my local computer also. I would be very happy to re-add the package after changes your side. Shall I open a new issue on the enhancements you mention?

@eblondel
Copy link
Contributor

eblondel commented Jul 5, 2022

Well that's the first time I get report of installation problems. For the image can you point to error logs that you get during ows4R installation, i will have a look. For the rgdal issue, i'm remove it from ows4R.

@eblondel
Copy link
Contributor

eblondel commented Jul 5, 2022

This said, the example above would need to be updated because of changes in the FAO geoserver you used. That one will not work anymore

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