My end goal is to get an inner band N meters wide for a given polygon.
I wanted to use JSTS's buffer, then substract the inside buffered polygon to the starting polygon to get the band.
The problem is that I get inconsistent width between the buffered polygon and the original one:
import GeoJSONWriter from "jsts/org/locationtech/jts/io/GeoJSONWriter";
import GeoJSONReader from "jsts/org/locationtech/jts/io/GeoJSONReader";
import { BufferOp } from "jsts/org/locationtech/jts/operation/buffer";
function getOffsetPolygonJSTS(
poly: Feature<Polygon>,
offsetSize: number
): Feature<Polygon> {
const geoReader = new GeoJSONReader();
const geoWriter = new GeoJSONWriter();
const geometry = geoReader.read(poly.geometry);
const res = BufferOp.bufferOp(geometry, -0.0001);
const jstsBuffer = geoWriter.write(res);
return polygon(jstsBuffer.coordinates);
}
It sounds like you're operating on (lat,long) coordinates and expecting the results to work like (x,y) coordinates. They do not, except near the equator.
Perform the operation in a locally anisotropic coordinate space. That'll also be essential for specifying the width in meters, rather than guessing.