CSV with Geometry Column to SF object
Without sharing a (minimal) reproducible example, it is unlikely that someone else can help you find out whether this points to a problem in your data, or in the software.
On 10/15/19 2:31 PM, argunaw . wrote:
? 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 at uni-muenster.de <mailto:edzer.pebesma at 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 at wildintellect.com <mailto:tech_dev at 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 at r-project.org <mailto:R-sig-Geo at 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 at r-project.org <mailto:R-sig-Geo at 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 at r-project.org <mailto:R-sig-Geo at 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 -------------- next part -------------- A non-text attachment was scrubbed... Name: pEpkey.asc Type: application/pgp-keys Size: 3110 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20191015/d3834479/attachment.bin>