[R-sig-Geo] CSV with Geometry Column to SF object

argunaw . @rgun@w @end|ng |rom gm@||@com
Tue Oct 15 20:31:08 CEST 2019


  When I run this, I get the following error:

*Error in CPL_sfc_from_wkt(x) : OGR error*

When I run it on my data, I get the same error.

On Tue, Oct 15, 2019 at 2:16 PM Edzer Pebesma <edzer.pebesma using uni-muenster.de>
wrote:

> You may try something along these lines:
>
> # read data.frame with read.csv; here, we create an example by hand:
> df = data.frame(
>                 a = 1:3, b = 3:1, geom = c("LINESTRING(0 0, 1 1)",
> "LINESTRING(1 1,2
> 2)", "LINESTRING(5 5,6 6)")
> )
>
> library(sf)
> sf = st_sf(df, geom = st_as_sfc(df$geom))
> sf
>
>
> On 10/15/19 1:58 PM, argunaw . wrote:
> > I'm not sure how it was exported from postgis- the person who gave me the
> > file wasn't the one who downloaded it unfortunately.
> >
> > The file is a line file of roads. The files main columns are road ID
> > numbers (type integer) and the geometry column (type geometry, long
> strong
> > of letters and numbers). Only the IT admins where I am have the postgis
> > load/import tools in the pgadmin/sql interface. The rest of us can
> download
> > from sql and create new tables from other sql databases, but not create a
> > new table from a csv file.
> >
> > On Tue, Oct 15, 2019 at 1:11 PM Alex Mandel <tech_dev using wildintellect.com>
> > wrote:
> >
> >> On 10/15/19 8:43 AM, argunaw . wrote:
> >>> Hello Everyone,
> >>>
> >>> I have a csv file with a postgis "geometry" column. I've been trying to
> >>> import it in to R as a SF file, with the goal of exporting it to a
> >> postgis
> >>> database, but to no avail. I've used the following methods:
> >>>
> >>> 1. file <- st_read("name.csv", stringsAsFactors=F,
> geometry_column=geom)
> >>>
> >>> 2. file <- fread("name.csv", headers=True)
> >>>     file <- st_as_sf(file)
> >>>
> >>> How can I import a csv with a postgis "geometry" column in to R as a
> >>> spatial/SF object?
> >>>
> >>>       [[alternative HTML version deleted]]
> >>>
> >>> _______________________________________________
> >>> R-sig-Geo mailing list
> >>> R-sig-Geo using r-project.org
> >>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>>
> >>
> >> Can you paste an example somewhere, is it binary data or some kind of
> >> plain text column? Do you know how it was exported from Postgis?
> >>
> >> If it's a dump from a postgis database did you try loading the table
> >> directly to postgis with it's own load/import, or sql tools?
> >>
> >> Thanks,
> >> Alex
> >>
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo using r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> --
> Edzer Pebesma
> Institute for Geoinformatics
> Heisenbergstrasse 2, 48151 Muenster, Germany
> Phone: +49 251 8333081
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list