Ian and Mark,
Thank you for the help. I, finally, managed to set the correct crs using hints.
The correct use of hints for the reader is like this:
Hints hints = new Hints(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM, crs);
ArcGridReader ascReader = new ArcGridReader(url, hints); Cheers,
Yared
-----------------------------------------------------------------PhD Research
Fellow in Urban Water SystemsEnvironmental Engineering and Water Technology
DepartmentUNESCO-IHE Institute for Water EducationWestvest 7 - P.O.Box 3015
2601 DA Delft, The Netherlands
On Tuesday, March 22, 2016 6:30 PM, Ian Turton <ijtur...@gmail.com> wrote:
If you are sure that the answer should be UTM20N then use something like:
CoordinateReferenceSystem crs = CRS.decode("EPSG:32620");
Otherwise you need to check that file2.tif has a CRS set and the coverage
reader is fetching it correctly.
Ian
On 22 March 2016 at 16:36, <yared...@yahoo.com> wrote:
This is what I was doing, but not successful!
URL url = null;
try {
url = new File("file1.asc").toURL();
} catch (MalformedURLException e1) {
e1.printStackTrace();
} // read this file to get the exact crs
File file = new File("data/file2.tif");
AbstractGridFormat format = GridFormatFinder.findFormat(file);
GridCoverage2DReader tiffReader = format.getReader(file);
GridCoverage2D coverage = tiffReader.read(null);
CoordinateReferenceSystem crs =
coverage.getCoordinateReferenceSystem2D();
Hints hints = new Hints(Hints.CRS, crs);
ArcGridReader ascReader = new ArcGridReader(url, hints);
if (reader != null) {
GridCoverage2D ascCoverage = (GridCoverage2D) ascReader.read(null);
ascCoverage.geophysics(true);
File tiffFile = new File("file3.tif");
if (tiffFile .exists())
tiffFile .delete();
GeoTiffWriter tiffWriter = new GeoTiffWriter(tiffFile);
tiffWriter .write(ascCoverage, null);
Where should I set the crs?
Yared
-----------------------------------------------------------------PhD Research
Fellow in Urban Water SystemsEnvironmental Engineering and Water Technology
DepartmentUNESCO-IHE Institute for Water EducationWestvest 7 - P.O.Box 3015
2601 DA Delft, The Netherlands
On Tuesday, March 22, 2016 4:05 PM, Mark Prins <mc.pr...@gmail.com> wrote:
On 22-03-16 15:14, yared...@yahoo.com wrote:
> I have these jars under the class path - gt-epsg-hsql and get-referencing
that sounds right.
You can pass in a Hints object that has a CRS Hint, see:
https://github.com/geotools/geotools/blob/master/modules/plugin/arcgrid/src/main/java/org/geotools/gce/arcgrid/ArcGridReader.java#L134-L151
HTH, Mark
>
> Yared
> -----------------------------------------------------------------
> PhD Research Fellow in Urban Water Systems
> Environmental Engineering and Water Technology Department
> UNESCO-IHE Institute for Water Education
> Westvest 7 - P.O.Box 3015
> 2601 DA Delft, The Netherlands
>
>
>
> On Tuesday, March 22, 2016 2:50 PM, Mark Prins <mc.pr...@gmail.com> wrote:
>
>
> do you have a referencing jar as a dependency in your pom? see:
> http://docs.geotools.org/latest/userguide/library/referencing/index.html
>
> 2016-03-22 14:15 GMT+01:00 <yared...@yahoo.com <mailto:yared...@yahoo.com>>:
>
> Hi all,
>
> I'm trying to read esri ascii file (using ArcGridReader), and write
> to geotiff (using GeoTiffWriter). However, the reader could not find
> the crs and hence used the default crs, and at the end, when i write
> the geotiff, I get an error:
>
> Caused by:
> org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffException:
> GEOTIFF Module Error Report
> The supplied grid coverage uses an unsupported crs! You are allowed
> to use only projected and geographic coordinate reference systems
> ModelPixelScaleTag: NOT AVAILABLE
> ModelTiePointTag: NOT AVAILABLE
> ModelTransformationTag: NOT AVAILABLE
>
> The question is, how can I set the crs of the coverage that I get
> from the reader?
>
> PS: The ascii file supposed to have UTM20 projection.
> I really appreciate any help!
> Yared
> -----------------------------------------------------------------
> PhD Research Fellow in Urban Water Systems
> Environmental Engineering and Water Technology Department
> UNESCO-IHE Institute for Water Education
> Westvest 7 - P.O.Box 3015
> 2601 DA Delft, The Netherlands
>
>
>
>------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> <mailto:GeoTools-GT2-Users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
>
>
> --
> Disclaimer;
> This message is just a reflection of what I thought at the time of
> sending. The message may contain information that is not intended for
> you or that you don't understand.
>
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
>
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> <mailto:GeoTools-GT2-Users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
--
Ian Turton
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users