Coordinate traslation on layers

Topics: Algorithms, SharpMap Project, SharpMap v0.9 / v1.x
Nov 14, 2011 at 9:02 AM

Hi all again, in these days I'm experimenting google maps and wms client. I have to set a base layer (raster, google maps or wms), and overlay a layer (shapefile or oracle or else). I tried all the code I found in posts like 'conversion problem, google maps conversion' but I realized that my problem is different:
My shapefile (or oracle) has been generated without any SRID, so the coords were automatically converted in the standard SRID (4326), but aren't georeferenced: they are in the middle of the layer. Therefore I can do all the conversion I want, but the result is the same in each case. 
So, there is a way to fix this in my shapefile, or better do a traslation on the fly while I'm drawing the geometries?

Coordinator
Nov 14, 2011 at 9:58 AM

To spatially reference a shapefile, you only need a proper *.prj file.

This must contain the WKT of the spatial reference system. You can (usually) get that for EPSG:4326 from here:

http://spatialreference.org/ref/epsg/4326/ogcwkt

GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]

Hth FObermaier

Nov 14, 2011 at 11:17 AM

Adding a prj file to my shapefile solved the wms problem! Thank you :D

But I still have problems with google maps. This is a pic http://imageshack.us/photo/my-images/715/immaginehq.png/

Yellow geometries represent my shapefile. I noted this layer is a bit smaller then the isle on google maps

Coordinator
Nov 14, 2011 at 11:47 AM

Which one of the Projection libraries do you use?

If it is Proj.Net, there are workarounds for the combination GoogleMercator <-> EPSG:4326 on http://projnet.codeplex.com.

But, I admit, I'd like to have the root of this fixed as well :).

Hth Felix

Nov 14, 2011 at 2:01 PM

I have no preferences of use... Which one do you reccomend?

Coordinator
Nov 14, 2011 at 2:44 PM

The DotSpatial.Projections has a broader range of projections defined and is more actively developed.
It is pretty large though (~17mb)

If you can, avoid coordinate transformation during the rendering process and preprocess your data with some reprojection tool, e.g. ogr2ogr of the gdal suite.

Hth FObermaier

Nov 15, 2011 at 7:13 AM

The problem is the oracle database, because it will be read only, so I will need to do some transformation, I think... btw, I try and I let you know

Coordinator
Nov 15, 2011 at 10:08 AM

You should be able to create a view within Oracle that returns transformed geometries...

Nov 18, 2011 at 4:41 PM

Hi FObermaier, I made some attempts, and now the question is much clear. I had to reproject my oracle table, and apply to it the SRID 3003 (Gauss-Boaga), that is the correct SRID. Also the yellow layer uses the same coordinate system (then 3003, not 4326).

After some hours I re-tried with the WMS and the 3 layers perfect match. So I tried with google, with the transformation from SRID 3003 to SRID 3785, and the result is this: 
 http://imageshack.us/photo/my-images/707/immaginenzz.png/

still not matching, but the result is better than before.

I used the following strings:

var SRID3003 = cf.CreateFromWkt("PROJCS[\"Monte Mario / Italy zone 1\",GEOGCS[\"Monte Mario\",DATUM[\"D_Monte_Mario\",SPHEROID[\"International_1924\",6378388,297]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",9],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",1500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]");          

var SRID3785 = cf.CreateFromWkt("PROJCS[\"Popular Visualisation CRS / Mercator\", GEOGCS[\"Popular Visualisation CRS\", DATUM[\"Popular Visualisation Datum\", SPHEROID[\"Popular Visualisation Sphere\", 6378137, 0, AUTHORITY[\"EPSG\",\"7059\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\",\"6055\"]],PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]], AXIS[\"E\", EAST], AXIS[\"N\", NORTH], AUTHORITY[\"EPSG\",\"4055\"]], PROJECTION[\"Mercator\"], PARAMETER[\"False_Easting\", 0], PARAMETER[\"False_Northing\", 0], PARAMETER[\"Central_Meridian\", 0], PARAMETER[\"Latitude_of_origin\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"East\", EAST], AXIS[\"North\", NORTH], AUTHORITY[\"EPSG\",\"3785\"]]");           

Comuni.CoordinateTransformation=ctf.CreateFromCoordinateSystems(SRID3003, SRID3785);         

Comuni.ReverseCoordinateTransformation = ctf.CreateFromCoordinateSystems(SRID3785, SRID3003); 

 

What can I do?

Coordinator
Nov 21, 2011 at 6:17 AM

From the picture, you can try changing the "FALSE_NORTHING" value for EPSG:3785 (which should be called EPSG:3857).

Since you are developing a commercial application, stay away from google tiles. Their license prohibits that. You can use Bing Tiles along with some file based cache instead. That (probably) won't solve your reprojection issues, though.

Whenever I have the need to reproject data, that is too expensive to transform "on the fly", I simply add a second geometry column to the table that holds the transformed geometry and is being filled/updated via triggers and use that for my rendering purposes. Wherever you can, try to avoid reprojecting your data in the rendering cycle!

Hth FObermaier

Nov 21, 2011 at 8:00 AM

OK, I'll try and I let you know... For the google license, I know, I read the posts regarding this, but that part is for my pride :) 

btw, with the CoordinateTransformation (ProjNet) the difference between conversion and non-conversion is not appreciable

Coordinator
Nov 25, 2011 at 10:39 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.