Hello,
It seems that some informations missed in the (geo)tiff file because I
receive today new ones and the loading works great.
I post below the code to load and display rasters, it may help others.
The (last ?) problem I (still) have is that I get wrong y coordinates. The
x ones seems to be right. It's not a problem to display the rasters alone
but it's a problem to localize and to use rasters with vectors.
Any ideas ?
Jérémy
The meta data shows :
****
Geotiff_Information:
Version: 1
Key_Revision: 1.0
Tagged_Information:
ModelTiepointTag (2,3):
0 0 0
580991 2428891 0
ModelPixelScaleTag (1,3):
1.32291667 1.32291667 0
End_Of_Tags.
Keyed_Information:
GTModelTypeGeoKey (Short,1): ModelTypeProjected
GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
ProjectedCSTypeGeoKey (Short,1): PCS_NTF_France_II
ProjLinearUnitsGeoKey (Short,1): Linear_Meter
End_Of_Keys.
End_Of_Geotiff.
PCS = 27582 (name unknown)
Projection Linear Units: 9001/metre (1.000000m)
Corner Coordinates:
Upper Left ( 580991.000, 2428891.000)
Lower Left ( 580991.000, 2423886.406)
Upper Right ( 585995.594, 2428891.000)
Lower Right ( 585995.594, 2423886.406)
Center ( 583493.297, 2426388.703)
****
and the output (linked to the code) shows :
****
[DEBUG_GeotiffTest] gc.getCoordinateReferenceSystem() >PROJCS["NTF (Paris)
/ France II",
GEOGCS["NTF (Paris)",
DATUM["Nouvelle_Triangulation_Francaise_Paris",
SPHEROID["Clarke 1880 (IGN)", 6378249.2, 293.4660212936269,
AUTHORITY["EPSG","7011"]],
TOWGS84[-168.0, -60.0, 320.0, 0.0, 0.0, 0.0, 0.0],
AUTHORITY["EPSG","6807"]],
PRIMEM["Paris", 2.33722917, AUTHORITY["EPSG","8903"]],
UNIT["grade", 0.015707963267948967],
AXIS["Lon", EAST],
AXIS["Lat", NORTH],
AUTHORITY["EPSG","4807"]],
PROJECTION["Lambert_Conformal_Conic_1SP",
AUTHORITY["OGC","Lambert_Conformal_Conic_1SP"]],
PARAMETER["central_meridian", 0.0],
PARAMETER["latitude_of_origin", 52.0],
PARAMETER["scale_factor", 0.99987742],
PARAMETER["false_easting", 600000.0],
PARAMETER["false_northing", 2200000.0],
UNIT["m", 1.0],
AXIS["x", EAST],
AXIS["y", NORTH],
AUTHORITY["EPSG","27582"]]
[DEBUG_GeotiffTest] gc.getEnvelope() >GeneralEnvelope[580990.3385416666,
-2433894.9322916665, 585994.9322916666, -2428890.3385416665]
[DEBUG_GeotiffTest] xMax >585994.9322916666
[DEBUG_GeotiffTest] yMax >-2428890.3385416665
[DEBUG_GeotiffTest] xMin >580990.3385416666
[DEBUG_GeotiffTest] yMin >-2433894.9322916665
****
public static void testGridCoverage() {
try {
MapContext mapContext = new DefaultMapContext();
StyleBuilder styleBuilder = new StyleBuilder();
// On charge le GridCoverage
GeoTiffReader reader = (GeoTiffReader) ((new
GeoTiffFormat()).getReader(new File(NOM_FICHIER_GEOTIFF)));
GridCoverage gc = reader.read(null);
debug("gc.getCoordinateReferenceSystem() >" +
gc.getCoordinateReferenceSystem());
debug("gc.getEnvelope() >" + gc.getEnvelope());
RasterSymbolizer rs =
styleBuilder.createRasterSymbolizer();
Style s = styleBuilder.createStyle(rs);
Envelope enveloppe = new Envelope(new
Coordinate(gc.getEnvelope().getUpperCorner().getCoordinates()[0],gc.getEnvelope().getUpperCorner().getCoordinates()[1]),
new
Coordinate(gc.getEnvelope().getLowerCorner().getCoordinates()[0],gc.getEnvelope().getLowerCorner().getCoordinates()[1]));
mapContext.addLayer(gc, s);
// Traitement de l'affichage
enveloppe = mapContext.getLayerBounds();
debug("xMax >" + enveloppe.getMaxX());
debug("yMax >" + enveloppe.getMaxY());
debug("xMin >" + enveloppe.getMinX());
debug("yMin >" + enveloppe.getMinY());
double largeur = 500;
double hauteur = 500;
BufferedImage image = new BufferedImage((int) largeur,
(int) hauteur,
BufferedImage.TYPE_INT_ARGB );
LiteRenderer rend = new LiteRenderer(mapContext);
Graphics2D g2d = (Graphics2D) image.getGraphics();
rend.paint(g2d, new Rectangle((int) largeur, (int)
hauteur), enveloppe);
JLabel label = new JLabel();
label.setIcon(new ImageIcon(image));
label.setSize((int) largeur, (int) hauteur);
label.setPreferredSize(new Dimension((int) largeur,
(int) hauteur));
JFrame frame = new JFrame();
frame.add(label, BorderLayout.CENTER);
frame.setTitle(NOM_FICHIER_GEOTIFF);
frame.setSize((int) largeur, (int) hauteur);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
catch (Exception e) {
e.printStackTrace();
}
}
> Jérémy DE ROYER a écrit :
>> Where can I find a tutorial explaining :
>> - how to load the files (geotiff ou tif+tfw)
>
> I can't tell on this one...
>
>> - how to define the projection (for me Lambert2E)
>
> I don't know how to defines a projection in the particular case of the
> GeoTIFF data store. However, there is how to creates a
> CoordinateReferenceSystem object in the general case:
>
> - Connect to an EPSG database. If you have the MS-Access software, you
> can download the database from http://www.epsg.org, register it as an
> ODBC datasource named "EPSG" (uppercase) and make sure that
> gt2-epsg-access.jar is in yours classpath. If you can't or don't want
> to use the MS-Access version, just make sure that hsqldb.jar and
> gt2-epsg-hsql.jar are in yours classpath (an EPSG database in bundled
> into gt2-epsg-hsql.jar).
>
> - Gets the EPSG code for Lambert 2 étendue (I don't know it from memory.
> If you have MS-Access, you can browse the Access database. They have
> nice forms for that).
>
> - Lets suppose that the EPSG code is 4326. You can write the following:
>
> CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
>
> Thats it. An alternative is to express yours CRS in "Well Known Text"
> format and use CRS.parseWKT(theWKT).
>
> There is tutorials on www.geotools.org for that, but unfortunatly they
> seems to have disaspear recently because of a Confluence server update.
> I don't know when they will be back.
>
>
>> I've seen things about GridCoverage (see below) but the loading doesn't
>> work (I receive a "Only Geographic & Projected Systems are supported").
>
> See previous mail. It may be a missing field in the GeoTIFF file, but I
> have the feeling that this field is not essential and that our GeoTIFF
> module could be made more tolerant.
>
> Martin.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users