[R-sig-Geo] Linear referencing in R

Rubem Dornas r@pdorn@@ @ending from gm@il@com
Mon Oct 1 16:25:51 CEST 2018


Thank you very much, Kent! This is pretty much what I was looking for. The
only problem is that the new shapefile didn't come with the attributes from
the topoESQ data frame. I made some adjustments, that probably are not the
best ones, but I still made it work.

topoESQ_comp <- read.csv("Files/Topo_estacas_E.csv") %>%
  select(-1) %>%
  rename(height = Altura,
         side = Lado) %>%
  filter(to_km <= 871)

Estacas_1m <- st_read("Files/ESTACAS_1m_EFC_0-871_Policonic_SIRGAS.shp")

topoESQ_comp %>%
  purrr::pmap(function(from_km, to_km, ...) {
    st_linestring(do.call(rbind,
Estacas_1m$geometry[((1000*from_km):(1000*to_km))+1]))
  }) %>%
  st_sfc(., crs = 5880) %>%
  cbind(topoESQ_comp, .) %>%
  st_as_sf(.) %>%
  st_write(., dsn = "Files/Topo_esq.shp", delete_dsn = T)

Best regards,

Rubem Dornas.


Em sáb, 29 de set de 2018 às 22:17, Kent Johnson <kent3737 using gmail.com>
escreveu:

> You need to snip out the sections of the railroad file rather than
> connecting the endpoints. Maybe this is closer to what you want?
>
> segments = topoESQ_comp %>%
>   filter(to_km <= 871) %>%
>   purrr::pmap(function(from_km, to_km, ...) {
>     st_linestring(do.call(rbind,
> Estacas_1m$geometry[((1000*from_km):(1000*to_km))+1]))
> }) %>%
>   st_sfc
>
> Kent Johnson
>
>
>> Date: Fri, 28 Sep 2018 19:52:03 -0300
>> From: Rubem Dornas <rapdornas using gmail.com>
>> To: r-sig-geo using r-project.org
>> Subject: [R-sig-Geo] Linear referencing in R
>> Hi, people! I hope I'll be not to speculative in my question and that you
>> can comprehend my problem.
>>
>> Well, I have a railroad shapefile and I have two csv files corresponding
>> to
>> the topography in each side of the railroad. The csv are organized in this
>> way:
>>
>> ID_topo, from_km, to_km, height
>> 1, 0, 1.91, 15
>> 2, 1.91, 2.23, -3
>>
>> I created a point shapefile for each meter of the railroad and then I
>> proceeded with a join (not spatial) between the from_km of the topography
>> data frame and the km mark (km_calc) from the point railroad.
>>
>> My goal is to create shapefiles for each of the railroadside topography.
>> The issue is that when I try to make a new line shapefile from topography
>> based on the points of the railroad, what I get is a line that has doesn't
>> follow the curvature of the railroad. Using the example of the csv above,
>> what I get are several straight lines linked by the from_km to to_km.
>> (Here
>> is a link to a print screen from QGIS:
>>
>> https://www.dropbox.com/s/erfsst8pasoqj64/Captura%20de%20tela%202018-09-28%2019.49.47.png?dl=0
>> <http://Image>)
>>
>>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list