-
Notifications
You must be signed in to change notification settings - Fork 8
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
WFS problems with geometry column and text conversion #17
Comments
Thanks, I will have a look. I already use "sf" as main binding for simple features. The problem is not really about the binding but the fact that WFS allows to return geometryless data. I will look to a better (more generic) way to handle this. Some of the recent GML improvements in geometa might help. I will let you know. 2d point seems to be related to a missing data type. I'm also aware of some issues when dealing with national sources, there might be issues with parsing properly national CRS not parsable from their EPSG code. The source you point out will be a good test case. |
Wow great to see upstream contributions on this. Many thanks for quick-fire response @eblondel ! |
@jannes-m i'm going to have a look to it asap, i'm going to split your report into 2 separate tickets, to better track bugs/enhancements. btw, looking at the code you run above, if you want to list the layers, there is a method "getFeatureTypes" that you can use:
|
Ok it should be ok now the both sources you've shared. In case you get other issues, you can raise another ticket. You should not need to read through sf directly, ows4R is doing it for you but also checks your data against its schema, handled by the FeatureType description). So the natural binding for this WFS client is "sf" (being an implementation of OGC standard), and you can then run |
Excellent, fantastic work!! Only this warning message might cause confusion when getting the Bavarian National Parcs: Warning messages:
1: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet, :
GDAL Error 1: HTTP error code : 404
2: st_crs<- : replacing crs does not reproject data; use st_transform for that I would probably suppress it since you are only using the |
@jannes-m yes i've seen this warning, I will try to find sometimes to better understand why we get this, and suppress it if it's ok. |
let me have a quick look at the source code but I guess you are using |
in your code I found: Lines 247 to 249 in c1557c2
The warning message is issued since |
I've checked and the warning is not raised by this piece of code, I will investigate further and let you know. overwriting the CRS has no effect because it will be the same (normally) as the default CRS specified as per the service capabilities featuretype metadata. |
Are you sure? Have a look at this reproducible example: library(ows4R)
#> Loading required package: geometa
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
library(sf)
#> Linking to GEOS 3.7.0, GDAL 2.3.2, PROJ 5.2.0
base_url = "http://www.lfu.bayern.de/gdi/wfs/naturschutz/schutzgebiete?"
wfs = WFSClient$new(base_url, "1.0.0", logger = "INFO")
#> [ows4R][INFO] OWSGetCapabilities - Fetching http://www.lfu.bayern.de/gdi/wfs/naturschutz/schutzgebiete?service=WFS&version=1.0.0&request=GetCapabilities
caps = wfs$getCapabilities()
tmp = caps$findFeatureTypeByName("")
# find out about the available feature types
# sapply(tmp, function(x) x$getName())
ft = caps$findFeatureTypeByName("lfu:nationalpark")
feats = ft$getFeatures()
#> [ows4R][INFO] WFSGetFeature - Fetching http://www.lfu.bayern.de/gdi/wfs/naturschutz/schutzgebiete?service=WFS&version=1.0.0&typeName=lfu:nationalpark&logger=INFO&request=GetFeature
#> [ows4R][INFO] WFSDescribeFeatureType - Fetching http://www.lfu.bayern.de/gdi/wfs/naturschutz/schutzgebiete?service=WFS&version=1.0.0&typeName=lfu:nationalpark&request=DescribeFeatureType
#> Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, :
#> GDAL Error 1: HTTP error code : 404
#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform
#> for that
# now reading the features manually (using more or less your code)
destfile = grep(".gml", dir(tempdir()), value = TRUE)
destfile = file.path(tempdir(), destfile)
ftFeatures = sf::st_read(destfile, quiet = TRUE)
st_crs(ftFeatures) = ft$getDefaultCRS()
#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform
#> for that
# geographic vs. projected CRS
ft_wgs84 = st_transform(ftFeatures, 4326)
# now assigning the same CRS again, does not lead to a warning message
st_crs(ft_wgs84) = 4326 Created on 2018-10-22 by the reprex package (v0.2.1) Could be that sf does not complain if you are "overwriting" a geographic CRS with the same geographic CRS but does complain if you do so with a projected CRS but this is just educated guessing (see also last three lines of the reproducible example) but @edzer will surely know! |
I don't get the second warning you get: only the one dealing with GDAL. For safety, i've added a simple control on crs ab5e1f2, in case, and overwrite it only if no crs is found. Can you please reinstall, test and let me know, normally you should not get the 2d warning, but the 1st warning will probably remain... |
|
Thanks for this, I will have a look as soon as i get some time (probably
tonight). Cheers
Le 22/10/2018 à 13:45, Jannes Muenchow a écrit :
in your code I found:
https://github.com/eblondel/ows4R/blob/c1557c27c7129c624cfa64f74c99ecb8acd09071/R/WFSFeatureType.R#L247-L249
The warning message is issued since |read_sf()| has already found a
CRS in the Bavarian National Parc case. I don't know if this is
usually the case with |.gml| files but I would guess so, hence you
could just delete the |st_crs()| line. Just to be on the safe side you
could also ask if the sf-object already has a CRS, and only if this is
not the case, you assign the CRS. What do you think @Robinlovelace
<https://github.com/Robinlovelace> @Nowosad <https://github.com/Nowosad>?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQ1bPCBTn4S2sx2fnK1iZgGbKG2LZZOks5una_TgaJpZM4XvvnO>.
--
|
Hi,
any solution of that? |
Hi @oggioniale I've fixed the issue through #37 |
thanks! It work now. |
Hi Emmanuel,
first, thank you again for developing OGC web services for R! I have played around a bit with your package, and stumbled across two potential bugs.
geometry
column (or tag), however, sometimes the column (tag) containing the geometry is unfortunately not named geometry, as is the case with this Dutch example where it is called "geometrie". The solution might be to use sf to read the downloaded GML file into R (see below, and FYI @Robinlovelace and @Nowosad):Created on 2018-10-19 by the reprex package (v0.2.1)
switch()
:Created on 2018-10-19 by the reprex package (v0.2.1)
The text was updated successfully, but these errors were encountered: