Hi
I am trying to check if my points are within polygons. And I struggle with wkt converting despite reading many post around it.
I have points list (flare) which I manage to convert to spatial and assign projection.
flare.points<-read_excel("flare.xlsx")
poly<-read_excel("poly.xlsx")
coordinates(flare.points)<-c("Longitude","Latitude")
as(flare.points, "SpatialPoints")
proj4string(flare.points)<- CRS("+proj=longlat +datum=WGS84")
now i have a problem with poly data which contains wkt polygons. I followed also this blog post here: read_csv saves geometry point data as character and wrote a code as follow:
poly.df<- as.data.frame(poly)
clean.poly <- poly.df %>%
st_as_sf(wkt = "wkt",
crs = 4326)
This ends up with error:OGR: Corrupt data
Error in CPL_sfc_from_wkt(x) : OGR error
Random rows of my data frame are converted if i try for example st_as_sfc(poly.df[33088,3]) I get the geometry set
Geometry set for 1 feature
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: 13.43856 ymin: 43.39011 xmax: 13.45856 ymax: 43.41011
CRS: NA
POLYGON ((13.45856 43.39011, 13.45856 43.41011,...
I am new to R and I have no idea how to check maybe which wkt in my file are then invalid? or how this OGR error can be corrected? skip?
Many thanks
Dorota