Re: [gdal-dev] Unable to create OGRSpatialReference

2012-10-21 Thread jcurru
Frank,

I've been working a little bit with your ideas.
The target is to realize towgs84 parameters automatically.
Of course it doesn't work many times because all the procedures I use
fail and/or because my code is wrong. I don't know, but maybe you can
find it useful.

I use Embarcadero (former Borland) IDE, so you'll find non-standard things
RRCS is a class derived from OGRSpatialReference.

Best regards.
Jose





--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/Unable-to-create-OGRSpatialReference-tp5009903p5010161.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Unable to create OGRSpatialReference

2012-10-20 Thread jcurru
Frank, 

Thanks you for your expert answer. It opens for me two or three new ways to
look for the /lost/ parameter.

My interest is not only in SHP, but your ideas might solve part of my
problem.

As for what you say I'm up with fixing this with your support (ie. testing,
prompting) I am at your command to test what it takes, but I think my
solutions that are not suitable for be incorporated into a library like
GDAL. However, if I walk into something you'll see in the forum.

I hope your new job at Google makes you as happy as a job can do.

Thank you again.

P.S. You are guaranteed a great paella if you come to Madrid.




--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/Unable-to-create-OGRSpatialReference-tp5009903p5010047.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Unable to create OGRSpatialReference

2012-10-19 Thread Even Rouault
Le vendredi 19 octobre 2012 16:41:14, jcurru a écrit :
 Hello!
 
 I have an old problem with TOWGS84 and OGRSpatialReference. Most likely
 it's because I'm no expert in GDAL. It is important for my project, and
 limits many of its capabilities. The fact is that, for unknown reasons (to
 me), proj4 does not do well conversions between coordinate system if there
 are not a TOWGS84 nodes inside the OGRSpatialReference(s).
 
 First of all: is this so? Do I really need that node? If not properly
 added, clearly some conversions fail.

The best is to point you to some reference documentation :

http://trac.osgeo.org/proj/wiki/GenParms#towgs84-DatumtransformationtoWGS84
http://docs.geotools.org/stable/javadocs/org/opengis/referencing/doc-
files/WKT.html#TOWGS84

 
 I continue: Imagine getting an OGRSpatialReference a shapefile or a TIF. To
 assign the node TOWGS84, what I do is look into the file EPSG, found in
 many sites related to GDAL, that contains a list of EPSGs with
 corresponding parameters. Knowing the EPSG, I can generate the TOWGS84
 node smoothly.
 
 The problem comes when I do not know the OGRSpatialReference’s EPSG,
 something very common: AutoIdentifyEPSG () gets nothing most of the time,
 at least with the systems in which I work.
 
 So what to do then? I need the TOWGS84 node but, with my knowledge, I can
 only get it from the EPSG.

This is indeed a difficulty that is not easily solved. The WKT in .prj that 
come 
alongside with shapefiles is in ESRI WKT that stripps TOWGS84 information. And 
most geotiff don't include TOWGS84 : the GeoTIFF format has only been extended 
very recently to convey TOWGS84 : 
http://trac.osgeo.org/geotiff/wiki/TOWGS84GeoKey

And indeed AutoIdentifyEPSG() only works a few common cases, mainly EPSG:4326, 
EPSG:326XX  EPSG:327XX (WGS84 UTM projections), EPSG:267XX (NAD27 UTM 
projections) and EPSG:269XX (NAD83 UTM projections).
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Unable to create OGRSpatialReference

2012-10-19 Thread jcurru
Thank you again, Even.

Well, I've taken a look at the documentation you mention, but no answers
there, just an explanation about wgsto84 parameters and a proposal for
extending the geotiff standard in order to embed the famous parameter. I
guess that if you don't say oh man, didn' you know this famous trick...?
is because the trick does not exist. So, before I continue wasting your
time, would you be so kind to answer this two questions? (yes/no will be
enough)

1) Do I need the towgs84 parameters to properly do transformations between
coordinate systems using proj4?
2) The only way to obtain that parameter is by using the epsg file, and
therefore I MUST know the EPSG?

Thak you!




--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/Unable-to-create-OGRSpatialReference-tp5009903p5009950.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Unable to create OGRSpatialReference

2012-10-19 Thread Frank Warmerdam
On Fri, Oct 19, 2012 at 7:41 AM, jcurru jcu...@yahoo.es wrote:

 Hello!

 I have an old problem with TOWGS84 and OGRSpatialReference. Most likely
 it's
 because I'm no expert in GDAL. It is important for my project, and limits
 many of its capabilities. The fact is that, for unknown reasons (to me),
 proj4 does not do well conversions between coordinate system if there are
 not a TOWGS84 nodes inside the OGRSpatialReference(s).

 First of all: is this so? Do I really need that node? If not properly
 added,
 clearly some conversions fail.


JCurru,

PROJ.4 should still handle reprojection for coordinate systems without
a TOWGS84 or other datum relationship to WGS84 *but* it will ignore
datum shifting if the source and destination coordinate system do not
have well defined relationships to WGS84.  So the results will (often)
be somewhat inaccurate.  How big an issue this is will depend on your
application and the typical coordinate systems you work with.


 I continue: Imagine getting an OGRSpatialReference a shapefile or a TIF. To
 assign the node TOWGS84, what I do is look into the file EPSG, found in
 many sites related to GDAL, that contains a list of EPSGs with
 corresponding
 parameters. Knowing the EPSG, I can generate the TOWGS84 node smoothly.

 The problem comes when I do not know the OGRSpatialReference’s EPSG,
 something very common: AutoIdentifyEPSG () gets nothing most of the time,
 at
 least with the systems in which I work.

 So what to do then? I need the TOWGS84 node but, with my knowledge, I can
 only get it from the EPSG.


If you want to handle a datum shift properly and you don't know how
the datum of your coordinate system relates to WGS84 then you are
essentially out of luck.

Best regards,
-- 
---+--
I set the clouds in motion - turn up   | Frank Warmerdam,
warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush| Geospatial Software Developer
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Unable to create OGRSpatialReference

2012-10-19 Thread jcurru
Frank,

First of all let me tell you thanks for your work. Thanks is not enough but
my poor english would put me in troubles if I tried to say something more
complicated. And thank you very much for your answer. Getting help from you
from the other side of the ocean (I live in Madrid, Spain) is a honor.

I am not an expert in GIS, but despite of it I am writting a big GIS
application. My colleages are supposed to be, but they have been unable to
give me a solution to this subject, so, please, be so kind to tell me if
this is ok:

Ignoring the towgs84 parameters has proved to give bad results when
transforming coordinate systems using proj4, even working with standard
systems like ETRS89 (used in Spain) or ED50. Giving the correct towgs84
parameter the errors dissapeared completely.

Therefore, I decided to write a descendant from OGRSpatialReference whose
constructors throw exceptions if the towgs84 parameter cannot be found. For
example, there's a constructor that receives an OGRSpatialReference pointer
as argument (obtained, for example, from a shapefile, a tif, a LAS file, etc
using GDAL). My class builds the underlying OGRSpatialReference with that
pointer and then tries to obtain the towgs84 parameter. Somethimes it is
present in the OGRSpatialReference object, most doesn't. Then I try to use
the epsg. file if I can figure out the EPSG number. If everything fails
then the constructor throws and the program asks for an EPSG to the user.
And this is a pity because almost all the information I need is supplied
by GDAL. The program is worst because it's not able to find out the famous
parameter.

You say: If you want to handle a datum shift properly and you don't know
how the datum of your coordinate system relates to WGS84 then you are
essentially out of luck. The problem is that my application should work
with any projection. I cannot make assumptions or make a list of supported
projections. My aim is to be able to get the towgs84 parameter whatever
coordinate system the input files are projected into.

I often use other programs to display geospatial information, for example
Global Mapper. It realizes coordinate systems from (for example) shapefiles
without EPSG, and applies transformations correctly. What am I missing?

Sorry for my long message, but I've been overwhelmed with this problem for
two years, and having you across the line gives me a hope. I'm sure there's
a solution because many systems work fine.

So thank you again.
Sincerely yours, 
Jose Antonio.



--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/Unable-to-create-OGRSpatialReference-tp5009903p5009971.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Unable to create OGRSpatialReference

2012-10-19 Thread Frank Warmerdam
On Fri, Oct 19, 2012 at 2:00 PM, jcurru jcu...@yahoo.es wrote:

 I often use other programs to display geospatial information, for example
 Global Mapper. It realizes coordinate systems from (for example) shapefiles
 without EPSG, and applies transformations correctly. What am I missing?


Jose,

It is hard to answer this very broadly, but it is possible that Global
Mapper
knows how to lookup *ESRI* datum names to find towgs84 parameters.
To some extent we have this information in the system now.  For instance
if you look in gdal_datum.csv, the last column is ESRI_DATUM_NAME
and has D_European_1950 for EPSG datum 6230.

The gcs.csv file has a TOWGS84 parameter value for GCS 4230 (which
uses datum 6230).

So in theory given ESRI datum names we ought to be able to (fairly
often) derived a TOWGS84 shift and in fact this should quite possible
be part of the morphFromESRI() process though apparently it is not
now.   It would make it easier to do this if we included the
ESRI_DATUM_NAME field in the gcs.csv file.

So if it is really just the ESRI datum's case that you want to address
lets consider improving the automatic morphing within GDAL/OGR.
I'm willing to help with this.  In fact, digging in the code there seems
to already be some machinery around doing that.  Lets discuss in
more detail the case where it isn't working for you now.

...

OK, I tried:

gdalsrsinfo
ESRI::'GEOGCS[GCS_European_1950,DATUM[D_European_1950,SPHEROID[International_1924,6378388.0,297.0]],PRIMEM[Greenwich,0.0],UNIT[Degree,0.0174532925199433],AUTHORITY[EPSG,4230]]'

and I get as output:

PROJ.4 : '+proj=longlat +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +no_defs '

OGC WKT :
GEOGCS[GCS_European_1950,
DATUM[European_Datum_1950,
SPHEROID[International_1924,6378388.0,297.0]],
PRIMEM[Greenwich,0.0],
UNIT[Degree,0.01745329251994

I'm not really sure where the PROJ.4 string is getting the towgs84
parameters,
but there is no evidence that the ESRI datum name lookup is being used to
get these parameters.  I'm up with fixing this with your support (ie.
testing,
prompting).

I still claim solving the problem widely is not really doable.

Best regards,
Frank



 Sorry for my long message, but I've been overwhelmed with this problem for
 two years, and having you across the line gives me a hope. I'm sure there's
 a solution because many systems work fine.

 So thank you again.
 Sincerely yours,
 Jose Antonio.



 --
 View this message in context:
 http://osgeo-org.1560.n6.nabble.com/Unable-to-create-OGRSpatialReference-tp5009903p5009971.html
 Sent from the GDAL - Dev mailing list archive at Nabble.com.
 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev




-- 
---+--
I set the clouds in motion - turn up   | Frank Warmerdam,
warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush| Geospatial Software Developer
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev