NetTopologySuite / NetTopologySuite.IO.ShapeFile

The ShapeFile IO module for NTS.
35 stars 25 forks source link

ShapefileStreamProviderRegistry does ProjectionStream get used? #29

Open mattfung opened 4 years ago

mattfung commented 4 years ago

Hello, Thanks for open sourcing this library.

I've been trying to open a shapefile in memory via ShapefileStreamProviderRegistry. The shapefile has .prj file, but the resultant ShapefileDataReader does not seem to have the CRS info present in the projection file. In fact, the Geometry field of the ShapefileDataReader instance is null (opening the shapefile using filepath also created a datareader with null geometry as well).

Browsing through the source code, I'm not able to find a place where ProjectionStream field of the StreamProviderRegistry is used, I'm wondering if the projection stream is read when opening the file?

Best,

mattfung commented 4 years ago

Test file:

issue_29_sample.shp.zip

When running the following:

var geomFactory = new GeometryFactory();
var shapeFileLocal = new ShapefileDataReader(SHP_PATH, geomFactory);

shapeFileLocal has a null geometry field. As well, the attribute has SRID=0.


ogrinfo of the shape file returns:

INFO: Open of `issue_29_sample.shp'
      using driver `ESRI Shapefile' successful.

Layer name: issue_29_sample
Metadata:
  DBF_DATE_LAST_UPDATE=2020-01-20
Geometry: Polygon
Feature Count: 1
Extent: (618170.544319, 5124782.085875) - (618348.422460, 5124959.936131)
Layer SRS WKT:
PROJCS["WGS_1984_UTM_Zone_18N",
    GEOGCS["GCS_WGS_1984",
        DATUM["WGS_1984",
            SPHEROID["WGS_84",6378137,298.257223563]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-75],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["Meter",1],
    AUTHORITY["EPSG","32618"]]
Field1: String (50.0)
Field2: String (50.0)

which shows projection information

Assistance will be appreciated.

kjeremy commented 4 years ago

I am seeing something similar. If I use a ShapeDataReader though I can get at the geometry but can't find anything about the projection. Did you solve this?

mattfung commented 4 years ago

@kjeremy Nope, I wasn't framework bound so ended up using python (fiona + geoalchemy)..

KubaSzostak commented 3 months ago

Hi @mattfung, do you need more support on this issue? If so, provide further details, please.