ckan / ckanext-geoview

CKAN Geospatial ResourceView
MIT License
43 stars 58 forks source link

Shapefiles show as line on the top of maps, the .prj file seems not to be read #91

Closed ghost closed 2 years ago

ghost commented 2 years ago

It appears all shapefiles I upload as a collection of files inside a zip file are rendered as a line at the top of the basemap: image

This is regardless of the projection set using QGIS and stored in the accompanying .prj file.

Steps to reproduce

  1. Create two ESRI shapefiles: one with an EPSG 4326 projection and an EPSG 28992 projection
  2. Zip the .shp, .dbf, .prj, .shx and .cpg files (attached below)
  3. Upload the zip files to CKAN, make sure the format of the resources is set to "SHP"
  4. Create a Shapefile view for each resource

I've attached two testfiles in case this helps with reproducing the issue. pc4-4326.zip pc4-28992.zip

Expected result: The shapefile is shown on a basemap. Actual result: A single line is shown in the top of the basemap

Things I've tried without any noticeable result

Things I've tried with limited result

Versions

Thank you very much for any support in advance!

ghost commented 2 years ago

Sorry for raising this issue, it turns out the problem was with how I created the .shp files. They were not actually projected into EPSG 4326, their .prj file just said so. The data itself was still in EPSG 28992.

After fixing that issue the plugin works as expected.

I did find out that, in case of a non EPSG 4326 projection, the .prj file has to contain a PROJ.4 definition instead of an ESRI WKT which QGIS creates by default.

So instead of:

$ cat map.prj
PROJCS["RD_New",GEOGCS["GCS_Amersfoort",DATUM["D_Amersfoort",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Double_Stereographic"],PARAMETER["False_Easting",155000.0],PARAMETER["False_Northing",463000.0],PARAMETER["Central_Meridian",5.38763888888889],PARAMETER["Scale_Factor",0.9999079],PARAMETER["Latitude_Of_Origin",52.1561605555556],UNIT["Meter",1.0]]

It should be:

$ cat map.prj
+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725 +units=m +no_defs 

QGIS always creates the .prj file in the ESRI WKT format, but there are tools available that can convert that programmatically (or you can look it up on epsg.io).