1

I'm very new to GIS and GeoTools too. I'm upgrading org.geotools dependencies of a Maven project from 2.7.0 to 15.2. I got a compilation error about VectorToRasterFactory, It looks like there is no VectorToRasterFactory in the newest libraries. I didn't found any docs about how to substitute this class or how to get the same features.

UPDATE I upgrade the libs but I got an issue during runtime. Here is the code:

...
GridCoverage2D cov = null;
try {
    org.geotools.process.Process p = Processors.createProcess(new NameImpl("vec", "VectorToRaster"));
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(AbstractFeatureCollectionProcessFactory.FEATURES.key, srcCollection);
    map.put("attribute", "value");
    map.put("rasterWidth", dimension.width);
    map.put("rasterHeight", dimension.height);
    map.put("bounds", bounds);
    Map<String, Object> result = p.execute(map, monitor);
    cov = (GridCoverage2D) result.get("result");
    return (PlanarImage) cov.getRenderedImage();
} finally {
    if (cov != null)
    cov.dispose(true);
}
...

I can't get a Process instance, Processors.createProces... always returns null.

  • Please edit your question to show your full error. It will help with troubleshooting. – MaryBeth Aug 19 '16 at 14:06
  • @MaryBeth Hello. My error is a compile error due to VectorToRasterFactory is removed in earlier versions. – Francesco Aug 19 '16 at 14:40
  • please show the code you are using – Ian Turton Nov 3 '16 at 15:37
1

It seems not to be needed any longer - the VectorToRasterProcess has moved to the unsupported process-features module. From looking at the unit tests you can just do:

    Process p = Processors.createProcess(new NameImpl("vec", "VectorToRaster"));
    SimpleFeatureCollection features = createPolys();
    ReferencedEnvelope bounds = features.getBounds();

    Dimension gridDim = new Dimension(
            (int)bounds.getWidth(),
            (int)bounds.getHeight());

    String covName = "Test";
    ProgressListener monitor = null;

    GridCoverage2D cov = p.process(
            features, "value", gridDim, bounds, covName, monitor);
|improve this answer|||||
  • hello, I am back on this issue again. Yes this must be the way but I am having some hard times about Processors.createProcess(...). I can't get anything but null. Any hint? – Francesco Nov 3 '16 at 15:29
  • I also edit my question. The geotools version we want to upgrade to is now 15.2. Thanks. – Francesco Nov 3 '16 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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