citygml4j / citygml-tools

Collection of tools for processing CityGML files
Apache License 2.0
115 stars 18 forks source link

No transformation available: JGD2011 + JGD2011 (vertical) height #22

Closed imakihi closed 3 years ago

imakihi commented 3 years ago

Hi there. I used citygml-tools to convert various CityGML data to CityJson. I am dealing with mainly Japanese building data and the CRSs are usually based on JGD2011. So, when I tried to reproject my Japanese data to a different CRS, I get following error message. I am guessing that the JGD2011 is missing from the library. PROJ 7.2.0 includes the Japanese GSIGEO2011 geoid (https://www.osgeo.org/foundation-news/announce-release-of-proj-7-2-0-and-proj-data-1-3/).

Is there anyway you can include JGD2011 to reproject Japanese data to a different projection?

Thank you!!

Hiroo

[12:03:39 INFO] Starting citygml-tools. [12:03:39 INFO] Initializing application environment. [12:03:40 INFO] Executing command 'reproject'. [12:03:40 INFO] Found 1 file(s) at 'data\53393330_bldg_6697_op2.gml'. Aug 03, 2021 12:03:40 PM org.hsqldb.persist.Logger logInfoEvent INFO: dataFileCache open start [12:03:40 INFO] [1|1] Processing file 'C:\Users\hiroo\Downloads\citygml-tools-master\build\install\citygml-tools\data\53393330_bldg_6697_op2.gml'. [12:03:40 INFO] Writing output to file 'C:\Users\hiroo\Downloads\citygml-tools-master\build\install\citygml-tools\data\53393330_bldg_6697_op2_reprojected.gml'. [12:03:42 ERROR] The following unexpected error occurred during execution. picocli.CommandLine$ExecutionException: Error while calling command (org.citygml4j.tools.command.ReprojectCommand@23faf8f2): java.lang.RuntimeException: Failed to transform coordinates. at picocli.CommandLine.executeUserObject(CommandLine.java:1962) at picocli.CommandLine.access$1300(CommandLine.java:145) at picocli.CommandLine$RunAll.recursivelyExecuteUserObject(CommandLine.java:2422) at picocli.CommandLine$RunAll.recursivelyExecuteUserObject(CommandLine.java:2424) at picocli.CommandLine$RunAll.handle(CommandLine.java:2419) at picocli.CommandLine$RunAll.handle(CommandLine.java:2383) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179) at org.citygml4j.tools.CityGMLTools.process(CityGMLTools.java:131) at org.citygml4j.tools.CityGMLTools.main(CityGMLTools.java:87) Caused by: java.lang.RuntimeException: Failed to transform coordinates. at org.citygml4j.tools.reproject.Reprojector.transform(Reprojector.java:334) at org.citygml4j.tools.reproject.Reprojector.reproject(Reprojector.java:129) at org.citygml4j.tools.command.ReprojectCommand.call(ReprojectCommand.java:149) at org.citygml4j.tools.command.ReprojectCommand.call(ReprojectCommand.java:51) at picocli.CommandLine.executeUserObject(CommandLine.java:1953) ... 8 more Caused by: org.citygml4j.tools.reproject.ReprojectionException: Failed to find a transformation. at org.citygml4j.tools.reproject.util.CRSUtil.getTransformation(CRSUtil.java:120) at org.citygml4j.tools.reproject.Reprojector.transform(Reprojector.java:308) ... 12 more Caused by: org.opengis.referencing.operation.OperationNotFoundException: No transformation available from system "CompoundCRS[JGD2011 + JGD2011 (vertical) height]" to "GeographicCRS[WGS 84]". at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:210) at org.geotools.referencing.operation.BufferedCoordinateOperationFactory.createOperation(BufferedCoordinateOperationFactory.java:233) at org.geotools.referencing.CRS.findMathTransform(CRS.java:1266) at org.citygml4j.tools.reproject.util.CRSUtil.getTransformation(CRSUtil.java:118) ... 13 more [12:03:42 WARN] citygml-tools execution failed.

clausnagel commented 3 years ago

The error message says:

No transformation available from system "CompoundCRS[JGD2011 + JGD2011 (vertical) height]" to "GeographicCRS[WGS 84]"

So, it seems that JGD2011 is supported but it cannot be transformed to WGS 84. Maybe the reason is that JGD2011 is a 3D system and WGS 84 is just 2D?! Have you tried to use WGS 84 3D as target system instead (EPSG code 4329, see here)?

If this doesn't help, could you please provide a snippet of your dataset so that we can try and reproduce the issue? And also post the full command line that you use to invoke citygml-tools.

imakihi commented 3 years ago

Hi @clausnagel Thank you for getting back to me. I tried the transformation with EPSG:4329 but I got following messages.

citygml-tools reproject --target-crs=4329 data\53393330_bldg_6697_op2.gml [16:22:58 INFO] Starting citygml-tools. [16:22:58 INFO] Initializing application environment. [16:22:59 INFO] Executing command 'reproject'. [16:22:59 INFO] Found 1 file(s) at 'data\53393330_bldg_6697_op2.gml'. Aug 09, 2021 4:22:59 PM org.hsqldb.persist.Logger logInfoEvent INFO: dataFileCache open start [16:22:59 ERROR] The following unexpected error occurred during execution. picocli.CommandLine$ExecutionException: Error while calling command (org.citygml4j.tools.command.ReprojectCommand@23faf8f2): org.geotools.referencing.wkt.UnformattableObjectException: This "GeographicCRS" object is too complex for WKT syntax. at picocli.CommandLine.executeUserObject(CommandLine.java:1962) at picocli.CommandLine.access$1300(CommandLine.java:145) at picocli.CommandLine$RunAll.recursivelyExecuteUserObject(CommandLine.java:2422) at picocli.CommandLine$RunAll.recursivelyExecuteUserObject(CommandLine.java:2424) at picocli.CommandLine$RunAll.handle(CommandLine.java:2419) at picocli.CommandLine$RunAll.handle(CommandLine.java:2383) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179) at org.citygml4j.tools.CityGMLTools.process(CityGMLTools.java:131) at org.citygml4j.tools.CityGMLTools.main(CityGMLTools.java:87) Caused by: org.geotools.referencing.wkt.UnformattableObjectException: This "GeographicCRS" object is too complex for WKT syntax. at org.geotools.referencing.wkt.Formattable.toWKT(Formattable.java:190) at org.geotools.referencing.wkt.Formattable.toWKT(Formattable.java:158) at org.geotools.referencing.wkt.Formattable.toWKT(Formattable.java:114) at org.geotools.referencing.wkt.Formattable.toWKT(Formattable.java:96) at org.citygml4j.tools.reproject.Reprojector.getTargetCRSAsWKT(Reprojector.java:104) at org.citygml4j.tools.command.ReprojectCommand.call(ReprojectCommand.java:112) at org.citygml4j.tools.command.ReprojectCommand.call(ReprojectCommand.java:51) at picocli.CommandLine.executeUserObject(CommandLine.java:1953) ... 8 more [16:22:59 WARN] citygml-tools execution failed.

I attached my date. I zipped the gml file.

Thank you so much for your help.

Hiroo 53393330_bldg_6697_op2.zip

clausnagel commented 3 years ago

Thanks for providing the test dataset. After doing some tests, it actually seems that that the source CRS EPSG:6697 is indeed not sufficiently supported by the GeoTools library, which is used in the background for coordinate transformation.

So I tested with EPSG:6668 as source CRS instead, which is the horizontal component of EPSG:6697. When trying to convert this to WGS 84 (EPSG:4328), GeoTools throws another error that the Bursa-Wolf parameters for performing the datum shift are missing. A quick fix for this is to use the option --lenient-transform to simply ignore this error. With these settings, the reproject command runs successfully:

$ citygml-tools reproject --source-crs=6668 --target-crs=4326 --lenient-transform /path/to/53393330_bldg_6697_op2.gml

But in the end, the coordinate values remain the same. EPSG:6697 obviously also uses geographic coordinates. You could additionally use --target-force-xy to swap the axis order if required.

imakihi commented 3 years ago

Hi @clausnagel Thank you so much for spending time to figure this out. I tested your approach and I could show my data in QGIS! As you suggested, I needed to use --target-force-xy option.

citygml-tools reproject --source-crs=6668 --target-crs=2451 --lenient-transform --target-force-xy data/53393330_bldg_6697_op2.gml

Just curiosity, how GeoTools library can fully support EPSG:6697? Should I ask the GeoTools community? Do you know someone who can help on this matter??

Thank you again!!

Hiroo

2021-08-11_21-31-43
clausnagel commented 3 years ago

Thanks for your feedback, @imakihi, and great to see that you can load your data with QGIS now.

Regarding GeoTools, I would suggest getting in contact with the community via their users list. Check out this website for useful links: https://geotools.org/getinvolved.html