Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating lines from points w/ grouping #321

Closed
jmlondon opened this issue Apr 28, 2017 · 9 comments
Closed

creating lines from points w/ grouping #321

jmlondon opened this issue Apr 28, 2017 · 9 comments

Comments

@jmlondon
Copy link

I am struggling to determine the optimal/best workflow for creating
multiple lines from sf point objects that have a group identifier.
This seems like it should be a pretty straightforward process -- and, it very well may be -- but I can't quite figure it out with the existing documentation, etc.

Let's first create an sf/data.frame from latlong point data

library(sf)
library(tidyverse)

pts_sf <- data.frame(
  x = seq(47, 48, by=0.1),
  y = seq(147, 148, by=0.1),
  attr_data = rnorm(11,42,42),
  id = c(rep("fred",6), rep("wilma",5))
) %>% 
  sf::st_as_sf(coords = c("x","y")) %>% 
  sf::st_set_crs(4326)

pts_sf
Simple feature collection with 11 features and 2 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 47 ymin: 147 xmax: 48 ymax: 148
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
   attr_data    id          geometry
1  -32.28072  fred     POINT(47 147)
2   45.37867  fred POINT(47.1 147.1)
3   56.77862  fred POINT(47.2 147.2)
4   48.94170  fred POINT(47.3 147.3)
5  -26.56757  fred POINT(47.4 147.4)
6  -25.84003  fred POINT(47.5 147.5)
7   23.10022 wilma POINT(47.6 147.6)
8   23.09363 wilma POINT(47.7 147.7)
9   85.06559 wilma POINT(47.8 147.8)
10  59.14303 wilma POINT(47.9 147.9)
11 -19.68219 wilma     POINT(48 148)

If I want to create a linestring from this, I can simply

l <- pts_sf %>% st_coordinates() %>% st_linestring()
l
LINESTRING(47 147, 47.1 147.1, 47.2 147.2, 47.3 147.3, 47.4 147.4, 47.5 147.5, 47.6 147.6, 47.7 147.7, 47.8 147.8, 47.9 147.9)

But, what to do if I want to end up with multiple linestrings with
one for "fred" and another for "wilma" ?

Intuition tells me there should be some way to implement a pipe chain with group_by() and st_multilinestring() e.g.

ml <- pts_sf %>% group_by(id) %>% st_coordinates() %>% st_multilinestring()

But, that doesn't seem to work because st_coordinates() drops the group and also
st_multilinestring() is expecting a list.

in PostGIS, I would do something like:

SELECT sf_pts.id, ST_MakeLine(sf_pts.geometry) As line_geom
	FROM sf_pts
GROUP BY sf_pts.id;

So, maybe a similar sf::st_makeline() function would be beneficial?

@edzer
Copy link
Member

edzer commented Apr 28, 2017

is

> pts_sf %>% group_by(id) %>% summarize(m = mean(attr_data)) %>% st_cast("LINESTRING")
Simple feature collection with 2 features and 2 fields
geometry type:  LINESTRING
dimension:      XY
bbox:           xmin: 47 ymin: 147 xmax: 48 ymax: 148
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
     id        m                       geometry
1  fred 51.11700 LINESTRING(47 147, 47.1 147...
2 wilma 63.77475 LINESTRING(47.6 147.6, 47.7...

what you are looking for?

@jmlondon
Copy link
Author

Ah yes! ... summarize() was the missing piece.

Is there an advantage/difference between this approach (collection of LINESTRINGs) and casting to a MULTIPOINT/MULTILINESTRING with groups/ids?

I think it could still be worth considering whether an st_MakeLine() -like function would offer an improvement. Although, it could just end up being a redundant wrapper for st_cast("LINESTRING").

@edzer
Copy link
Member

edzer commented Apr 30, 2017

sf now has about 125 functions, 85 starting with st_. I'd like to try to make these number smaller, rather than larger, for the sake of usability. But others might disagree, and say that larger numbers are more usable. Anyway, this would be a discussion for a new issue.

@SimonCoulombe
Copy link

st_cast("LINESTRING") doesnt work nice for me. It creates a line, but it breaks the order of the points at it appears to arrange(lon,lat), beforeheand because line jumps all over the Y space instead of following a nice path.

Here is a minimal working example building on jmlondon's example:

pts_sf <- data.frame(
x = c(seq(47, 48, by=0.1), seq(48, 47, by=-0.1)),
y = c(seq(147, 148, by=0.1,),seq(148, 149, by=0.1,)),
attr_data = rnorm(11,42,42),
id = rep("fred",22)) %>%
sf::st_as_sf(coords = c("x","y")) %>%
sf::st_set_crs(4326)

plot(pts_sf)

this line goes up-right from (47,147) to (48,148), then up-left from (48,148) to (47,149)

pts_sf%>% st_coordinates() %>% st_linestring() %>% plot()

this line is supper jagged, jumping up and down on the y axis as it move from x= 47 to x= 48

pts_sf %>% group_by(id) %>% summarize(m = mean(attr_data)) %>% st_cast("LINESTRING") %>% plot()

I want to generate many such line and create a sf data.frame where I have 1 row for each line and plot them in a different color in leaflet.
I am not sure how to that with the first line, because I am not sure how to combine sfg objects.
I can't do it with the second option, because the order of the points in the line is broken.

Any tips for a newbie? :)
thanks!

@edzer
Copy link
Member

edzer commented Nov 6, 2017

pts_sf %>% group_by(id) %>% summarize(m = mean(attr_data),do_union=FALSE) %>% st_cast("LINESTRING") %>% plot()

The default for summarize is to call st_union on points, which rearranges, just like

pts_sf %>% group_by(id) %>% st_union() %>% st_cast("LINESTRING") %>% plot()

does

@pecard
Copy link

pecard commented Dec 19, 2017

Will this (something like this) works [one fashion] for create a geometrycollection as well, keeping points where there is one element only for a ID group?
I'm reading hundreds of millions of data from ornithological radar, tippically with one hexa ID for points (single id) that are replicated when a track is identified.

It would be nice to cast them all in a single process for further analysis.

I found this #110 but the way to go may be here, nevertheless no combination of geometries seems to be in use.

@dblodgett-usgs
Copy link
Contributor

I just spent a good deal of time trying to figure out why some code worked one way on one line and a different way on another line. Just leaving some notes here for future reference.

The one that worked looked like this:
screen shot 2018-07-03 at 10 22 22 am

The one that broke looked like this:
screen shot 2018-07-03 at 10 22 31 am

but when it came out of my function it looked like:
screen shot 2018-07-03 at 10 25 35 am

So node order wasn't being preserved when I was round tripping from sf to matrix back to sf using the method described here.

What @edzer pointed out above with summarise(do_union=FALSE) was the ticket. Here's some code that drives the point home.

roundtrip <- function(input) {
  
  sf::st_as_sf(input, coords = c("X", "Y"), crs = 4326) %>%
    dplyr::group_by(L1) %>%
    dplyr::summarise(do_union=FALSE) %>%
    sf::st_cast("LINESTRING") %>%
    sf::st_coordinates() %>%
    as.data.frame()
  
} 

roundtrip_no_order <- function(input) {
  
  sf::st_as_sf(input, coords = c("X", "Y"), crs = 4326) %>%
    dplyr::group_by(L1) %>%
    dplyr::summarise(do_union=TRUE) %>%
    sf::st_cast("LINESTRING") %>%
    sf::st_coordinates() %>%
    as.data.frame()
  
} 

input <- data.frame(X = c(-76.8776437244438, -76.8804731911061, -76.8810037244386, 
                          -76.8817699244375, -76.8817405244375, -76.8816223911043, 
                          -76.8808265244389, -76.8804431911061, -76.8790579244417, 
                          -76.8756683244469, -76.8746957244484, -76.8741651911159), 
                    Y = c(39.3640528722325, 39.3635036055667, 39.3632976055671, 
                          39.3626338722348, 39.3620848055689, 39.3616958722362, 
                          39.3604604055714, 39.3601858722385, 39.3597970722392, 
                          39.3585160055745, 39.3581728055751, 39.3579898055752), 
                    L1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))

cbind(input, roundtrip(input))

cbind(input, roundtrip_no_order(input))

And the output:

cbind(input, roundtrip(input))
           X        Y L1         X        Y L1
1  -76.87764 39.36405  1 -76.87764 39.36405  1
2  -76.88047 39.36350  1 -76.88047 39.36350  1
3  -76.88100 39.36330  1 -76.88100 39.36330  1
4  -76.88177 39.36263  1 -76.88177 39.36263  1
5  -76.88174 39.36208  1 -76.88174 39.36208  1
6  -76.88162 39.36170  1 -76.88162 39.36170  1
7  -76.88083 39.36046  1 -76.88083 39.36046  1
8  -76.88044 39.36019  1 -76.88044 39.36019  1
9  -76.87906 39.35980  1 -76.87906 39.35980  1
10 -76.87567 39.35852  1 -76.87567 39.35852  1
11 -76.87470 39.35817  1 -76.87470 39.35817  1
12 -76.87417 39.35799  1 -76.87417 39.35799  1

cbind(input, roundtrip_no_order(input))
           X        Y L1         X        Y L1
1  -76.87764 39.36405  1 -76.88177 39.36263  1
2  -76.88047 39.36350  1 -76.88174 39.36208  1
3  -76.88100 39.36330  1 -76.88162 39.36170  1
4  -76.88177 39.36263  1 -76.88100 39.36330  1
5  -76.88174 39.36208  1 -76.88083 39.36046  1
6  -76.88162 39.36170  1 -76.88047 39.36350  1
7  -76.88083 39.36046  1 -76.88044 39.36019  1
8  -76.88044 39.36019  1 -76.87906 39.35980  1
9  -76.87906 39.35980  1 -76.87764 39.36405  1
10 -76.87567 39.35852  1 -76.87567 39.35852  1
11 -76.87470 39.35817  1 -76.87470 39.35817  1
12 -76.87417 39.35799  1 -76.87417 39.35799  1

@Demetrio92
Copy link

https://gis.stackexchange.com/a/270814/112713

x1=st_as_sfc("POINT(47.810368 13.941994)")
x2=st_as_sfc("POINT(47.810358 13.941994)")
c(x1, x2) %>% st_combine() %>% st_cast("LINESTRING")

Works with all group-by/mutate/etc stuff. With lead/lag you'll have to filter out first/last points.

@thisissarah
Copy link

Hi,
I am trying to recreate this apporach to create sf Linestrings from a Point dataframe but my lines turn out jagged the same way others commented before.
This is how I am creating my lines:

test_lines <- data.frame(x, y, NEW_ID)

new_lines <- test_lines %>%
  st_as_sf(coords = c("x", "y"), crs = 25832) %>%
  group_by(NEW_ID) %>%
  dplyr::summarize() %>%  # do_union=FALSE doesn't work as well
  st_cast("LINESTRING") 

plot(new_lines[1,])

And this is my example data:

 x <- c(512479.697065708 , 512480.250661712 , 512482.987040812 , 512483.249553425 , 512492.586731394 , 512490.200111953 , 512489.78343994 ,  512489.450950014 ,
 512488.95288015 ,  512488.542001041 , 512488.167317277 , 512487.098424994 , 512485.96381862 ,  512484.828296161 , 512484.185293151 , 512483.723459029 ,
 512483.512066037 , 512483.249553425 , 512415.384159413 , 512415.577936111 , 512415.789227095 , 512415.894862411 , 512416.791584063 , 512417.027661192 ,
 512417.241952151 , 512417.521992658 , 512417.693089591 , 512417.947047717 , 512418.134676398 , 512418.436225651 , 512418.85206217 ,  512419.168545053 ,
 512419.444117332 , 512419.77909383 ,  512420.049782357 , 512420.359461634 , 512420.657619221 , 512421.028816685 , 512421.320003802 , 512421.596095004 ,
 512422.029521903 , 512422.369220085 , 512422.733380085 , 512423.120268537 , 512423.528349138 , 512423.956056845 , 512426.471454705 , 512426.973087944 ,
 512427.901722061 , 512428.039719761 , 512479.697065708 , 512479.143469704 , 512478.952871949 , 512478.136753726 , 512477.662498739 , 512476.836567475 ,
 512476.544938521 , 512475.969742769 , 512474.651534452 , 512474.039156801 , 512472.772119656 , 512472.062125426 , 512470.870109725 , 512470.2573916 ,  
 512469.128985774 , 512468.096017977 , 512467.564167915 , 512466.865294995 , 512466.320281231 , 512465.699030065 , 512465.046371911 , 512464.414069958 ,
 512463.650878563 , 512462.067272335 , 512459.664316558 , 512457.08817566 ,  512454.508070211 , 512453.210570318 , 512452.290456146 , 512450.858545348 ,
 512449.245135025 , 512447.211963124 , 512445.045315604 , 512444.173996014 , 512443.497085307 , 512442.300040917 , 512441.645461029 , 512440.920296171 ,
 512440.288043701 , 512439.578990257 , 512439.045057906 , 512438.355723944 , 512437.770398522 , 512437.184200194 , 512436.300526718 , 512435.233306577 ,
 512434.470977573 , 512433.299213609 , 512432.598626104 , 512432.056047379 , 512431.729465245 , 512431.169762474 , 512428.039719761 , 512428.177717462 ,
 512429.855871946 , 512430.610059703 , 512431.169762474 , 512507.157200324 , 512506.769961235 , 512506.429383907 , 512506.036085093 , 512505.629745321 ,
 512505.13325311 ,  512504.715807742 , 512504.408778062 , 512503.982592299 , 512503.493855094 , 512503.061600461 , 512502.830877652 , 512502.39535427 , 
 512502.156304005 , 512501.720234171 , 512501.219812837 , 512500.699217728 , 512500.37348907 ,  512499.94418624 ,  512499.267964737 , 512498.760247967 ,
 512498.340938622 , 512497.680562224 , 512497.252821696 , 512496.367080671 , 512495.34381091 ,  512494.487636641 , 512492.010959641 , 512489.961273602 ,
 512488.853605089 , 512488.341336553 , 512485.388097999 , 512484.826397199 , 512483.313981521 , 512481.264552167 , 512480.282029173 , 512479.197741063 ,
 512478.70867489 ,  512478.188488126 , 512477.719910045 , 512477.109664291 , 512475.780561418 , 512473.898753897 , 512472.978044594 , 512472.28686614 , 
 512472.166699147 , 512471.794914526 , 512471.012634321 , 512531.077743031 , 512531.469757789 , 512532.669683117 , 512532.680756732 , 512532.708711943 ,
 512532.752157013 , 512532.867686974 , 512533.132446696 , 512533.371046309 , 512533.824055231 , 512534.024504623 , 512534.40306935 ,  512535.131292432 ,
 512535.705843865 , 512536.399961217 , 512536.617626863 , 512536.92069792 ,  512537.15235619 ,  512537.410472921 , 512537.980240068 , 512538.271128349 ,
 512538.604521918 , 512539.42394453 ,  512540.592798016 , 512541.567214129 , 512542.001164023 , 512542.206911238 , 512542.592928084 , 512543.728893019 ,
 512544.068808613 , 512544.387303822 , 512544.785527888 , 512545.053449377 , 512545.547078128 , 512546.111529726 , 512547.18679658 ,  512547.690398632 ,
 512547.767937038 , 512547.804141347 , 512547.827013442 , 512548.285361443 , 512548.887017059 , 512549.195740681 , 512531.077743031 , 512530.685728273 ,
 512530.543579968 , 512530.197928509 , 512529.632024297 , 512529.337251287 , 512528.538408127 , 512528.217287828 , 512527.368342418 , 512526.187479454 ,
 512525.66807419 ,  512525.155055254 , 512524.123425993 , 512523.333620799 , 512522.845719099 , 512522.493475288 , 512522.02414975 ,  512521.707617408 ,
 512521.414032635 , 512521.272723958 , 512521.003438704 , 512520.611198348 , 512520.044358903 , 512519.883403295 , 512519.581804837 , 512519.401724859 ,
 512519.226393887 , 512518.908757327 , 512518.677251262 , 512518.383111624 , 512518.125986409 , 512517.891754541 , 512517.579340079 , 512517.294601343 ,
 512516.534844996 , 512516.232402901 , 512515.910507093 , 512515.564246133 , 512515.221423256 , 512514.971887748 , 512514.669375889 , 512514.571434083 ,
 512514.253105538 , 512514.082025203 , 512513.747593368 , 512513.700478408 , 512513.349890152 , 512513.261851035 , 512512.712619034 , 512512.097684535 ,
 512512 ,           512512.006544385 , 512512.02498364 ,  512512.712619034 , 512507.157200324 , 512507.544439412 , 512512.712619034 , 512492.586731394 ,
 512494.556199353 , 512495.235072968 , 512496.064112409 , 512496.311072031 , 512496.637229679 , 512496.838057973 , 512497.158693114 , 512497.534620225 ,
 512497.847948322 , 512498.150219877 , 512498.454494612 , 512498.671801076 , 512499.343740123 , 512499.568181757 , 512499.972352636 , 512500.200692716 ,
 512500.454522548 , 512500.686574989 , 512500.869130695 , 512501.28349144 ,  512501.517356646 , 512501.904607063 , 512503.008985698 , 512503.272686664 ,
 512503.900668267 , 512504.215076556 , 512504.471659978 , 512504.784537156 , 512505.032728834 , 512505.339041358 , 512505.757924357 , 512506.218528546 ,
 512506.656969083 , 512507.456461994 , 512507.923405741 , 512509.446858774 , 512510.916227406 , 512511.260548276 , 512511.940773104 , 512512.080641235 ,
 512512.732295137 , 512512.832913485 , 512512.544714271 , 512512.097684535 , 512512.269086673 , 512512.294417801 , 512512.29539941 ,  512512.256515058 ,
 512512.544714271 , 512549.195740681 , 512549.504464303 , 512549.615775818 , 512550.05706312 ,  512550.294048221 , 512550.563069153 , 512550.805049173 ,
 512551.877228774 , 512552.138405963 , 512552.452242581 , 512553.612261229 , 512554.231688528 , 512554.897676925 , 512555.026613213 , 512555.285111796 ,
 512555.403889146 , 512555.559892224 , 512555.665627616 , 512555.829303864 , 512555.918834597 , 512556.091281272 , 512556.161299882 , 512556.29685421 , 
 512556.334599458 , 512556.523882052 , 512556.547546865 , 512556.695796547 , 512556.704268122 , 512557.015234229 , 512557.001384996 , 512557.217040051 ,
 512557.187046448 , 512557.351367066 , 512557.571243187 , 512557.524181427 , 512557.687564349 , 512557.623565981 , 512557.835948975 , 512557.755492166 ,
 512557.908204675 , 512557.812104296 , 512558.092245563 , 512558.215978661 , 512415.384159413 , 512415.190382715 , 512414.957578414 , 512414.898012412 ,
 512414.558488979 , 512414.067211799 , 512413.638307348 , 512413.419640465 , 512413.24907239 ,  512412.589339638 , 512412.440848364 , 512412.295916573 ,
 512412.153275912 , 512411.533145835 , 512411.412878189 , 512411.34087791 ,  512411.292126322 , 512411.268620724 , 512410.418976001 , 512410.419473156 ,
 512410.444374562 , 512410.495616667 , 512410.249109005 , 512410.326740391 , 512410.430697842 , 512410.171190017 , 512410.301374468 , 512410.04923823 , 
 512410.181550106 , 512410.062466312 , 512410.16110783 ,  512410.048053736 , 512410.127340298 , 512410.021076678 , 512410.104721863 , 512410.006700549 ,
 512410.094466192 , 512409.994326209 , 512410.085904982 , 512409.983965338 , 512410.078979306 , 512409.975637993 , 512410.073641847 , 512409.969366909 ,
 512410.069855885 , 512409.965172951 , 512410.067594993 , 512410.17136635 ,  512471.012634321 , 512470.230354115 , 512469.591030456 , 512469.321345479 ,
 512468.650056948 , 512468.203552182 , 512467.732139706 , 512467.219223363 , 512466.867185175 , 512466.716848874 , 512466.475889951 , 512466.256501471 ,
 512466.109923706 , 512466.001240639 , 512465.867649463 , 512465.779859319 , 512465.556429178 , 512465.49283629 ,  512465.404718517 , 512465.377442848 ,
 512465.305711549 , 512465.289928503 , 512465.234705359 , 512465.265158684)


 
y <- c(6018724.17256768 , 6018724.0306637 ,  6018723.40160793 , 6018723.02062054 , 6018719.63978774 , 6018719.8859143 ,  6018719.94169498 , 6018720.19904659 ,
  6018720.27865743 , 6018720.55930264 , 6018720.7783321 ,  6018720.9822937 ,  6018721.53062273 , 6018721.77786335 , 6018722.12486027 , 6018722.45502615 ,
 6018722.63963316 , 6018723.02062054 , 6018750.38515942 , 6018749.83393612 , 6018749.3522271 ,  6018749.16086242 , 6018747.28558407 , 6018746.8286612 , 
 6018746.34995216 , 6018745.83799267 , 6018745.4150896 ,  6018744.97604772 , 6018744.47067641 , 6018743.98022566 , 6018742.81206217 , 6018742.33654506 ,
 6018741.62211734 , 6018741.16509384 , 6018740.54478237 , 6018740.16146164 , 6018739.56861923 , 6018739.14781669 , 6018738.64700381 , 6018738.23009501 ,
 6018737.77252191 , 6018737.32022009 , 6018736.89238009 , 6018736.48726854 , 6018736.10334914 , 6018735.73905685 , 6018733.20545472 , 6018732.81608795 ,
6018732.16072207 , 6018731.90271977 , 6018724.17256768 , 6018724.31447166 , 6018724.42087314 , 6018724.59475322 , 6018724.81339919 , 6018724.97746768 ,
 6018725.08131377 , 6018725.21902713 , 6018725.45213798 , 6018725.49387016 , 6018725.71183302 , 6018725.69306437 , 6018725.88704867 , 6018725.8283917 , 
 6018725.68065223 , 6018725.83568443 , 6018725.77455507 , 6018725.86768213 , 6018725.81907717 , 6018725.890826 ,   6018725.85065988 , 6018725.91135793 ,
 6018725.88277965 , 6018725.98217341 , 6018725.92307067 , 6018726.01992979 , 6018725.90485765 , 6018725.99335776 , 6018725.97951027 , 6018726.13159947 ,
 6018726.18139745 , 6018726.42522556 , 6018726.54246534 , 6018726.66114572 , 6018726.77623503 , 6018726.85613586 , 6018726.99355597 , 6018727.05842898 ,
 6018727.21817651 , 6018727.30036941 , 6018727.45943706 , 6018727.56183975 , 6018727.66943651 , 6018727.87523819 , 6018728.0805324 ,  6018728.49831224 ,
 6018728.72597842 , 6018729.13821392 , 6018729.42762614 , 6018729.67704739 , 6018729.84546524 , 6018729.98126248 , 6018731.90271977 , 6018731.64471747 ,
 6018730.55087195 , 6018730.11705971 , 6018729.98126248 , 6018741.69410277 , 6018741.95138423 , 6018742.30121788 , 6018742.21084514 , 6018742.13902167 ,
 6018742.62883081 , 6018742.57545308 , 6018742.86020423 , 6018742.824961 ,   6018743.22389503 , 6018743.20626876 , 6018743.37006651 , 6018743.36934668 ,
 6018743.52481695 , 6018743.54012033 , 6018743.82874009 , 6018743.8667927 ,  6018744.03421474 , 6018744.08096629 , 6018744.39104616 , 6018744.46331616 ,
 6018744.63578763 , 6018744.75719823 , 6018744.92123852 , 6018745.12068056 , 6018745.47823272 , 6018745.70998456 , 6018746.49527914 , 6018747.1086068 , 
 6018747.4833455 ,  6018747.66148792 , 6018748.76465966 , 6018748.99199995 , 6018749.64944729 , 6018750.37201792 , 6018750.77031684 , 6018751.16880956 ,
 6018751.37274339 , 6018751.54296756 , 6018751.76738948 , 6018751.94618466 , 6018752.69608177 , 6018753.18136297 , 6018753.64665368 , 6018753.84298549 ,
 6018753.9208185 ,  6018754.04189476 , 6018754.20207589 , 6018775.26875698 , 6018775.57224221 , 6018777.34231691 , 6018777.62824329 , 6018777.79828808 ,
 6018777.952843 ,   6018778.23331304 , 6018778.66155332 , 6018779.11595371 , 6018779.90007012 , 6018780.19462072 , 6018780.95493064 , 6018781.90970758 ,
 6018783.21615613 , 6018784.20503877 , 6018784.68037312 , 6018785.15359118 , 6018785.61493291 , 6018786.06552706 , 6018786.98075993 , 6018787.48187168 ,
 6018787.9404781 ,  6018789.39805548 , 6018790.803202 ,   6018792.50178588 , 6018793.057836 ,   6018793.34708878 , 6018793.95107191 , 6018795.98310696 ,
 6018796.63319137 , 6018797.30469617 , 6018797.99547212 , 6018798.61855064 , 6018799.41192188 , 6018800.82747026 , 6018802.42520342 , 6018803.50560138 ,
 6018803.72506298 , 6018803.88685867 , 6018804.25998658 , 6018804.98963855 , 6018806.07098216 , 6018806.21025854 , 6018775.26875698 , 6018774.96527174 ,
 6018774.71142004 , 6018774.1660715 ,  6018773.04897571 , 6018772.55174872 , 6018771.07359188 , 6018770.50371218 , 6018769.07565759 , 6018766.79152056 ,
 6018765.82592582 , 6018764.75494476 , 6018762.81657401 , 6018761.01378522 , 6018760.01668692 , 6018759.19952472 , 6018758.18385026 , 6018757.3123826 , 
 6018756.71496737 , 6018756.26227605 , 6018755.7395613 ,  6018754.34980166 , 6018753.33264113 , 6018752.80059674 , 6018752.31019531 , 6018751.79727529 ,
 6018751.37860626 , 6018750.90424346 , 6018750.44274952 , 6018750.04389156 , 6018749.60801678 , 6018749.24824864 , 6018748.86767175 , 6018748.55843263 ,
 6018747.43718898 , 6018747.14568889 , 6018746.87372654 , 6018746.3289875 ,  6018746.07813808 , 6018745.63467359 , 6018745.44274083 , 6018745.24368263 ,
 6018745.06803395 , 6018744.64511429 , 6018744.48635802 , 6018744.33547297 , 6018744.19415146 , 6018743.78719057 , 6018743.56140693 , 6018736.75794849 ,
 6018737 ,          6018737.68645562 , 6018737.96501637 , 6018743.56140693 , 6018741.69410277 , 6018741.43682132 , 6018743.56140693 , 6018719.63978774 ,
 6018719.43692428 , 6018720.05728691 , 6018720.02117234 , 6018720.23023286 , 6018720.23936909 , 6018720.39462691 , 6018720.41962841 , 6018720.66324041 ,
 6018720.70537524 , 6018720.85885136 , 6018720.91901093 , 6018721.00118329 , 6018721.19914364 , 6018721.24607707 , 6018721.41800448 , 6018721.44596966 ,
 6018721.58110303 , 6018721.59200183 , 6018721.70296151 , 6018721.68935159 , 6018721.84852011 , 6018722.15187047 , 6018722.05191479 , 6018722.28259925 ,
 6018722.28227114 , 6018722.31505534 , 6018722.55323573 , 6018722.61164417 , 6018722.67747766 , 6018722.783499 ,   6018722.97415942 , 6018723.24639234 ,
 6018723.56742839 , 6018724.35178165 , 6018724.75827059 , 6018726.2934096 ,  6018727.88511806 , 6018728.3079817 ,  6018729.0137024 ,  6018729.23777764 ,
 6018729.87311987 , 6018730.10850437 , 6018732.9727036 ,  6018736.75794849 , 6018736.33217335 , 6018736.20756475 , 6018736.02047542 , 6018735.83690282 ,
 6018732.9727036 ,  6018806.21025854 , 6018806.34953492 , 6018806.4362234 ,  6018806.6879361 ,  6018806.846951 ,   6018807.07293007 , 6018807.32595005 ,
 6018809.42156328 , 6018809.75438609 , 6018810.23254938 , 6018812.21074509 , 6018813.39809422 , 6018814.59696559 , 6018814.85430618 , 6018815.2759903 , 
 6018815.53655282 , 6018815.76429167 , 6018816.02755388 , 6018816.2423029 ,  6018816.50716333 , 6018816.70599025 , 6018816.97073596 , 6018817.10759483 ,
 6018817.30470823 , 6018817.46843808 , 6018817.66301691 , 6018817.77017755 , 6018817.96089484 , 6018818.1301878 ,  6018818.37596671 , 6018818.45241119 ,
 6018818.62838362 , 6018818.66530778 , 6018818.68632017 , 6018818.85339567 , 6018818.84758275 , 6018819.00422157 , 6018818.96754504 , 6018819.11226443 ,
 6018819.06325584 , 6018819.19466471 , 6018819.04317046 , 6018818.94204485 , 6018750.38515942 , 6018750.93638272 , 6018751.49557841 , 6018751.73301241 ,
 6018752.58148898 , 6018753.57521179 , 6018754.73030734 , 6018755.20464045 , 6018755.6280724 ,  6018757.54233937 , 6018758.08684611 , 6018758.7338869 , 
 6018759.48195681 , 6018761.33680292 , 6018762.10572162 , 6018762.72167369 , 6018763.3531075 ,  6018763.99514741 , 6018766.60564113 , 6018767.15825611 ,
 6018767.79743739 , 6018768.42224184 , 6018769.15436388 , 6018769.75677692 , 6018770.32863655 , 6018771.02783437 , 6018771.55906322 , 6018772.13302141 ,
 6018772.54596878 , 6018772.77547756 , 6018773.02366777 , 6018773.21387219 , 6018773.3833927 ,  6018773.54361682 , 6018773.6972747 ,  6018773.82366555 ,
 6018773.96004626 , 6018774.07004851 , 6018774.1878309 ,  6018774.28006821 , 6018774.37807783 , 6018774.45129258 , 6018774.52855044 , 6018774.58164681 ,
 6018774.63741055 , 6018774.66949525 , 6018774.7032899 ,  6018774.71492659 , 6018754.20207589 , 6018754.36225702 , 6018754.60882005 , 6018754.73159114 ,
 6018754.72981139 , 6018754.9653672 ,  6018754.94803884 , 6018755.2903379 ,  6018755.25886132 , 6018755.38258098 , 6018755.34434349 , 6018755.55997439 ,
 6018755.52631977 , 6018755.66023572 , 6018755.61960703 , 6018755.75559819 , 6018755.65310924 , 6018755.78962009 , 6018755.72814677 , 6018755.81848268 ,
 6018755.75076722 , 6018755.8835557 ,  6018755.81022106 , 6018755.97814886)
 

NEW_ID <- rep(18, each = 420)

I also posted this question here on StackOverflow.
I'd appreciate any help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants