# \[?\] Find all ZipCodes within 5 miles of a KML line?

**URL:** <https://community.wolfram.com/t/find-all-zipcodes-within-5-miles-of-a-kml-line/11398>\
**Category:** Questions\
**Tags:** curated-data, wolfram-cloud, geography\
**Created:** [October 15, 2017, 7:55am UTC](https://community.wolfram.com/t/find-all-zipcodes-within-5-miles-of-a-kml-line/11398 "2017-10-15T07:55:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wf](https://avatars.discourse-cdn.com/v4/letter/w/c4cdca/32.png) [@wf](https://community.wolfram.com/u/wf)\
**Post date:** [October 15, 2017, 7:55am UTC](https://community.wolfram.com/t/find-all-zipcodes-within-5-miles-of-a-kml-line/11398/1 "2017-10-15T07:55:31Z")

</div>

I drew a line using Google Earth. I saved it as “Line2.kml” (not kmz). I uploaded it to Wolfram Programming Lab.

I can successfully import the line into Wolfram:

```
kml1 = Import["Line2.kml", "Graphics"];

```

I can find all of the zip codes within 5 miles of a single point:

```
zipCodeList = GeoEntities[GeoDisk[GeoPosition[{46.73333672951149,-117.009711345202,0}], Quantity[5, "Miles"]], "ZIPCode"]

```

Is there a way to find all of the zip codes within 5 miles of all of the points?

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [October 15, 2017, 4:57pm UTC](https://community.wolfram.com/t/find-all-zipcodes-within-5-miles-of-a-kml-line/11398/2 "2017-10-15T16:57:52Z")

</div>

Could use brute force by finding them for a set of points on the line that have smallish gaps between neighbors.

---

<div class="post-metadata">

**Author:** ![wf](https://avatars.discourse-cdn.com/v4/letter/w/c4cdca/32.png) [@wf](https://community.wolfram.com/u/wf)\
**Post date:** [October 16, 2017, 4:10am UTC](https://community.wolfram.com/t/find-all-zipcodes-within-5-miles-of-a-kml-line/11398/3 "2017-10-16T04:10:19Z")

</div>

It looks like the correct term I should have used is Path, not Line. It consists of about 240 points.

I like the concept of separating out individual points, finding the ZipCodes near each point, and eliminating the duplicate ZipCodes.

I do not understand the data structure of my variable “kml1”. [I am much more at home with languages that require exact variable types to be declared in advance.]

Is there a way to loop through all Points in variable “kml1” and execute code on each point?

---

<div class="post-metadata">

**Author:** ![Vitaliyk](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vitaliyk/32/45591_2.png) [@Vitaliyk](https://community.wolfram.com/u/Vitaliyk)\
**Post date:** [October 16, 2017, 7:45am UTC](https://community.wolfram.com/t/find-all-zipcodes-within-5-miles-of-a-kml-line/11398/4 "2017-10-16T07:45:34Z")

</div>

Perhaps this is of some help. To find nearest cities within 5ml is much easier. And then to find ZIPs for every city is also easy.

```
data = Import["Line2.kml", "Data"]

pos = First[Cases[data, _GeoPosition, Infinity]]

cits = GeoNearest[Entity["City"], pos, {All, Quantity[5, "Miles"]}]

EntityValue[cits, "ZIPCodes"]

```

---

<div class="post-metadata">

**Author:** ![Vitaliyk](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vitaliyk/32/45591_2.png) [@Vitaliyk](https://community.wolfram.com/u/Vitaliyk)\
**Post date:** [October 16, 2017, 8:20am UTC](https://community.wolfram.com/t/find-all-zipcodes-within-5-miles-of-a-kml-line/11398/5 "2017-10-16T08:20:52Z")

</div>

I posted a workaround here:

Simulating GeoNearest for ZIP codes around a geo path

[http://community.wolfram.com/groups/-/m/t/1203815](http://community.wolfram.com/groups/-/m/t/1203815)

---

<div class="post-metadata">

**Author:** ![wf](https://avatars.discourse-cdn.com/v4/letter/w/c4cdca/32.png) [@wf](https://community.wolfram.com/u/wf)\
**Post date:** [October 20, 2017, 8:00am UTC](https://community.wolfram.com/t/find-all-zipcodes-within-5-miles-of-a-kml-line/11398/6 "2017-10-20T08:00:40Z")

</div>

It looks very good. It will take me a bit to digest it all.
