Select to view content in your preferred language

Open network dataset

1419
8
Jump to solution
12-19-2012 04:45 AM
AngeloBevilacqua
Emerging Contributor
I am following "How to setup, solve, and save a network analysis problem" :

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000001zq000000

and "How to open a network dataset"

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_open_a_network_d...

Seems like to open a network dataset - I need to open a file gdb workspace.

I am trying to use the streetmap_na network dataset.

How do I get the streetmap_na network dataset into the default.gdb ?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
PatrickStevens
Esri Contributor
Hello, Angelo!

The code sample for "How to open a network dataset" should work for SDC as well as FGDB.  Are you getting an error when you try to use the code sample to open an SDC dataset?  What error is it?  Can you see your SDC dataset in ArcMap?

The steps from the sample are basically:

Get the IWorkspaceFactory, like they do in Connecting to a geodatabase.  However, use "esriDataSourcesFile.SDCWorkspaceFactory"as the ProgID:

public static IWorkspace SDCWorkspaceFromPath(String path)
{
    Type factoryType = Type.GetTypeFromProgID(
        "esriDataSourcesFile.SDCWorkspaceFactory");
    IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance
        (factoryType);
    return workspaceFactory.OpenFromFile(path, 0);
}

Once you have the workspace, you should be able to pass it into OpenNetworkDataset from How to open a network dataset and have it work.

Let me know what errors you are getting and we'll try to work them out.  Clipping a FGDB out of SDC is possible, but you lose a lot of information, like turns and signposts.

Regards,

Patrick

View solution in original post

0 Kudos
8 Replies
NicoleHanson
Deactivated User
Streetmap network dataset will open without putting it into a gdb.  That is more for when you create your own.  But if you really want to put it into a gdb, you can copy and paste in ArcCatalog, and then rebuild the dataset.
0 Kudos
AngeloBevilacqua
Emerging Contributor
Streetmap network dataset will open without putting it into a gdb.  That is more for when you create your own.  But if you really want to put it into a gdb, you can copy and paste in ArcCatalog, and then rebuild the dataset.


I am not able to copy and paste in ArcCatalog (or I don't see how to do it).

But in all the code samples I see - the workspace to open is a gdb. Then open the network dataset from a feature data set included included in the gdb.

Is there any code sample that will just open the streetmap networkdataset directly without going thru a workspace ?
0 Kudos
NicoleHanson
Deactivated User
I am not able to copy and paste in ArcCatalog (or I don't see how to do it).

But in all the code samples I see - the workspace to open is a gdb. Then open the network dataset from a feature data set included included in the gdb.

Is there any code sample that will just open the streetmap networkdataset directly without going thru a workspace ?



When you mention code samples, are you talking about with python?  If so, then I'm not sure how to accomplish what you're wanting.
0 Kudos
AngeloBevilacqua
Emerging Contributor
When you mention code samples, are you talking about with python?  If so, then I'm not sure how to accomplish what you're wanting.


I am using ArcObjects via .NET
0 Kudos
NicoleHanson
Deactivated User
Sorry, can't help you there.
0 Kudos
PatrickStevens
Esri Contributor
Hello, Angelo!

The code sample for "How to open a network dataset" should work for SDC as well as FGDB.  Are you getting an error when you try to use the code sample to open an SDC dataset?  What error is it?  Can you see your SDC dataset in ArcMap?

The steps from the sample are basically:

Get the IWorkspaceFactory, like they do in Connecting to a geodatabase.  However, use "esriDataSourcesFile.SDCWorkspaceFactory"as the ProgID:

public static IWorkspace SDCWorkspaceFromPath(String path)
{
    Type factoryType = Type.GetTypeFromProgID(
        "esriDataSourcesFile.SDCWorkspaceFactory");
    IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance
        (factoryType);
    return workspaceFactory.OpenFromFile(path, 0);
}

Once you have the workspace, you should be able to pass it into OpenNetworkDataset from How to open a network dataset and have it work.

Let me know what errors you are getting and we'll try to work them out.  Clipping a FGDB out of SDC is possible, but you lose a lot of information, like turns and signposts.

Regards,

Patrick
0 Kudos
AngeloBevilacqua
Emerging Contributor
Hello, Angelo!

The code sample for "How to open a network dataset" should work for SDC as well as FGDB.  Are you getting an error when you try to use the code sample to open an SDC dataset?  What error is it?  Can you see your SDC dataset in ArcMap?

The steps from the sample are basically:

Get the IWorkspaceFactory, like they do in Connecting to a geodatabase.  However, use "esriDataSourcesFile.SDCWorkspaceFactory"as the ProgID:

public static IWorkspace SDCWorkspaceFromPath(String path)
{
    Type factoryType = Type.GetTypeFromProgID(
        "esriDataSourcesFile.SDCWorkspaceFactory");
    IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance
        (factoryType);
    return workspaceFactory.OpenFromFile(path, 0);
}

Once you have the workspace, you should be able to pass it into OpenNetworkDataset from How to open a network dataset and have it work.

Let me know what errors you are getting and we'll try to work them out.  Clipping a FGDB out of SDC is possible, but you lose a lot of information, like turns and signposts.

Regards,

Patrick


Thats works !

esriDataSourcesFile.SDCWorkspaceFactory was the missing piece of the puzzle.
I was using esriDataSourcesGDB.FileGDBWorkspaceFactory - I knew that was wrong but didn't know what else to use...

Now I can open the workspace, network dataset and create my VRP.
But now I am having issues with OpenFeatureClass("Stores") when loading the locations - but haven't fiddled much with that part yet.

At least now I can try to move ahead.

Thanks a million Patrick - really appreciate your help !!! Been knocking my head on this for the past couple of days.
0 Kudos
PatrickStevens
Esri Contributor
That's good news.

When you run into struggles loading locations, post here and I'll help you out.

Thanks for using our software!
0 Kudos