Message Boards Message Boards

GROUPS:

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

Posted 1 year ago
1444 Views
|
5 Replies
|
4 Total Likes
|

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:
5 Replies

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

Posted 1 year 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?

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"]

I posted a workaround here:

Simulating GeoNearest for ZIP codes around a geo path

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

Posted 1 year ago

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

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract