Hi all, it might old but still struggling from it.
I have an ESRI geo-database that has Roads data. I want to display it in axMap control.
This is my function:
private void openGDB()
{
try
{
var ogr = new OgrDatasource();
string source = @"path\data.gdb";
if (!ogr.Open(source)) // no error here
{
MessageBox.Show("Failed to open data source. Err: " + ogr.GdalLastErrorMsg);
}
else
{
int count = ogr.LayerCount; // This displays count properly
Debug.WriteLine(count);
var layer = new OgrLayer();
layer = ogr.GetLayerByName("Road");
int a = axMap1.AddLayer(layer, true) ; // here a gets number 1
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Code works without error but data are not displayed.
When I debug the code, the only error I get is the following at layer var:
GdalLastErrorMsg = “Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.” when layer created. But when I check layer’s values again in the same run, that error disappears.
When I add shapefile to axMap it works fins, but from geo-database it does not. All layers has the same projection.
Also as long as I remember, while I was installing mapwingis, I was asked while installation if I want to register variables to system, and I selected yes to that. So, GdalLastErrorMsg kind of make no sense to me!
Can someone enlighten me on what is wrong with my code.
Dear Mr. Jerry, Thank u for your reply. I added the code and all layers got printed successfully. But it does not appear in the axMap. The other options you suggested, I installed mapwindow5, but when I navigate to any esri geo-database, it only enables me to select geo-database not feature class; not expandable.
See attached picture.
It shows all shapefiles properly. Do you think mapwindow5 has same issue in my machine as mine?
Please advise, Thanks
Can you have a look if the GDAL_DATA variable is correctly set on your machine?
It should point to the gdal-data subfolder of the folder MapWinGIS is installed.
If it points to the correct location can you check if the file gcs.csv is in it?
Hi Mr. Pmeems,
I checked GDAL_DATA variable but wasnt there. I added it with the proper folder where mapwingis is installed. I also found gcs.csv in that folder. But still data not shown.
This works perfect. Thank you Mr. pmeems, you really saved me a lot of time. Very beautiful.
Though having it working, I tried to modify my code to match yours, but it never works with other than your code!!!.
Any way, Thank again