I am working with start and end coordinate points and I have generated
midpoints between the two. Each start, end, midpoint, and connecting segments
are visualized using the plot function. Five segments (groups of points) are
plotted side-by-side in near-parallel arrangements. I could use some help
performing three functions:
1: Determine the 90-degree angle of each segment,
2: generate a line from the midpoint of each segment to the intersecting point
of the next segment (for instance, 90-degrees from the midpoint of segment 1 to
anywhere on segment 2),
3: and report the distance of the generated line
data3<-data2 #cannot have two sets of coordinates in one dataframe; create
another
# need two sets of coordinates to plot line
segments connecting
# haul start and haul end coordinates command
is necessary. It converts the dataframe to "Spatial Points Dataframe"
# so that SetLon and SetLat are gone, replaced
by one column
coordinates(data2)<-~LonOD+LatOD # Defines point
coordinates and converts the dataframe
coordinates(data3)<-~LonTrap+LatTrap # repeat for end
coordinates
data2@proj4string<-CRS('+init=epsg:4326') # DEFINE PROJECTION AS LATLON
data3@proj4string<-CRS('+init=epsg:4326') # DITTO
plot(bathy.arc.tr,col="gray80"
#bathy.arc@data$color<mailto:#bathy.arc@data$color>
,xlim=c(-70.9065,-70.905),ylim=c(41.4715,41.4748)) # bathy comes first
so data points aren't covered up
polygon(c(-71,-71,-70,-70)
,c( 41, 42, 42, 41), col=rgb(0.44, 1, 1, .2)) # this is rgb;
last # is transparency so bathymetry is seen (if present)
# plot points
plot(data2,pch=18,col=c("red"), add=T, border="transparent") # Start
coordinates
points(LatTrap~LonTrap, data2, pch=18, col="green2") # End coordinates
segments(data2@coords[,1], data2@coords[,2], data3@coords[,1],
data3@coords[,2],col=c("black")) # plot segments (start to end coordinates)
Included is an example of the groups of 5 near-parallel segments. Each group of
5 segments are uniquely identified (such as group1:pair1, group1:pair2, etc.).
Again, looking for the 90-degree distance from midpoint of group1:pair1 to
intersection of group1:pair2.
David M. Chosid
Conservation Solutions
MA Division of Marine Fisheries
836 S. Rodney French Blvd.
Mobile: 857-393-4026
[email protected]<mailto:[email protected]>
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.