Hello,

I'm new to GIS world and I'm having some trouble trying to crop and
reproject one covegare read from a tiff raster.

I have two input files:

* europe_laea which is a population raster of europe with the following CRS;
   - ETRS_1989_LAEA_L52_M10
   - GridEnvelope2D[0..50499, 0..43699]
   - GeneralEnvelope[(1500000.0, 940000.0), (6550000.0, 5310000.0)]
   - ReferencedEnvelope[1500000.0 : 6550000.0, 940000.0 : 5310000.0]

* ESP_adm0.shp which is a shape file containig Spain borders geometry with
the following CRS:
   - GCS_WGS_1984
   - ReferencedEnvelope[-18.161527633666935 : 4.328195095062224,
27.63736152648937 : 43.791526794433636]
   - ReferencedEnvelope[1544707.3832030324 : 3863890.051557834,
544966.971622494 : 2721615.01105987]

After reading the geotools user guide and trying several ways to accomplish
this task I didn't managed to do it. This is the most basic way I can think
of doing it, could you please hint me what is wrong with it?


File europe_path = new File("europe_laea.tif");

AbstractGridFormat format = GridFormatFinder.findFormat(europe_path);
GridCoverage2DReader reader = format.getReader(europe_path);

GridCoverage2D europe_laea = reader.read(null);

CoordinateReferenceSystem europe_CRS = europe_laea.
getCoordinateReferenceSystem();
Envelope europe_extent = europe_laea.getEnvelope2D();

// Load Spain borders
File spain_border_path = new File("ESP_adm0.shp");
FileDataStore dataStore = FileDataStoreFinder.getDataStore(spain_border_
path);
SimpleFeatureSource spain_border = dataStore.getFeatureSource();

// Transform Spain Borders to Europe CRS
ReferencedEnvelope spain_border_laea =
spain_border.getBounds().transform(europe_CRS,
true);

// Crop Europe to Spain envelope
GridCoverage2D crop_laea = (GridCoverage2D)
Operations.DEFAULT.crop(europe_laea,
spain_border_laea);

// Reproject Europe to Spain
CoordinateReferenceSystem wgs84 = spain_border.getBounds().
getCoordinateReferenceSystem();
GridCoverage2D spain = (GridCoverage2D) Operations.DEFAULT.resample(crop_laea,
wgs84);

GeoTiffWriter writer = new GeoTiffWriter(new File("spain_wgs84.tiff"));
writer.write(spain, null);


When I write out crop_laea it works as expected but with the resampled
coverage it hangs forever.

Thanks in advance.
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to