Bug report #9414
Custom CRS with units=mm stored as units=m
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Projection Support | ||
Affected QGIS version: | 2.0.1 | Regression?: | No |
Operating System: | Windows | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 18009 |
Description
I try to set up a custom CRS with
+proj=tmerc +lat_0=51.4 +lon_0=7.0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=mm +no_defs
This is valid and computes correctly in GDAL cs2cs.
I can input the proj string in Custom CRS dialogue, and the input form saves and does not throw an error. But when I reopen the Custom CRS form, the units have changed to meters. In project settings, the custom CRS is also only in meters.
Additionally, when I create a shapefile with millimeters as units outside QGIS, it will be loaded in a custom CRS with meters as units.
History
#1 Updated by Leyan Ouyang almost 11 years ago
This is a limitation in OGR, not in QGis. When creating a custom CRS, QGis just uses the OGR function OSRImportFromProj4 to create the CRS. The stored string is the proj4 representation given by OGR, so this means the unit information was lost during the conversion back and forth with OGR.
I just tried with a simple C++ wrapper around OSRImportFromProj4, and it seems OGR doesn't keep the unit for at least dm,cm,mm. It will only work for some units: such as km, ft, yd, us-ft, us-yd, etc.
Another way to specify a unit is using the to_meter= parameter. This seems to be accepted by OSRImportFromProj4, could you try using :
+proj=tmerc +lat_0=51.4 +lon_0=7.0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +to_meter=0.001 +no_defsto see if it works with your data?
edit: seems it does not work either. I am actually working on improvements on the CRS management but this will have to wait for 2.4, I will see if I can include a simple bug correction for 2.2.
#2 Updated by Andre Joost almost 11 years ago
Leyan Ouyang wrote:
edit: seems it does not work either.
No success on my side too.
#3 Updated by kyle - almost 11 years ago
All units reported by cs2cs -lu should be supported in parsing proj.4 strings in GDAL trunk. See gdal ticket:
http://trac.osgeo.org/gdal/ticket/5370
kyle@kyle-workstation:~/src/gdal/trunk/gdal$ cs2cs -lu km 1000. Kilometer m 1. Meter dm 1/10 Decimeter cm 1/100 Centimeter mm 1/1000 Millimeter kmi 1852.0 International Nautical Mile in 0.0254 International Inch ft 0.3048 International Foot yd 0.9144 International Yard mi 1609.344 International Statute Mile fath 1.8288 International Fathom ch 20.1168 International Chain link 0.201168 International Link us-in 1./39.37 U.S. Surveyor's Inch us-ft 0.304800609601219 U.S. Surveyor's Foot us-yd 0.914401828803658 U.S. Surveyor's Yard us-ch 20.11684023368047 U.S. Surveyor's Chain us-mi 1609.347218694437 U.S. Surveyor's Statute Mile ind-yd 0.91439523 Indian Yard ind-ft 0.30479841 Indian Foot ind-ch 20.11669506 Indian Chain
#4 Updated by Leyan Ouyang almost 11 years ago
I made a small pull request allowing to avoid the OGR conversion before storing the CRS. Based on my quick tests, it seems to solve your issue, could you try it? https://github.com/qgis/QGIS/pull/1130
I am currently working on more significant improvements in the custom CRS management, but this will have to wait until 2.4.
#5 Updated by Andre Joost almost 11 years ago
Leyan Ouyang wrote:
I made a small pull request allowing to avoid the OGR conversion before storing the CRS. Based on my quick tests, it seems to solve your issue, could you try it?
Sorry, I can't build QGIS on my own. But I added some test cases to the GDAL ticket http://trac.osgeo.org/gdal/ticket/5370. Only 2 of the 4 shapefiles correctly created by the latest GDAL-dev are displayed properly in QGIS 2.0.1
#6 Updated by Leyan Ouyang almost 11 years ago
- Status changed from Open to Closed
I just tried the test cases in the GDAL tickets, they are correctly represented with QGis Master.