|
From: Sunela M. <Mar...@fc...> - 2010-10-07 07:14:08
|
Simone,
So I have various maps in geotiff format. Usually the coordinate system used in the maps I use is the old Finnish Uniform coordinate system (EPSG:2393). These maps are available for whole Finland, but they come in tiles. The size of the tile depends, of course, on the scale of the map. The address map used in the example has a tile size of roughly 10 km x 10 km and pixel size of 10000 x 10000. In order to have a map for certain area it's necessary to combine several tiles.
Now my data itself can be in almost every coordinate system: ETRS89, WGS84, old Finnish systems etc. I store and plot the data separately. I only use GeoTools to do various transformations, and mainly to plot the background map in the coordinate system of the actual data. I plot the background map into BufferImages of size 400 x 400 px in separate thread to speed up panning and zooming the map -- kind of a Google maps like effect.
So the whole procedure is as follows:
// First a map context in constructed
crs = CRS.decode("EPSG:2392"); // Coordinate system depends on the actual data
mapContext = new DefaultMapContext(crs);
mapContext.setTitle("Background maps");
// Then user can add various background maps to the context
// via UI. Background map can be a shape file or geotiff or
// what ever GeoTools supports
AbstractGridFormat format = GridFormatFinder.findFormat(file);
AbstractGridCoverage2DReader reader = format.getReader(file, hints);
[...]
mapContext.addLayer(reader, style);
[...]
// Different map tile
mapContext.addLayer(reader, style);
[...]
// Different map tile
mapContext.addLayer(reader, style);
// Now there are, for example, three GeoTiffs covering a certain area
// Then the actual plotting of the background map in separate thread
// The corners of the tile to be plotted (in CRS of the data)
double x1, y1, x2, y2;
BufferedImage image = [...]
Graphics2D g = image.createGraphics();
StreamingRenderer renderer = new StreamingRenderer();
renderer.setContext(mapContext);
renderer.paint(g, new Rectangle(0, 0,
image.getWidth(),
image.getHeight()),
new ReferencedEnvelope(y1, y2, x1, x2,
mapContext.getCoordinateReferenceSystem()));
// Notify the UI that a new image is available
[...]
Then I just plot all the images side by side in the UI view and plot my data model on top of it. I am not sure if this is the bast way to do it, but this works perfectly with shape files and also with geotiffs that happen to be in the same coordinate reference system as my data. The only problem so far is that the method produces borders when it is necessary to do transformations for the geotiffs.
Thank you very much for any hints!
Markus
________________________________
From: sim...@gm... [mailto:sim...@gm...] On Behalf Of Simone Giannecchini
Sent: Thursday, October 07, 2010 2:44 AM
To: Sunela Markus
Cc: geo...@li...
Subject: Re: [Geotools-gt2-users] How to change border color used when transforming geotiff?
Dear Markus,
we have added the aforementioned parameter lately therefore it is not well documented yet (daniele can you please provide some info?).
Aside, I think that your problem requires a different solution since if you reproject the single images separately you will still get a bad result even if you manage to
tweak the bkg color. What you need is to mosaic the images in their original CRS and then reproject the entire thing afterwards. This way you would not get this annoying effect at the edges.
In order to be more specific I would need a bit more info about what you are doing.
Regards,
Simone.
-------------------------------------------------------
===
Notice that our office phone number has recently changed!
Please, update your records!
===
Ing. Simone Giannecchini
GeoSolutions S.A.S.
Founder
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584962313
fax: +39 0584962313
mob: +39 333 8128928
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/simonegiannecchini
http://twitter.com/simogeo
-------------------------------------------------------
On Wed, Oct 6, 2010 at 1:55 PM, Sunela Markus <Mar...@fc...<mailto:Mar...@fc...>> wrote:
Hello,
In my project I need to render a map that consists of several GeoTiff-files, which are in EPSG:2393, in EPSG:2392. While GeoTools makes the transformation fine, but it leaves black or brown (value 0.0) borders around the geotiffs when rendering. The transformation involves rotating the geotiffs. Because of this, the single geotiffs have very large and visible seams instead of forming a nice and continuous map.
This is illustrated in the attached picture with two different geotiffs (different maps altogether) used as a background. I render the map context with different geotiffs added as layers in pieces of 400x400 px which are stored in a cache.
Is there a way to change how the borders are handled? Preferrably the renderer should draw only the existing data or draw the borders with full transparency.
I noticed that there is Resample.BACKGROUND_VALUES hint in org.geotools.coverage.processing.operation. Is it the right thing to use and how can I pass it to the rendering pipeline?
Thank you very much,
Markus
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Geotools-gt2-users mailing list
Geo...@li...<mailto:Geo...@li...>
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
|