Skip to content

[OT] Coordinates and pojection problems

6 messages · Julien Barnier, Takatsugu Kobayashi, Paul Hiemstra +1 more

#
Hi,

I'm sorry to post a rather off-topic question here, but as a new sp
user and total novice in coordinates and projections questions, I'm
facing a problem you may help me to solve. Please ignore this post if
it is too much noise.

I've got two map files (a MapInfo file and an ESRI shapefile) from two
different sources but which represent objects from the same french
region (one represent the cities, the other rivers and water
surfaces). 

The problem is that when imported into R and plotted together, they
doesn't appear in the same place.  They seem to have the same
?longitude?, but the ?latitude? is different. If I plot them, the
first map ranges in the Y axis from 70,000 to 100,000 and the second
one from 2,060,000 to 2,140,000. The ranges along the x axis seem to
be the same, though.

Here is the output of ogrinfo on the two files :

,----
| $ ogrinfo -so 69_iris.mid 69_iris
| Had to open data source read-only.
| INFO: Open of `69_iris.mid'
|       using driver `MapInfo File' successful.
| 
| Layer name: 69_iris
| Geometry: Unknown (any)
| Feature Count: 774
| Extent: (747910.000000, 2053380.000000) - (819740.000000,
| 2147622.300000)
| Layer SRS WKT:
| PROJCS[?unnamed?,
|     GEOGCS[?unnamed?,
|         DATUM[?MIF 9999,6,-168,-60,320,0,0,0,0,0?,
|             SPHEROID[?Clarke 1880?,6378249.145,293.465],
|             TOWGS84[-168,-60,320,-0,-0,-0,0]],
|         PRIMEM[?non-Greenwich?,0],
|         UNIT[?degree?,0.0174532925199433]],
|     PROJECTION[?Lambert_Conformal_Conic_2SP?],
|     PARAMETER[?standard_parallel_1?,45.90287723937],
|     PARAMETER[?standard_parallel_2?,47.69712276063],
|     PARAMETER[?latitude_of_origin?,46.8],
|     PARAMETER[?central_meridian?,2.337229104484],
|     PARAMETER[?false_easting?,600000],
|     PARAMETER[?false_northing?,2200000],
|     UNIT[?Meter?,1]]
| DepCom: String (5.0)
| Nom_Com: String (40.0)
| Iris: String (4.0)
| DComIris: String (9.0)
| Nom_Iris: String (43.0)
| Typ_Iris: String (1.0)
| Indic: String (1.0)
| Origine: String (1.0)
`----

,----
| $ ogrinfo -so Decoupage_Administratif/SURFDEAU.shp SURFDEAU
| INFO: Open of `Decoupage_Administratif/SURFDEAU.shp'
|       using driver `ESRI Shapefile' successful.
| 
| Layer name: SURFDEAU
| Geometry: Polygon
| Feature Count: 168
| Extent: (785619.190000, 68133.620000) - (818193.410000, 107443.340000)
| Layer SRS WKT:
| (unknown)
| NUMOBJ: String (11.0)
`----

I've tried to play with some parameters in readShapePoly and
spTransform, but without success.

Any help would be greatly appreciated.

Thanks in advance,
#
Hi,

I am having a problem with segmentation fault when I run my code using 
PBSmapping. I have thought 'segfault' indicates either that my code is 
wrong or that something is missing in this package.

When I run my code, a terminal on Ubuntu shows me:

Program received signal SIGSEGV, Segmentation fault.
gpc_polygon_clip (op=GPC_INT, subj=<value optimized out>,
    clip=<value optimized out>, result=0x18c76d0) at gpc.c:1721
1721    gpc.c: No such file or directory.
        in gpc.c

So I guess I need to install gpc.c from somewhere.

I have been net searching this file, but no luck. I appreciate any help.

Thanks.

Best regards,

Taka
#
On Wed, 18 Jun 2008, tkobayas at indiana.edu wrote:

            
No, it simply suggests that your copy of the package was compiled using 
the -g flag (standard for R in most cases, and inherited by packages with 
source code). Did you install from source, or a binary? Have you tried 
running R -d gdb to determine where the problem occurred? Have you 
contacted the package maintainer, best with a copy of the object (save()) 
and a script to reproduce the error?

Roger

  
    
#
Hi,

You need to find out what the projection of the shapefile is, the 
ogrinfo does not give this information for your file as you probably do 
not have the .prj file. The R function spTransform needs the projection 
info in a so called proj4string. The easiest way to define such a string 
is through the epsg code, this code enables proj (the projection library 
used in R) to find the parameter it needs. For example, the proj4string 
for the Dutch national projection is:

"+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 
+k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m 
+towgs84=565.04,49.91,465.84,-0.409394387,0.35970519561,-1.868491,4.0772 
+no_defs"

using epsg codes:

"+init=epsg:28992"

The bottomline is to find the projection of your second shapefile as 
this is the most likely candidate to cause the difference. A good place 
to ask questions regarding projections is the proj4-mailing list 
(http://lists.maptools.org/mailman/listinfo/proj).

hth and cheers,
Paul
Julien Barnier wrote:

  
    
#
On Thu, 19 Jun 2008, Paul Hiemstra wrote:

            
Right. In addition, do some digging into the history of coordinate 
reference systems for your country of interest, for example:

http://www.asprs.org/resources/grids/

has France on January 2001. I think that you may be in Nouvelle 
Triangulation Fran?aise, which has a Paris meridian:

EPSG <- make_EPSG()
EPSG[grep("NTF", EPSG$note), 1:2]

But that is guesswork. For enthusiasts, once you have a guess, use 
spTransform to geographical coordinates (CRS("+longlat +datum=WGS84")), 
and do writeOGR(obj, "obj.kml", "obj", driver="KML") of (a subset of) your 
object and see where it lands in Google Earth.

Roger

  
    
1 day later
#
Hi Roger and Paul,

Thanks to your help, I've managed to import the files and to transform
them into the same projection. In fact I had the .prj file associated
to the shapefile, but I didn't even know that it contains the
projection informations...

Thanks to readShape Ply and spTransform I've converted both into
geographical coordinates. And the kml export and GoogleEarth
visualization is a very useful possibility I didn't know.

So thanks a lot for your help !