Resolve shapefile projections

55 views
Skip to first unread message

Jaak Laineste

unread,
Jun 15, 2013, 1:56:56 AM6/15/13
to geo...@opengeo.org
Hello,

I tried some basic things with geogit (0.2.0), and ran into projection issue with own shapefile. The documentation seems not to cover how geogit handles projections. Specifically:
 1. I would like to set projection during import, especially useful for shp files which may or may not have usable .prj file
 2. I guess projection is not stored in object (node) level, but stored as general hidden datastore parameter. There is no handling of rare edge cases where update has projection change?

In my case I have following prj file:
PROJCS["WGS_84_Pseudo_Mercator",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator"],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],PARAMETER["standard_parallel_1",0.0]]

From the exception it seems that geogit (or maybe geotools?) tries to interpret it as "EPSG:WGS_84_Pseudo_Mercator" which fails. I know from OSM and Spatialite sources you have EPSG code easily, but figuring it out from the .prj file where EPSG authority could not be given explitly is not really a trivial task, and with custom projections it would not be possible at all.

Workaround seems to be to remove .prj file before import of shapefile.

Jaak

ps. the exception:
java.lang.RuntimeException: org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:WGS_84_PSEUDO_MERCATOR" from authority "European Petroleum Survey Group" found for object of type "CoordinateReferenceSystem".
at org.geogit.storage.datastream.FormatCommon.readAttributeType(FormatCommon.java:341)
at org.geogit.storage.datastream.FormatCommon.readAttributeDescriptor(FormatCommon.java:357)
at org.geogit.storage.datastream.FormatCommon.readFeatureType(FormatCommon.java:306)
at org.geogit.storage.datastream.FormatCommon.readFeatureType(FormatCommon.java:297)
at org.geogit.storage.datastream.ObjectReader.readData(ObjectReader.java:43)
at org.geogit.storage.datastream.ObjectReader.read(ObjectReader.java:28)
at org.geogit.storage.datastream.ObjectReader.read(ObjectReader.java:23)
at org.geogit.storage.AbstractObjectDatabase.get(AbstractObjectDatabase.java:126)
at org.geogit.storage.AbstractObjectDatabase.getIfPresent(AbstractObjectDatabase.java:84)
at org.geogit.storage.bdbje.JEStagingDatabase.get(JEStagingDatabase.java:164)
at org.geogit.storage.CachingObjectDatabaseGetInterceptor.invoke(CachingObjectDatabaseGetInterceptor.java:36)
at org.geogit.api.plumbing.RevObjectParse.call(RevObjectParse.java:93)
at org.geogit.api.plumbing.DiffFeature.call(DiffFeature.java:82)
at org.geogit.cli.porcelain.FullDiffPrinter.print(DiffPrinter.java:136)
at org.geogit.cli.porcelain.Diff.runInternal(Diff.java:111)
at org.geogit.cli.AbstractCommand.run(AbstractCommand.java:32)
at org.geogit.cli.GeogitCLI.execute(GeogitCLI.java:329)
at org.geogit.cli.GeogitCLI.processCommand(GeogitCLI.java:263)
at org.geogit.cli.GeogitCLI.main(GeogitCLI.java:216)
Caused by: org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:WGS_84_PSEUDO_MERCATOR" from authority "European Petroleum Survey Group" found for object of type "CoordinateReferenceSystem".
at org.geotools.referencing.factory.AbstractAuthorityFactory.noSuchAuthorityCode(AbstractAuthorityFactory.java:951)
at org.geotools.referencing.factory.epsg.DirectEpsgFactory.toPrimaryKey(DirectEpsgFactory.java:886)
at org.geotools.referencing.factory.epsg.DirectEpsgFactory.toPrimaryKeyCRS(DirectEpsgFactory.java:1865)
at org.geotools.referencing.factory.epsg.DirectEpsgFactory.createCoordinateReferenceSystem(DirectEpsgFactory.java:1885)
at org.geotools.referencing.factory.BufferedAuthorityFactory.createCoordinateReferenceSystem(BufferedAuthorityFactory.java:783)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:801)
at org.geotools.referencing.factory.BufferedAuthorityFactory.createCoordinateReferenceSystem(BufferedAuthorityFactory.java:783)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:801)
at org.geotools.referencing.factory.FallbackAuthorityFactory.createCoordinateReferenceSystem(FallbackAuthorityFactory.java:640)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:801)
at org.geotools.referencing.factory.ThreadedAuthorityFactory.createCoordinateReferenceSystem(ThreadedAuthorityFactory.java:731)
at org.geotools.referencing.DefaultAuthorityFactory.createCoordinateReferenceSystem(DefaultAuthorityFactory.java:179)
at org.geotools.referencing.CRS.decode(CRS.java:489)
at org.geogit.storage.datastream.FormatCommon.readAttributeType(FormatCommon.java:335)
... 18 more

Victor Olaya

unread,
Jul 8, 2013, 9:28:44 AM7/8/13
to geo...@opengeo.org
Hi Jaak

Sorry for the late reply. I remember having found this same problem when handling the authorities, and I was sure I had fixed it (see [1]) A closer looks shows that I did...but apparently only for the text serializer... :-(  I will try to add a similar fix for the datastream package, and that should fix the problem when storing CRS's like yours.

Thanks for your help!
Victor


Victor Olaya

unread,
Sep 3, 2013, 12:33:55 PM9/3/13
to geo...@opengeo.org
Hi Jaak

This should already be fixed in 0.4. Did you have time to check it and can you confirm that the issue is solved?

Thanks in advance for your help.

Victor
Reply all
Reply to author
Forward
0 new messages