[R-sig-Geo] rgdal retirement

Michael Sumner md@umner @end|ng |rom gm@||@com
Tue Sep 21 13:14:48 CEST 2021


On Tue, Sep 21, 2021 at 8:04 PM Roger Bivand <Roger.Bivand using nhh.no> wrote:

> On Sun, 19 Sep 2021, Michael Sumner wrote:
>
> > Hi Jean-Luc, if the packages mentioned don't yet cover it, you can get
> > ogrInfo and ogrFIDs with a combination of vapour's vapour_read_names()
> > (for FID), vapour_geom_summary()  (for FID and type) and
> > vapour_layer_info().
>
> In sf you can use the fid_column_name= argument to st_read() to retreive
> the FIDs with the geometries, but I think not the FIDs alone. orgInfo grew
> over time and became unwieldy, are there specific components that you use?
> Might sf::st_read() be modified to report these (and return FIDs) without
> reading the data and geometries? Using vapour is of course a good way to
> proceed, and very useful for cross-checking (Do rgdal and vapour return
> the same values, I hope so, vapour is much cleaner).
>
>
They do where I've checked!  I've put some notes here running the code
below: https://gist.github.com/mdsumner/6e756ded5f73c19bfb5935b12e4cec16


file <- "list_locality_postcode_meander_valley.tab"

## MapInfo file is 1-based FID
mvfile <- system.file(file.path("extdata/tab", file), package="vapour")
range(vapour::vapour_read_names(mvfile))
range(rgdal::ogrFIDs(mvfile, "list_locality_postcode_meander_valley"))

## shapefile is 0-based FID
pfile <- system.file("extdata/point.shp", package="vapour")
range(vapour::vapour_read_names(pfile))
range(rgdal::ogrFIDs(pfile, "point"))

## geopackage is 1-based
gfile <- system.file("gpkg/nc.gpkg", package = "sf")
range(vapour::vapour_read_names(gfile))
range(rgdal::ogrFIDs(gfile, "nc.gpkg"))  ## quirky layer name, it's not
always predictable

## real DB used not to have FIDS accessible by SQL (so I thought ... but
now it seems to work
vapour::vapour_read_attributes(mvfile, sql = "SELECT FID FROM
list_locality_postcode_meander_valley")
sf::read_sf(mvfile, query = "SELECT FID FROM
list_locality_postcode_meander_valley")

## some formats are arbitrary FIDS (not sequential by-1 or starting from
0/1)
osmfile <- system.file("extdata/osm/osm-ways.osm", package = "vapour")
vapour::vapour_read_names(osmfile)
rgdal::ogrFIDs(osmfile, "points")

My major concern with the vapour version is it won't handle 64-bit FIDs, I
tried and failed to get that to work but I've also never needed it, I don't
use databases much. I'm not sure if there's a broader variety of FIDS/names
to be concerned with.



> >
> > For make_EPSG() it's probably time to hit the proj.db more directly and
> I'd
> > be happy to have a look at that.
>
> Right, RSQLite can handle this quite well, but sometimes the names of
> tables and fields in tables change.
>
>

Indeed, note that you can read it with gdal itself i.e.

## on my linux (I don't know how to generalize this proj.db find step)
f <- "/usr/share/proj/proj.db"
## or CRAN built windows/macos
#f <- system.file("proj/proj.db", package = "sf", mustWork  = TRUE)

## table of authority codes, but I don't generally know my way around this
projected_crs  <- sf::read_sf(f, "projected_crs")

Cheers, Mike

Roger
>
> >
> > Cheers, Mike
> >
> > On Sun, Sep 19, 2021 at 9:35 AM Jean-Luc Dupouey <
> jean-luc.dupouey using inrae.fr>
> > wrote:
> >
> >> Dear Roger Bivand,
> >>
> >> I read your message about the rgdal retirement. It was a nice package
> >> and an important step in the development of R-spatial.
> >>
> >> I looked for alternatives for the functions I was using, but I didn't
> >> find them all. Those I am missing:
> >>
> >> . ogrInfo
> >> . ogrFIDs
> >> . make_EPSG
> >>
> >> Do you know of any (more or less) equivalent functions in the packages
> >> you mentioned that have taken over from rgdal?
> >>
> >> Thanks in advance,
> >>
> >> Jean-Luc Dupouey
> >>
> >> --
> >> INRAE
> >> UMR Silva
> >> F-54280 Champenoux
> >> France
> >>
> >> _______________________________________________
> >> R-sig-Geo mailing list
> >> R-sig-Geo using r-project.org
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>
> >
> >
> >
>
> --
> Roger Bivand
> Emeritus Professor
> Department of Economics, Norwegian School of Economics,
> Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
> e-mail: Roger.Bivand using nhh.no
> https://orcid.org/0000-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
>


-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsumner using gmail.com

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list