[gdal-dev] creating graph for single line shape layer using gdal gnm

Mikhail Gusev gusevmihs at gmail.com
Wed Nov 12 13:52:23 PST 2014


>
> Is it correct to do this way?First I will save point layer using start and
> end points of line  layer.Again then connect the two layers using
> autoconnect method . So that I can find shortest path between features of
> the line layer.
>

hema,
yes it's correct, but note, that there must be only one point in a junction
of two line ends in order the connection will be made correct.

2014-11-12 14:28 GMT+04:00 yhema <hema.yeedunuri at amigooptima.in>:

> hello Mikhail Gusev ,
>
> Is it correct to do this way?First I will save point layer using start and
> end points of line  layer.Again then connect the two layers using
> autoconnect method . So that I can find shortest path between features of
> the line layer.
>
> thanks,
> hema
>
> On Wed, Nov 12, 2014 at 3:03 PM, Михаил Гусев [via OSGeo.org] <[hidden
> email] <http://user/SendEmail.jtp?type=node&node=5172529&i=0>> wrote:
>
>> The algorithm is using only the features that are connected manually and
>>> that are present in _gnm_graph.
>>
>>
>> No, if you use automatic connection the  _gnm_graph is also formed
>> automatically because it internally calls ConnectFeatures().
>>
>> Is there any other simple solution to solve this.
>>>
>>
>> It is no other solution for now to solve this. I think in the nearest
>> future the new algorithm of automatic connection can be written (which
>> regards only line layers and determines the start and end point of the
>> lines automatically), I'm working on this now.
>>
>> 2014-11-11 14:48 GMT+04:00 Hema Yeedunuri <[hidden email]
>> <http://user/SendEmail.jtp?type=node&node=5172509&i=0>>:
>>
>>> hello Mikhail Gusev ,
>>>
>>> Thank u for the reply .I want to find  the shortest distance between
>>> features .But the road layer I am using is having 10055 features. without
>>> creating graph it is not possible to find shortest distance.And to my
>>> understanding I think it is difficult to manually connect features to
>>> create graph. The algorithm is using only the features that are connected
>>> manually and that are present in _gnm_graph.dbf file.Is there any other
>>> simple solution to solve this.
>>>
>>> thanks,
>>> hema
>>>
>>> On Tue, Nov 11, 2014 at 3:59 PM, Mikhail Gusev <[hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=5172509&i=1>> wrote:
>>>
>>>> Hello, hema.
>>>> The current default implementation of GNMNetwork::AutoConnect() can
>>>> work only if the passing array of layers contains at least one point and
>>>> one line layer (i.e. GetGeomType() for the layers equals wkbPoint and
>>>> wkbLineString accordingly). For each line feature the algorithm takes the
>>>> start and end snapping area formed around the start and end point of the
>>>> line and searches the points from point layers which are situated inside
>>>> these two areas. So there is no way for now to connect features of only one
>>>> line layer automatically. You can use ConnectFeatures() to connect
>>>> manually, but you will need the features (with any geometry!) to be the
>>>> source and the target for the connection, while the gnm_roads_line feature
>>>> will be the connector.
>>>>
>>>> 2014-11-11 11:26 GMT+04:00 yhema <[hidden email]
>>>> <http://user/SendEmail.jtp?type=node&node=5172509&i=2>>:
>>>>
>>>>> Hello all,
>>>>>
>>>>> I am trying to create a graph for network analysis using gdalgnm.The
>>>>> feature
>>>>> auto connect is working if we provide more than one layer.How can we
>>>>> connect
>>>>> features of a single layer so that graph is created automatically. We
>>>>> can
>>>>> connect features using connect features but automatically it is not
>>>>> conncting using auto connect .Here is the code.
>>>>>
>>>>>  char **options = NULL;
>>>>>     options = CSLAddNameValue(options,GNM_INIT_OPTIONPAIR_NAME,
>>>>> "roads_network");
>>>>>
>>>>>
>>>>>     GNMGdalNetwork *poNet;
>>>>>
>>>>>     poNet =
>>>>>
>>>>> GNMManager::GdalCreateNetwork("/home/shiva/Desktop/network/network_data",
>>>>> "ESRI Shapefile", "EPSG:4326", options);
>>>>>     CSLDestroy(options);
>>>>>     if (poNet == NULL)
>>>>>     {
>>>>>         printf("Failed to create network\n");
>>>>>         exit(1);
>>>>>     }
>>>>>
>>>>>     GDALDataset *poSrcDS = (GDALDataset*)
>>>>> GDALOpenEx("/home/shiva/Desktop/network/data",
>>>>>                                                      GDAL_OF_VECTOR |
>>>>> GDAL_OF_READONLY, NULL, NULL, NULL );
>>>>>     if(poSrcDS == NULL)
>>>>>     {
>>>>>         printf("Can not open source dataset at\n");
>>>>>         exit(1);
>>>>>     }
>>>>>
>>>>>     OGRLayer *poSrcLayer2 = poSrcDS->GetLayerByName("roads");
>>>>>     if (poSrcLayer2 == NULL)
>>>>>     {
>>>>>         printf("layer is null\n");
>>>>>         printf("Can not process layers of source dataset\n");
>>>>>         exit(1);
>>>>>     }
>>>>>
>>>>>     GNMErr err2 = poNet->CopyLayer(poSrcLayer2, "roads");
>>>>>     if (err2 != GNMERR_NONE)
>>>>>     {
>>>>>         printf("Can not import layers from source dataset\n");
>>>>>         exit(1);
>>>>>     }
>>>>>
>>>>>     GDALClose(poSrcDS);
>>>>>
>>>>>
>>>>>     if (poNet->CreateRule("CLASS gnm_roads_line COSTS TIGER_ID") !=
>>>>> GNMERR_NONE)
>>>>>     {
>>>>>         printf("Can not create rule\n");
>>>>>     }
>>>>>
>>>>>     if (poNet->CreateRule("NETWORK CONNECTS gnm_roads_line WITH
>>>>> gnm_roads_line  ") != GNMERR_NONE)
>>>>>     {
>>>>>         printf("Can not create rule\n");
>>>>>     }
>>>>>
>>>>>
>>>>>     printf("\nBuilding network topology ...\n");
>>>>>     GDALDataset *poNetDS = poNet->GetDataset();
>>>>>     OGRLayer **layers = new OGRLayer*[3];
>>>>>
>>>>>     layers[0] = poNetDS->GetLayerByName("gnm_roads_line");
>>>>>     layers[2] = NULL;
>>>>>     layers[1] = NULL;
>>>>>
>>>>>
>>>>>     if (poNet->AutoConnect(layers,0.05, NULL) != GNMERR_NONE)
>>>>>     {
>>>>>         printf("Building topology failed\n");
>>>>>         exit(1);
>>>>>     }
>>>>>     else
>>>>>     {
>>>>>         printf("Topology has been built successfully\n");
>>>>>     }
>>>>>
>>>>>     delete[] layers;
>>>>>
>>>>>
>>>>>         GNMManager::GdalCloseNetwork(poNet);
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> thanks,
>>>>> hema
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326.html
>>>>> Sent from the GDAL - Dev mailing list archive at Nabble.com.
>>>>> _______________________________________________
>>>>> gdal-dev mailing list
>>>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=5172509&i=3>
>>>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>>>>
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> gdal-dev mailing list
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=5172509&i=4>
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the
>> discussion below:
>>
>> http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326p5172509.html
>>  To unsubscribe from creating graph for single line shape layer using
>> gdal gnm, click here.
>> NAML
>> <http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
> ------------------------------
> View this message in context: Re: creating graph for single line shape
> layer using gdal gnm
> <http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326p5172529.html>
>
> Sent from the GDAL - Dev mailing list archive
> <http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html> at
> Nabble.com.
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20141113/b6c2f9a6/attachment.html>


More information about the gdal-dev mailing list