[Tutor] Making unique identifier from repeated observation data

Tariq Khasiri tariqkhasiri at gmail.com
Wed Mar 29 20:55:11 EDT 2023


My data frame looks like the following. Here, countyfp stands for usa
county code, statefp stands for statefip ( state code of USA). Fullname
stands for the name of the interstate highway. Geometry is the geographical
position of that interstate highway. Here, the distance variable is the key
for each interstate highway observation. The distance variable stands up
for the distance between each county and its nearest intersection of
interstate highways

I have multiple records when there are multiple interstates that intersect
a county, because they are all equidistant. Now, for each unique county I
only want to keep the minimum distance from the nearest intersection of the
interstate highway. How can I keep the observations making the combined
(countyfp and statefp) the unique identifier? The first column is index.

My objective is to find the minimum distance from each county to its the
nearest intersection of interstate highway.


FULLNAME geometry statefp countyfp distance 0 I- 75 POLYGON ((-83.88076
41.08036, -83.88076 41.081... 39 063 0.000000 111 I- 75 POLYGON ((-84.39719
40.78658, -84.39720 40.787... 39 003 0.000000 2301 I- 75 POLYGON
((-84.45562 40.55325, -84.45562 40.553... 39 011 0.000000 0 I- 75 POLYGON
((-83.88076 41.08036, -83.88076 41.081... 39 063 0.000000 111 I- 75 POLYGON
((-84.39719 40.78658, -84.39720 40.787... 39 003 0.000000 812 I- 75 POLYGON
((-83.70964 41.52185, -83.70950 41.522... 39 173 0.000000 1639 I- 75
POLYGON ((-83.47674 40.90496, -83.47666 40.917... 39 175 0.197390 0 I- 75
POLYGON ((-83.88076 41.08036, -83.88076 41.081... 39 063 0.000000 672 I- 75
POLYGON ((-84.34216 41.00514, -84.34222 41.012... 39 137 0.030141 812 I- 75
POLYGON ((-83.70964 41.52185, -83.70950 41.522... 39 173 0.000000 0 I- 75
POLYGON ((-83.88076 41.08036, -83.88076 41.081... 39 063 0.000000 812 I- 75
POLYGON ((-83.70964 41.52185, -83.70950 41.522... 39 173 0.000000 1 I- 95
POLYGON ((-77.58878 38.50404, -77.58295 38.508... 51 179 0.000000 101 I- 95
POLYGON ((-77.78589 38.26993, -77.78357 38.271... 51 177 0.000000 1140 I-
95 POLYGON ((-77.53268 38.30850, -77.53267 38.308... 51 630 0.000000 1 I-
95 POLYGON ((-77.58878 38.50404, -77.58295 38.508... 51 179 0.000000 304 I-
95 MULTIPOLYGON (((-77.57948 38.62765, -77.57955 ... 51 153 0.000000 1036
I- 95 POLYGON ((-77.26754 38.33410, -77.26721 38.333... 51 099 0.122636
2422 I- 95 POLYGON ((-76.89028 38.11468, -76.89335 38.112... 51 193
0.407545 1 I- 95 POLYGON ((-77.58878 38.50404, -77.58295 38.508... 51 179
0.000000


More information about the Tutor mailing list