Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#1487 closed bug (fixed)

QGIS fails to recognise Shapefile projection

Reported by: marisn Owned by: nobody
Priority: major: does not work as expected Milestone: Version 1.2.0
Component: Projection Support Version: 1.2.0
Keywords: Cc: warmerdam, timlinux
Must Fix for Release: No Platform: Gentoo
Platform Version: Awaiting user input: no

Description

When loading shapefile with defined projection into QGIS 1.0.0 pr2, it shows up as layer without coordinate information (assigned default one). ogrinfo reports projection info just fine. Shapefile is created with Phyton + OGR and as SRS is used EPSG:3059

ogrinfo -ro -so bbox_3059.shp bbox_3059
INFO: Open of `bbox_3059.shp'
      using driver `ESRI Shapefile' successful.

Layer name: bbox_3059
Geometry: Polygon
Feature Count: 240
Extent: (28.110982, 56.323566) - (1050169.240520, 524386.627352)
Layer SRS WKT:
PROJCS["LKS92 / Latvia TM",
    GEOGCS["LKS92",
        DATUM["Latvia_1992",
            SPHEROID["GRS_1980",6378137,298.257222101]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",24],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",-6000000],
    UNIT["Meter",1]]
FID: Real (11.0)

Attachments (1)

bbox_3059.tgz (4.3 KB ) - added by marisn 15 years ago.
Example shapefile with failing proj (EPSG:3059)

Download all attachments as: .zip

Change History (11)

by marisn, 15 years ago

Attachment: bbox_3059.tgz added

Example shapefile with failing proj (EPSG:3059)

comment:1 by warmerdam, 15 years ago

Cc: warmerdam added; userid:warmerdam removed

I have confirmed on my machine that the SRS does not appear in the vector layer metadata properties dialog. The debug output suggests much effort is made matching it and failing.

comment:2 by warmerdam, 15 years ago

No match is found because the EPSG:3059 entry in the srs.db includes a towgs84 parameter lacking in the ESRI .prj file.

I really have no idea why a coordinate system needs to exist in srs.db to be considered valid. What's with that?

comment:3 by warmerdam, 15 years ago

Cc: timlinux added

Tim,

It was suggested you are a QGIS CRS guru of sorts, and I have taken the liberty of adding you to the cc list. Perhaps we could discuss the matter in IRC at some point - particularly why the matching is necessary.

comment:4 by wonder, 15 years ago

Resolution: fixed
Status: newclosed

This has been fixed in r10398.

Frank - to explain the inner working of the CRS recognition: given a proj4 string, qgis tries to match it to database. Reason for this is to find out EPSG id, srid and name of the projection. If it fails doing exact match, it goes through the database entries and compares the two projections using OSRIsSame (resp. OSRIsSameGeogCS). If this search fails too, it creates CRS just using the proj4 string (projection name and ids are not resolved). If everything fails, it just uses wgs84 or some other default CRS.

This might not be the best logic (personally I'm not really confident with roboustness of OSRIsSame), so any ideas for improvement are mostly welcome.

Martin

comment:5 by hamish, 15 years ago

Hi,

a sort of related question about this fix:

if you have just started the program and this is the first data layer you have loaded AND you have not already set the CRS with the "P" setup, will it automatically set the uninitialized CRS to match the CRS of the first layer, or do you still have to manually adjust the project's CRS to match the layers? it would be awesome if that could happen automatically. (maybe it now does?)

thanks, Hamish

comment:6 by marisn, 15 years ago

Milestone: Version 1.0.2Version 1.2.0
Resolution: fixed
Status: closedreopened
Version: 1.0.01.2.0

Still fails with QGIS 1.2.0 (r11429). Related question - why QGIS SRS definition differs from one created by OGR?

Here's console output:

Critical: QgsCoordinateReferenceSystem::createFromWkt -- theWkt is uninitialised, operation failed
Critical: QgsCoordinateReferenceSystem::createFromWkt -- theWkt is uninitialised, operation failed
Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnHelp_clicked()
Warning: QgsCoordinateReferenceSystem::getRecord failed :  select * from tbl_srs where parameters='+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=-6000000 +ellps=GRS80 +units=m +no_defs'
Warning: QgsCoordinateReferenceSystem::findMatchingProj ------->
 no match found in srs.db, trying user db now!
Warning: QgsCoordinateReferenceSystem::findMatchingProj -------> no match found in user db
Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnClose_clicked()
Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnHelp_clicked()
Warning: QgsCoordinateReferenceSystem::getRecord failed :  select * from tbl_srs where parameters='+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=-6000000 +ellps=GRS80 +units=m +no_defs'
Warning: QgsCoordinateReferenceSystem::findMatchingProj ------->
 no match found in srs.db, trying user db now!
Warning: QgsCoordinateReferenceSystem::findMatchingProj -------> no match found in user db

comment:7 by homann, 15 years ago

Resolution: fixed
Status: reopenedclosed

The WKT is read by the OGR library to an OGR-internal format, and then exported to proj4 string from that OGR format (for projection). I would guess that OGR does not recognize the "LKS92" datum, and assigns no datum.

So, the proj4 string you in the output above IS created from OGR.

I think this bug should be sent to OGR maintainer. The best solution is that OGR converts the LKS92 datum to a +towgs84=0,0,0,0,0,0,0

Note: Now QGIS creates a custom CRS from the proj4 string if no match was found. Unfortunately, as OGR does not supply any datum

comment:8 by homann, 15 years ago

... we can't assume that it is equal to EPSG 3059, where the datum is specified as LKS92 (WKT) or towgs84=0,0,0,0,0,0,0 (our EPSG list)

comment:9 by hamish, 15 years ago

see also comments in bugs #1079 and #1875

comment:10 by homann, 15 years ago

Fixed i18n problems in r11436, it was no possible auto create CRS when i18n characters were used in the description.

Note: See TracTickets for help on using tickets.