Thanks!

On Sun, Jan 7, 2024 at 4:32 PM Martin Desruisseaux <
[email protected]> wrote:

> Hello Gary, and welcome!
>
> Le 2024-01-07 à 22 h 00, Gary Lucas a écrit :
>
> > I am working on a Java application which develops an elevation data
> > raster product that I would like to store in a GeoTIFF file. Some of
> > my input data comes from shapefiles with associated .prj files. I
> > would like to be able to extract relevant information from the .prj
> > files and use it to populate GeoTIFF tags for output.
> >
> The easiest way would be:
>
>     import org.apache.sis.referencing.CRS;
>
>     CoordinateReferenceSystem crs = CRS.fromWKT(wkt);
>
> However, the Shapefile format uses an old WKT version, which sometime
> agrees with the standard expected by above method, and sometime not. So
> a safer approach is to set explicitly the expected WKT variant:
>
>     import org.apache.sis.io.wkt.WKTFormat;
>
>     var parser = new WKTFormat(null, null);
>     parser.setConvention(Convention.WKT1_COMMON_UNITS);
>     var crs = (CoordinateReferenceSystem) parser.parseObject(wkt);
>
>
> > Can someone point me toward example code I could look at or maybe a
> > general outline of the steps for doing so? I have been looking through
> > the documentation, but need a place to start.
> >
> There is a "how to" page at https://sis.apache.org/howto.html - but of
> course it needs more examples. For the next step (getting the EPSG code
> to write in a GeoTIFF), see the "Get the EPSG code or URN of an existing
> CRS" item.
>
>
> > Some of my sources come with EPSG codes that I can use to populate the
> > GeoTIFF ProjectedCrsGeoKey (GeoTiff spec section 6.3.3.1). However,
> > others carry general datum and map-projection parameters, so I would
> > have to populate multiple GeoTIff elements. A few of my data sources
> > are in geographic coordinate systems.
> >
> When the EPSG code is sufficient, above should help. When datum and
> other properties needs to be written, this is more complicated. Apache
> SIS 1.5 (not yet released, but available on snapshot repository) will
> have a GeoTIFF writer, but if you prefer doing the work on your side,
> the class `org.apache.sis.storage.geotiff.writer.GeoEncoder` class may
> be used as a source of inspiration, in particular the
> `writeCRS(GeodeticCRS)` and `writeCRS(ProjectedCRS)` method:
>
>
> https://github.com/apache/sis/blob/2330bb247ded208d8722cbb88753310cd9b0bd68/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/writer/GeoEncoder.java#L364
>
> Please let us know if there is any issue.
>
>      Martin
>
>

Reply via email to