Transform and display my shapefile

Topics: SharpMap v0.9 / v1.x
Feb 26, 2010 at 9:10 AM

Hey,

I'm trying to display my shapefile.  I believe it is in WGS84-UTM.  It should display a rectangle in the NorthSea (Zone 31U).

I'm not able to find the correct transformation, or the correct code to display it.

Can anyone help me?

Coordinator
Feb 26, 2010 at 1:37 PM

Hi Jan, if all of your data is in the same projection you do not need to worry about the projection. If you need the WKT for a coordinate system you can try at http://spatial-reference.org

http://sharpmap.codeplex.com/wikipage?title=Apply%20on%20the%20fly%20transformation%20to%20a%20layer&referringTitle=How%20to... may be useful if you do need to transform data.

hth jd

Mar 1, 2010 at 7:26 AM

thx for your reply

This is one of the shapefiles i'm trying to display: http://www.j-dc.be/rectangle.zip

I can display all other shapefiles, but this ones, I just can't figger it out.

grtz

Coordinator
Mar 1, 2010 at 4:16 PM

Hi Jan, that zip was corrupt.. can you repost? cheers jd

Mar 2, 2010 at 8:44 AM

Oops, sorry.   The zip-file should be fixed now!

Coordinator
Mar 2, 2010 at 12:47 PM

Hello Jan,

if it is for the sake of this one rectangle, why don't you recreate it from scratch?

Information on how to convert lat/lon to utm can be found here.

Knowing the bounding coordinates of the rectangle you can create a shapefile using NetTopologySuite or many other gis programs.

Hth FObermaier

 

Mar 2, 2010 at 1:04 PM

Hi,  the rectangle is just an example. 

I have several more shapefiles I need to display, I just posted the most simple one here.

Can I asume correctly that sharpmap is not able to display shapefiles with UTM coordinates, or is it my fault I can't display those files?

grtz

 

 

Coordinator
Mar 2, 2010 at 1:20 PM

Jan,

SharpMap can display shapefiles with UTM coordinates. If you have shapefiles with different coordinate systems you have to agree on one  to "take the lead" and set up reprojection(s) for the others.

Don't you have matching *.prj files for the shapefiles? They usually contain information about the used coordinate system?

FObermaier

Mar 3, 2010 at 8:19 AM

All my shapefiles use the same coordinate system.

Ar you saying that this code should display my shape, if it is the only layer I am adding?

Dim map As Map = New Map(size)
Dim _RectangleLayer As VectorLayer = New VectorLayer("Rectangle")
'Shapefile without .prj file
Dim _shf As New ShapeFile("E:\SharpmapTest\kader_CRTPNL_Polygon.shp")
_RectangleLayer.DataSource = _shf
'Not sure about this
_RectangleLayer.SRID = 23031

_RectangleLayer.Style.Fill = New SolidBrush(Color.Green)
map.Layers.Add(_RectangleLayer)

I also tried it with this .prj file :  http://spatial-reference.org/ref/epsg/23031/

Coordinator
Mar 3, 2010 at 9:45 AM

Hello Jan,

is there a call to

map.ZoomToExtents()

somewhere after you added the layer? The DemoWinForm application at least displays your shapefile - after clicking on the "Zoom to Extents" button.

Hth FObermaier

Mar 5, 2010 at 7:53 AM

Hey,  I got it working

Thx for your replies