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

Convert XY Dimension #1245

Closed
sjvermeulen opened this issue Jan 21, 2020 · 5 comments
Closed

Convert XY Dimension #1245

sjvermeulen opened this issue Jan 21, 2020 · 5 comments

Comments

@sjvermeulen
Copy link

sjvermeulen commented Jan 21, 2020

Hi all,

I am trying to revetrive dataset of the municipal borders of belgium.

url <- "http://ccff02.minfin.fgov.be/geoservices/arcgis/services/INSPIRE/AU_wfs/MapServer/WFSServer?request=getcapabilities&service=wfs&version=1.1.0"

#get the unit data
unit <- st_read(url, layer = "au:AdministrativeUnit") 
unit$SHAPE <- st_transform(unit$SHAPE, 4326)

At first instance, it looks okay, however if I do a quick plot, I noticed that it is currently residing next to Somalia. I check other data that I have of Belgium and it seems like the XY of the boundary box should be the other way around.

My data

geometry type: POLYGON
dimension: XY
bbox: xmin: 2.607302 ymin: 51.10844 xmax: 2.611473 ymax: 51.11213
epsg (SRID): 4326
proj4string: +proj=longlat +datum=WGS84 +no_defs

Data of url

geometry type: MULTISURFACE
dimension: XY
bbox: xmin: 49.49696 ymin: 2.541327 xmax: 51.50511 ymax: 6.408098
epsg (SRID): 4326
proj4string: +proj=longlat +datum=WGS84 +no_defs

Can I add something in my st_read request to change XY?

Thanks so much in advance.

@edzer
Copy link
Member

edzer commented Jan 21, 2020

You may want to look into #1033.

@sjvermeulen
Copy link
Author

Thanks for quick reply, I tried your method using #1033

However I does not seem to work. Could it by the case that the data is multisurface and that I should first covert in into polygon? Or should it technically work on both cases?

@edzer
Copy link
Member

edzer commented Jan 21, 2020

I can't read your data:

> unit <- st_read(url, layer = "au:AdministrativeUnit") 
Cannot open layer au:AdministrativeUnit
Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  : 
  Opening layer failed.
In addition: There were 50 or more warnings (use warnings() to see the first 50)
> unit$SHAPE <- st_transform(unit$SHAPE, 4326)
Error in st_transform(unit$SHAPE, 4326) : object 'unit' not found
> warnings()
Warning messages:
1: In CPL_read_ogr(dsn, layer, query, as.character(options),  ... :
  GDAL Error 1: JSON parsing error: unexpected character (at offset 0)
2: In CPL_read_ogr(dsn, layer, query, as.character(options),  ... :
  GDAL Error 1: JSON parsing error: unexpected character (at offset 0)

For #1033 I guess you'll need to link sf against modern GDAL and PROJ versions. What does

> sf_extSoftVersion()
          GEOS           GDAL         proj.4 GDAL_with_GEOS     USE_PROJ_H 
       "3.8.0"        "3.0.2"        "6.2.1"         "true"         "true" 

give, in your case?

@sjvermeulen
Copy link
Author

Yes, that is the problem! I have an old versions of GDAL and PROJ on my laptop.

sf_extSoftVersion()
          GEOS           GDAL         proj.4 GDAL_with_GEOS     USE_PROJ_H 
       "3.6.1"        "2.2.3"        "4.9.3"         "true"        "false" 

Is there an easy way to update this?

@edzer
Copy link
Member

edzer commented Feb 5, 2020

You'll have to install from source, on a platform with updated GDAL and PROJ libraries.

@edzer edzer closed this as completed Feb 5, 2020
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