Thank You Michael.
That solved my problem perfectly. I'm now having an issue with the evaluate
returning 0.0 every time. The following is a simplified version of my code. I
have a latitude, longitude, and value for points that I'm creating a feature
collection with. I then use the VectorToRasterProcess to create my
GridCoverage. I've read through all the documentation and can't seem to figure
out what I'm missing. Again pointing me in the right direction is greatly
appreciated.
-Mike
// Setup CRS
Hints hints = new Hints( Hints.CRS, DefaultEngineeringCRS.CARTESIAN_2D );
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory( hints );
SimpleFeatureType TYPE =
DataUtilities.createType("location","geom:Point,value:Float");
SimpleFeatureCollection collection =
FeatureCollections.newCollection("ExampleSetFeatureCollection");
// Loop and add features
Coordinate coord1 = new Coordinate( currentLat, currentLon);
Point point1 = geometryFactory.createPoint( coord1 );
SimpleFeature feature = SimpleFeatureBuilder.build( TYPE, new Object[]{ point1,
currentDoubleValue.floatValue() }, null );
collection.add( feature );
// Setup for process
ProgressListener progress = new ProgressWindow(null);
Dimension gridDim = new Dimension(1000,1000);
GridCoverage2D gridCoverage = VectorToRasterProcess.process(
collection,
"value",
gridDim,
collection.getBounds(),
"ExampleSetGridCoverage",
progress);
// Create point with known location from my raw data.
DirectPosition point = new DirectPosition2D(DefaultEngineeringCRS.CARTESIAN_2D,
38.969614330552, -121.512359247084);
float[] value = (float[]) gridCoverage.evaluate(point);
// This shows the point to be 0.0 no matter the location I give it.
System.out.println("Known Point: Lat:38.969614330552 Lon:-121.512359247084
value:" + value[0]);
On Mar 29, 2011, at 11:12 PM, Michael Bedward wrote:
> Hi Mike,
>
> It's just Java's typing being a bit painful. A DirectPosition2D
> object is a Point2D object with geospatial extras.
>
> What I usually do use DirectPosition references instead which avoids
> the ambiguity...
>
> DirectPosition pos = new DirectPosition2D(myCRS, x, y);
> dest = cov.evaluate(pos, dest);
>
> The only hassle with this is that you can no longer say pos.x and
> pos.y. Instead you have to say pos.getOrdinate(0) and
> pos.getOrdinate(1) which is clunky.
>
> The other option of course is to explicitly cast...
>
> DirectPosition2D pos = new DirectPosition2D(myCRS, x, y);
> dest = cov.evaluate( (DirectPosition2D)pos, dest);
>
> Your mission is to decide which of these is the least worst :)
>
> Hope that helps,
>
> Michael
>
>
> On 30 March 2011 15:38, Mike O'Toole <[email protected]> wrote:
>> Hello all,
>> I'm brand new to GeoTools. I'm trying to use the evaluate() method on my
>> GridCoverge2D object. However I get a reference to evaluate is ambiguous
>> error.
>> Error:
>> reference to evaluate is ambiguous, both method
>> evaluate(org.opengis.geometry.DirectPosition,double[]) in
>> org.geotools.coverage.AbstractCoverage and method
>> evaluate(java.awt.geom.Point2D,double[]) in
>> org.geotools.coverage.grid.GridCoverage2D match
>>
>> Here is the code snippet:
>> DirectPosition2D nextPoint = new DirectPosition2D(sphericalMercator, x, y);
>>
>> double[] dest = gridCoverage.evaluate(nextPoint, dest);
>>
>> Any help pointing me in the right direction is greatly appreciated and let
>> me know if more information is needed.
>> Thank You,
>> Mike
>> ------------------------------------------------------------------------------
>> Enable your software for Intel(R) Active Management Technology to meet the
>> growing manageability and security demands of your customers. Businesses
>> are taking advantage of Intel(R) vPro (TM) technology - will your software
>> be a part of the solution? Download the Intel(R) Manageability Checker
>> today! http://p.sf.net/sfu/intel-dev2devmar
>> _______________________________________________
>> Geotools-gt2-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>>
------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself;
WebMatrix provides all the features you need to develop and
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users