[R] Opening shapefiles in R

Micha Silver t@v|b@r @end|ng |rom gm@||@com
Sat Oct 22 11:28:41 CEST 2022


Hello Nick:


First: as Jeff pointed out, you'll probably have better luck posting to 
the r-sig-geo list.


On 21/10/2022 14:25, Nick Wray wrote:
> Hello
>
> I have managed to download and plot the outline for the River Tweed In the
> Sottish borders)  catchment using this code.  21009 is a zipfile downloaded
> from the FEH website https://fehweb.ceh.ac.uk/Map:
>
> require(rgdal)
>
> shape <- readOGR(dsn ="C:/Users/nick/Desktop/PhD Oct 22", layer = "21009")


Second: The R-spatial "ecosystem" has undergone some major changes 
recent years. You'd be well advised, I think, to switch to using the 
`sf` package for vector data. So reading in a shapefile would be 
`sf::st_read(dsn="...")`



Third: Regarding your other post about string representations of 
geometries. Can you be more specific as to what your final goal is? The 
"canonical" string representation of geometries is Well Known Text (WKT) 
and can be returned with the `sf::st_as_text()` function. Does that help?


Kind regards,

Micha


> shape
>
> plot(shape)
>
> and I get an outline of the Tweed catchment which I can use
>
> the zipfile has eight documents all with the name “21009.” and the suffixes
> cpg/dbf/prj/sbn/sbx/shp/shp/shx   There are two .shp docs, one labelled as
> SHP file and one as XML file.
>
> However
>
> I then have downloaded a file of a plot of all the rivers in the uk from
> https://osdatahub.os.uk/downloads/open
>
> I’ve put this data into a zipfile with the name “rivers”   Within this are
> eight docs – four with the names HydroNode. and suffixes dbf/prj/shp/shx
> and four with the name WatercourseLink. and the four suffixes.
>
> Just subbing in “rivers” for “21009” in my code above doesn’t work and I
> can’t find a way of getting into the shapefiles and opening them
>
>
> I'd be grateful if anyone can help me get further with this
>
> Thanks Nick Wray
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918



More information about the R-help mailing list