Message Boards Message Boards

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

GROUPS:

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?

Attachments:
POSTED BY: Steve LaDuke
Answer
3 months ago

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

POSTED BY: Daniel Lichtblau
Answer
3 months ago

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?

POSTED BY: Steve LaDuke
Answer
3 months ago

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"]
POSTED BY: Vitaliy Kaurov
Answer
3 months ago

I posted a workaround here:

Simulating GeoNearest for ZIP codes around a geo path

http://community.wolfram.com/groups/-/m/t/1203815

POSTED BY: Vitaliy Kaurov
Answer
3 months ago

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

POSTED BY: Steve LaDuke
Answer
3 months ago

Group Abstract Group Abstract