A few problems with sharpmap v1.1

Topics: SharpMap Project, SharpMap v0.9 / v1.x, WinForms Controls
Apr 23, 2014 at 6:12 PM
I've started to use sharpmap as gis framework, and it's defentetly hard for me. I'm not familiar with codeplex, opensource and gis systems, so I have several problems, and googling doesn't helped a lot. I believe my questions will be stupid, so I post all of them here. I hope someone will copypast smth from somewhere.

So, I have VS12pro, I've downloaded sharpmap, geoapi, nts, brutile, gdal (and mb smth else) from NuGet.

1. I've displayed my shp files with Ogr data provider. I need to save user paintings to separate shp file. I don't understand how exactly layer system works, and how can I do what I want.
var vLayer = new SharpMap.Layers.VectorLayer("OgrSample");
vLayer.DataSource = new SharpMap.Data.Providers.Ogr("mymap.shp", 0);
2. Mb It's connected with prevous question - but I don't even know how to clear all user paintings manually (from code). I know that there is button "clear" on MapDigitizeGeometriesToolStrip, but I don't know what is it actually do. Mb it's related to this code? I don't know what's that for, but it seems to be connected with custom (painted) geometries.

private SharpMap.Data.Providers.GeometryProvider geoProvider;
public Form1()
            var vl = new SharpMap.Layers.VectorLayer("My Geometries");
            geoProvider = new SharpMap.Data.Providers.GeometryProvider(new List<GeoAPI.Geometries.IGeometry>());
            vl.DataSource = geoProvider;
3. I have a problems with BruTIle (, It don't show bing layers as expected and google sattelite at all. When I'm trying to open bing layer with code
var bingLayer = new SharpMap.Layers.TileAsyncLayer(new BruTile.Web.BingTileSource(BruTile.Web.BingRequest.UrlBingStaging, string.Empty, BruTile.Web.BingMapType.Hybrid), "TileLayer - Bing");
            bingLayer.SRID = 4326;         
It shows me just north america (and small part of africa), not expected square with whole world. And it gives me a pictures "404error" when I'm trying to open "google sattelite" type with this code (but other google types works)
var googleLayer = new SharpMap.Layers.TileAsyncLayer(new BruTile.Web.GoogleTileSource(new BruTile.Web.GoogleRequest(BruTile.Web.GoogleMapType.GoogleSatellite), new BruTile.Cache.MemoryCache<byte[]>(100, 1000)), "TileLayer - Google");
            googleLayer.SRID = 4326;
4. what cordinate system google/bing/osm brutile layers use? Is it wgs84? I've tried to load them with my maps, and my maps appear in athlantic ocean, because their coordinates lays in smth about 0..200, but brutile coordinates is much bigger. How can I transform my coordinates from shp file to use it on brutile layers? BTW - my shp files is nothing but OSM data, but cutted with ogr2ogr from FWTools. Mb It's achievable with GeoData from Sharpmap winforms examples (at least countries.shp/rivers.shp) ?

5. How can I make targeting and drag&drop operations with painted (by user) points? Is it possible without hardcoding? If not, how can I access to screen and world coordinates of this points?

6. I can't download NuGet packages for .NET 3.5, just for .NET 4.5. I've targeted on Sharpmap because it can work with 3.5 or even 2-3 or even with mono (as I understood). Is it so?

7. What is it - Sharpmap 2.0 ? https://code.google.com/p/sharpmapv2/ I've found old google repository, which wasn't updated since 2012. I've installed svn, maked a checkout. But I can't run any example from it, as I don't have vs 2008/2010 (and my attempts to convert it into 2012 got failed).
Apr 25, 2014 at 12:19 AM
  1. SharpMap's shapefile provider is readonly. Even if you use the Ogr provider you will have to write the shapefile saving routine yourself.
  2. The MapDigitizeGeometriesToolStrip adds all created geometries to a GeometryProvider backed VectorLayer. If you want to save the features some way it may be better to subscribe to the GeometryDefined event.
  3. The issue with Bing is a bug or a change in the tile schema we did not notice. Google Maps is prohibited (even though it might work). There are alternatives (MapBox, OpenStreetMap) that jump in quite well.
  4. The coordinate system of the tiles is called WebMercator. To convert your vector data you need to set up a coordinate transformation.var ctFac = ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
    var ct = ctFac.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84,
    and assign that to your shapefile.
  5. You need to set MapBox.ActiveTool = MapTools.QueryWindow
  6. Currently SharpMap targets .Net Framework 4.03 Client profile. You probably can build it yourself for .Net 2.0/3.5 with some tweaks. All providers that rely on native libs (GDAL/OGR, SpatiaLite to some extent) won't work. on mono.
  7. SharpMap v2 is no longer maintained.
May 8, 2014 at 12:19 AM
FObermaier wrote:
Thank you very much, this information helped me a lot, but it's not all.
  1. The MapDigitizeGeometriesToolStrip adds all created geometries to a GeometryProvider backed VectorLayer. If you want to save the features some way it may be better to subscribe to the GeometryDefined event.
  2. You need to set MapBox.ActiveTool = MapTools.QueryWindow
Here is the most emportant things for me - how can I edit data loaded on some layer of mapbox? I've tried QueryPoint and QueryBox (there is no QueryWindow). And got some output by handling MapQueried event It was cool, but I can't figure out how can I use it for data edit (drag&drop points, line points,...)
May 8, 2014 at 3:51 PM
Edited May 8, 2014 at 3:52 PM
There is currently no geometry editing functionality in SharpMap, apart from creating them.