NetTopologySuite / NetTopologySuite.IO.Esri

BSD 3-Clause "New" or "Revised" License
35 stars 18 forks source link

Can you read .prj to create SpatialReference? #56

Open soba-noodle opened 1 week ago

soba-noodle commented 1 week ago

In order to use the polygon geometry in shapefile, you have to know the (projection spatial reference) in order to translate shapefile coordinates to WGS84. Can you point me a way to read .prj to create a spatial reference? Thanks.

KubaSzostak commented 1 week ago

I've created a sample code that demonstrates how to read the .prj file and create a spatial reference for transforming shapefile coordinates to WGS84. You can find the implementation here. Let me know if you need any further assistance.

soba-noodle commented 1 week ago

Thanks for your quick reply.

My shapefile projection is shapefile.Projection (created in ArcGISPro). PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]

var transformation = transformationFactory.CreateFromCoordinateSystems(sourceCs, targetCs); throws exception: 'Projection Mercator_Auxiliary_Sphere is not supported. I'm really surprised by this exception.

Thanks.

Tosa

On Sat, Sep 7, 2024 at 4:28 AM Kuba Szostak @.***> wrote:

I've created a sample code that demonstrates how to read the .prj file and create a spatial reference for transforming shapefile coordinates to WGS84. You can find the implementation here https://github.com/NetTopologySuite/NetTopologySuite.IO.Esri/blob/develop/test/NetTopologySuite.IO.Esri.Test/Issues/Issue056.cs. Let me know if you need any further assistance.

— Reply to this email directly, view it on GitHub https://github.com/NetTopologySuite/NetTopologySuite.IO.Esri/issues/56#issuecomment-2335117108, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMZ36QSB7EVYAE6FQ5SZWTTZVK2JLAVCNFSM6AAAAABNRILVFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZVGEYTOMJQHA . You are receiving this because you authored the thread.Message ID: @.*** com>