[R] Opening shapefiles in R
Nick Wray
n|ckmwr@y @end|ng |rom gm@||@com
Sat Oct 22 12:52:32 CEST 2022
Hi Micha Thanks for your ideas which I will look into I hadn't heard of
r-sig-geo before but I've signed up to it. I'm a bit of beginner as far as
geospatial in R goes. What I am ultimately trying to do is this - my PhD
research is into the relative proportions of the effects of climate change
and land use on streamflow in Scottish rivers (I'm based at Edinburgh) and
to this end I need to create a map of catchments eg the Tweed onto which I
can placing flow gauging stations/ weather stations etc . I have catchment
outline shapefiles and the stations but finding the bit of the whole of the
UK river system shapefile which is the Tweed catchment is tricky, as the
shapefile matrix doesn't have names in it and I am trying to identify the
Tweed and its tributaries from the coordinates of its mouth sources and so
on... that's why i need to pull out the coordinates. Any suggestions 'd
be v welcome Nick
On Sat, 22 Oct 2022 at 10:28, Micha Silver <tsvibar using gmail.com> wrote:
> 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
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list