I have a bunch of data all in EPSG:4326 for which I need to calculate some buffers around particular points in this data. I am using the Esri geometry engine in java to accomplish this (https://github.com/Esri/geometry-api-java). There is a nice API call available to produce these buffers. My users are used to providing the radius of a buffer in miles. The problem is the Esri geometry library uses the units of your projection as the distance, and in the case of EPSG:4326 the units are degrees. So if I tell the library I want a buffer with a distance of 5 it will give me back a buffer with a radius of 5 degrees around my point.
So I'm wondering what the best approach is here. I had initially thought of projecting this data to EPSG:3857 because the units in that projection are meters. I could then convert the miles that a user wants into meters easily and then project back to EPSG:4326 to give the user back their answer.
If this isn't a good approach I'm very open to suggestions. I had initially tried to figure out how I could convert miles to degrees in EPSG:4326 but that looks to be tricky and could depend on how far away you are from the equator. I'm afraid of screwing that up.
Anyone have any suggestions?
Your post may be moved to the coordinate reference systems 'place' as this one is for the Runtime SDK for Java rather than the Java Geometry API.
You're correct that you'll need to project the geometries to a projected coordinate reference system before buffering. I wouldn't suggest using 3857 (Web Mercator) as it's quite distorted except near the equator. There's not a good answer for you. Even for so-called 'equidistant' projections, they maintain distances from one or two points or along certain lines, like all north-south lines.
One intensive solution is to create a custom projected coordinate system for each geometry. If they're points, center an azimuthal equidistant projection, run the buffer, then reproject to whatever coordinate reference system you're using. If you don't need really accurate results and are instead okay with 1 part in 2500 accuracy at the worst AND working within 3 degrees of longitude, the local UTM zone would be okay. A shortcut for UTM zones are that the WGS 84 ones have well-known IDs that look like:
326 + zone number
where zone number is 01 - 60 for the northern hemisphere and
327 + zone number for the southern hemisphere
I'm not going to replicate the pseudo-code here, but there's a post on GIS stackexchange that shows how to calculate the UTM zone from a latitude-longitude point.