Qui gen double `d' = 2 * asin(min(1,sqrt( /// the following is equivalent of using -geodist- (from SSC) ESRI format: points must form a closed loop.Ĭap by `ring': assert `lon1' = `lon1'Ĭap by `ring': assert `lat1' = `lat1'ĭis as err "Polygon rings must form a closed loop first and last vertex do not match" ESRI format: minimum of 4 points (plus missing coordinates obs)ĭis as err "Polygon rings must contain at least 4 points to form a closed loop" If "`varlist'" = "" local varlist _ID _Y _Xĭis as err "You must specify 3 variables that hold, in order:"Ĭap assert inrange(`lat1',-90, 90) if !mi(`lat1')ĭis as err "The latitude variable should range from -90 to 90"Ĭap assert inrange(`lon1',-180, 180) if !mi(`lon1')ĭis as err "The latitude variable should range from -180 to 180" if no variables are provided, assume those generated by -shp2dta. Graph export "drowning_map.png", replace width(1000)and the resulting map:Ĭode: *! version 1.0.0 25nov2015 Robert Picard, define geopolyfill
Line ylat xlon if mi(lat), lwidth(vthin) lcolor(gs10) cmissing(n) xsize(`xw') ysize(`yw') `options' Scatter ylat xlon if !mi(d_latitude) & _ID = 201, msymbol(x) mcolor(green) || /// Scatter ylat xlon if !mi(d_latitude) & _ID = 107, msymbol(x) mcolor(red) || /// Scatter ylat xlon if !mi(d_latitude) & _ID = 50, msymbol(x) mcolor(blue) || /// * make a scatter plot of all drownings, use separate colors by nearest country Local options `options' graphregion(margin(small) fcolor(gs15)) * a small margin to the graph region to make a gray border Local options `options' plotregion(margin(small)) * add a small margin to the plot region so that points are not up to the side Local options `options' yscale(off) xscale(off) Local options `options' ylabel(minmax, nogrid) xlabel(minmax, nogrid)
#GEODIST RADIAN STATA FULL#
* spread the points along the full width of the plot * build options for a making a map, start by removing the legend * determine the size of the graph using the aspect ratio that * convert coordinates using Google Maps projection | Year event_id d_latit~e d_longi~e coor_id km_to_nid _ID _X _X | list Year event_id d_latitude d_longitude coor_id km_to_nid _ID _X _X event_id: is the id of the drowning eventĪlso please notice that I have 343 drowning events and many more data for latitude and longitude.Ĭode.d_latitude d_longitude defines the coordinates of where the drowning event happened.latitude and longitude are instead the coordinates that define the Lybian border (have them for all the countries).
_ID identifies the Country LIbya=3 Tunisia=5 Egypt=2.I need that because after that I am gonna say that the boat departed from Libya (if libya is the closest country), and I will build a variable called number of events by departure point. I have latitude and longitude for a set of drowning events occurred in the Mediterranean Sea, I also have the data, as a shape file, of the coastal border of Libya Tunisia and Egypt, what I would like to do is: compute all the possible distances between every single drownig event and the coastal border of the countries stated above.įor example I have that a boat (identified as event 4) capsized at coordinates: 32.6853649 (d_latitude) 25.9012421(d_longitude) I want then to compute all the pairwise distances from that point to each country border and then take the smllest of such distance. Good Morning I am dealing with the following problem: