You do not necessarily need to draw a map if you are working with an entered zip code.
Turf.js which was made for working with JavaScript mapping however could be really useful.
The aggregate function could be helpful you here if you can use the counterpoints of counties. You could also use polygons, but it will be more complicated.
Simply using center points:
- Create GeoJSONs for both your zips and county data with polygons.
- Select point from zips with the
turf.filter
function.
- Create your 50 mile radius from the point with
turf.buffer
- Use
turf.aggregate
to get polygons with the sums of the attributes.
A bit more complicated way if you wish to use polygons:
- Create GeoJSONs for both your zips and county data with polygons.
- Select zip polygon with
turf.filter
.
- Create your 50 mile radius buffer with
turf.buffer
.
- Create variables to hold your totals for each attribute with 0.
- For each county use
turf.intersect
with your 50 mile buffer to check that it doesn't return undefined
(or that it returns a polygon). If your buffer and county overlap add each of the county attributes to the totals.
If you wish to display a map you could input your filtered ZIP code point/polygon, your buffered polygon, and the aggregated/intersected polygons.
Additionally you could replace using turf.filter
and your own zip GeoJSON with using a lookup service like Mapbox geocoding which will also work with addresses or town names.