3

I am new in using GeoTools (8.2). I was able to create shp from asc file which contains my data.

Is there a simple way to create (interpolate) a simple shapefile (only points) to raster image?

1

1 Answer 1

3

You can use the Barnes Surface process using code like this:

public GridCoverage2D interpolate(SimpleFeatureCollection features, String value) {
    Name pName = new NameImpl("vec", "BarnesSurface");
    org.geotools.process.Process process = Processors.createProcess(pName);

    ProcessExecutor engine = Processors.newProcessExecutor(2);

    ReferencedEnvelope bounds = features.getBounds();
    double aspectRatio = bounds.getHeight() / bounds.getWidth();
    int width = 1000;
    int height = (int) (aspectRatio * width);
    Map<String, Object> input = new KVP("data", features, "valueAttr", value, "scale", 1000, "queryBuffer", 1000,
        "outputBBOX", bounds, "outputWidth", width, "outputHeight", height);

    Progress working = engine.submit(process, input);

    Map<String, Object> result = null;
    try {
      result = working.get();
    } catch (InterruptedException | ExecutionException e) {
      e.printStackTrace();
    } // get is BLOCKING

    return (GridCoverage2D) result.get("result");
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.