[Geoserver-users] How to know in a coordinate (x, y) is into a ascii grid file

Hello,
I'm a beginner in using asc grid and geotools library. I'm developing some
processes in java and I would understand the way to know if a generic
coordinate (x,y) is inside the asc file using geotools libraries.
Thanks in advance for any help you will give me.
Sandro

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/How-to-know-in-a-coordinate-x-y-is-into-a-ascii-grid-file-tp5138303.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Hi Sandro,
it think you can have a better answer in the GeoTools mailing list.
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Anyway, I guess you can get the envelope of the grid and check the
coordinates on it.

  File file = new File("/home/xxx/grid.asc");
  AbstractGridFormat format = GridFormatFinder.findFormat(file);
  reader = format.getReader(file);

  GridCoverage2D coverage = reader.read(null);
  Envelope2D envelope = coverage.getEnvelope2D(); // the envelope

  DirectPosition2D point_to_check = new DirectPosition2D ( x , y ); //
your coordinates

  boolean is_inside = envelope.contains(point_to_check); // check if
point is inside the envelope

Regards
Lorenzo Pini
Software Engineer

==
Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

On Fri, May 2, 2014 at 4:56 PM, spresta73 <sandro.presta@anonymised.com> wrote:

Hello,
I'm a beginner in using asc grid and geotools library. I'm developing some
processes in java and I would understand the way to know if a generic
coordinate (x,y) is inside the asc file using geotools libraries.
Thanks in advance for any help you will give me.
Sandro

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/How-to-know-in-a-coordinate-x-y-is-into-a-ascii-grid-file-tp5138303.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos. Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users