networkbuilder + geography and GIS

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

networkbuilder + geography and GIS

Taylor Anderson
Hi all,

The popular Repast zombie tutorial using java employs a NetworkBuilder that allows you to visualize the infection network. I was wondering if there is anything similar that can be used with the Geography/GIS context. Alternatively, any thoughts on how I could construct my own? For example, if my agent moves from point A to point B, can I write a function that will draw a vector connecting the two?

Thank you very much,

Taylor

Taylor Anderson BES, MSc
PhD Candidate, Geography
Spatial Analysis and Modeling Lab
Simon Fraser University, Vancouver, Canada

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: networkbuilder + geography and GIS

Taylor Anderson
Hi all,

I found a way to construct my own network. I don't have time at the moment to provide the code, but I certainly will next week for anyone who is looking to do the same in the future.

Cheers,

Taylor

Taylor Anderson BES, MSc
PhD Candidate, Geography
Spatial Analysis and Modeling Lab
Simon Fraser University, Vancouver, Canada

----- Original Message -----
From: "Taylor Anderson" <[hidden email]>
To: "repast-interest" <[hidden email]>
Sent: Thursday, February 16, 2017 3:44:49 PM
Subject: networkbuilder + geography and GIS

Hi all,

The popular Repast zombie tutorial using java employs a NetworkBuilder that allows you to visualize the infection network. I was wondering if there is anything similar that can be used with the Geography/GIS context. Alternatively, any thoughts on how I could construct my own? For example, if my agent moves from point A to point B, can I write a function that will draw a vector connecting the two?

Thank you very much,

Taylor

Taylor Anderson BES, MSc
PhD Candidate, Geography
Spatial Analysis and Modeling Lab
Simon Fraser University, Vancouver, Canada

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: networkbuilder + geography and GIS

Juan José Pérez Consuegra
In reply to this post by Taylor Anderson
Hello Taylor,

I'm in the same point at this moment, I would appreciate your help if you could manage whith it very much.

Regards,

Juanjo.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: networkbuilder + geography and GIS

Ozik, Jonathan
In reply to this post by Taylor Anderson
Taylor,

Thank you for offering to share the code with the list.

Jonathan

> On Feb 18, 2017, at 9:21 PM, Taylor Anderson <[hidden email]> wrote:
>
> Hi all,
>
> I found a way to construct my own network. I don't have time at the moment to provide the code, but I certainly will next week for anyone who is looking to do the same in the future.
>
> Cheers,
>
> Taylor
>
> Taylor Anderson BES, MSc
> PhD Candidate, Geography
> Spatial Analysis and Modeling Lab
> Simon Fraser University, Vancouver, Canada
>
> ----- Original Message -----
> From: "Taylor Anderson" <[hidden email]>
> To: "repast-interest" <[hidden email]>
> Sent: Thursday, February 16, 2017 3:44:49 PM
> Subject: networkbuilder + geography and GIS
>
> Hi all,
>
> The popular Repast zombie tutorial using java employs a NetworkBuilder that allows you to visualize the infection network. I was wondering if there is anything similar that can be used with the Geography/GIS context. Alternatively, any thoughts on how I could construct my own? For example, if my agent moves from point A to point B, can I write a function that will draw a vector connecting the two?
>
> Thank you very much,
>
> Taylor
>
> Taylor Anderson BES, MSc
> PhD Candidate, Geography
> Spatial Analysis and Modeling Lab
> Simon Fraser University, Vancouver, Canada
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: networkbuilder + geography and GIS

Taylor Anderson
Hi all,

Below is my code... its quite simple and it works. The code is for the visualization of the network only. If you wish to integrate network topology into the nodes, it's a little more complicated. Let me know if you have any questions or even suggestions. I am not a java expert, so kindly bear with me.

public class Me {

//variables...
//initialize class...
//getters and setters...

@ScheduledMethod...
//method to decide on a target object to move to (technically a network node) called t
public void target() {

//get my coordinates
Context context = ContextUtils.getContext(this);
Geography<Object>geography = (Geography) context.getProjection("Geography");
Geometry geom = geography.getGeometry(this);
Coordinate coord = geom.getCoordinates()[0];

//get coordinates of the target
Context tcontext = ContextUtils.getContext(t);
Geography<Object> tgeography = (Geography) tcontext.getProjection("Geography");
Geometry tgeom = tgeography.getGeometry(t);
Coordinate tcoord = tgeom.getCoordinates()[0];

visualizeNetwork(coord, tcoord);
moveTo(t)

}

//method to build network
public void visualizeNetwork(Coordinate coord, Coordinate tcoord) {

//build lineString between two coordinates
GeometryFactory fac = new GeometryFactory();
Coordinate [] coords = new Coordinate [] {coord, tcoord};
Nets networks = new Nets (geography, context);
Context.add (networks);
//make sure you choose createLineString using a sequence of coordinates
geography.move(networks, new GeometryFactory().createLineString(coords));

}

//move to next target
public void moveTo(){

...

}

}

Note:
You will need to create a class that represents the network (I created one called Nets) and instantiate it in your DataLoader class (in the tutorial its the JZombiesBuilder). You will then need to remove the first instance of it. This was a work around in an older Repast... I wonder if it's necessary anymore.
Do not call the network class NetworkBuilder.
You will need to build a display that displays the network class as a line.

Taylor  

Taylor Anderson BES, MSc
PhD Candidate, Geography
Spatial Analysis and Modeling Lab
Simon Fraser University, Vancouver, Canada

----- Original Message -----
From: "Ozik, Jonathan" <[hidden email]>
To: "Taylor Anderson" <[hidden email]>
Cc: "repast-interest" <[hidden email]>
Sent: Monday, February 20, 2017 6:38:10 AM
Subject: Re: [Repast-interest] networkbuilder + geography and GIS

Taylor,

Thank you for offering to share the code with the list.

Jonathan

> On Feb 18, 2017, at 9:21 PM, Taylor Anderson <[hidden email]> wrote:
>
> Hi all,
>
> I found a way to construct my own network. I don't have time at the moment to provide the code, but I certainly will next week for anyone who is looking to do the same in the future.
>
> Cheers,
>
> Taylor
>
> Taylor Anderson BES, MSc
> PhD Candidate, Geography
> Spatial Analysis and Modeling Lab
> Simon Fraser University, Vancouver, Canada
>
> ----- Original Message -----
> From: "Taylor Anderson" <[hidden email]>
> To: "repast-interest" <[hidden email]>
> Sent: Thursday, February 16, 2017 3:44:49 PM
> Subject: networkbuilder + geography and GIS
>
> Hi all,
>
> The popular Repast zombie tutorial using java employs a NetworkBuilder that allows you to visualize the infection network. I was wondering if there is anything similar that can be used with the Geography/GIS context. Alternatively, any thoughts on how I could construct my own? For example, if my agent moves from point A to point B, can I write a function that will draw a vector connecting the two?
>
> Thank you very much,
>
> Taylor
>
> Taylor Anderson BES, MSc
> PhD Candidate, Geography
> Spatial Analysis and Modeling Lab
> Simon Fraser University, Vancouver, Canada
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: networkbuilder + geography and GIS

Tatara, Eric R.
In reply to this post by Taylor Anderson
I wrote a projection listener class that will manage Repast network objects in a geography projection that can be visualized in a GIS display.  The attached listener class can be placed in your project and used in the ContextBuilder to link a Geography and Network projection like this:

GeographyParameters geoParams = new GeographyParameters();
Geography geography = GeographyFactoryFinder.createGeographyFactory(null)
                                .createGeography("Geography", context, geoParams);
               
NetworkBuilder<Object> netBuilder = new NetworkBuilder<Object>(
                                "Network", context, true);
Network net = netBuilder.buildNetwork();
               
GISNetworkListener netListener = new GISNetworkListener(context, geography, net);

The GIS NetworkListener binds the geography and network within the specified context such that changes in one will be reflected in the other.  This handles agent movement, additions, and removal from the geography along with network add/remove edge events.   If you have multiple networks you can create separate listener instances for each.   As long as the Repast network and geography projections are otherwise used normally in your code, no additional code is required to update events between the projections.  To visualize the network edges in the GIS displays, you will need to create a simple edge class that extends RepastEdge, for example the attached MyNetworkEdge class.  This is only because the display wizards need a user class for styling.  In the displays, you can select the MyNetworkEdge class in the agent types dialog and specify either a line type or style class like the attached MyNetworkStyle class.  To create links in the Repast network, you will need to use the add and remove edge methods with the MyNetworkEdge, e.g.

net.addEdge(new MyNetworkEdge(source, target));

and you can of course add more capabilities to the MyNetworkEdge class as needed.

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory

-----Original Message-----
From: Taylor Anderson [mailto:[hidden email]]
Sent: Thursday, February 16, 2017 5:45 PM
To: repast-interest <[hidden email]>
Subject: [Repast-interest] networkbuilder + geography and GIS

Hi all,

The popular Repast zombie tutorial using java employs a NetworkBuilder that allows you to visualize the infection network. I was wondering if there is anything similar that can be used with the Geography/GIS context. Alternatively, any thoughts on how I could construct my own? For example, if my agent moves from point A to point B, can I write a function that will draw a vector connecting the two?

Thank you very much,

Taylor

Taylor Anderson BES, MSc
PhD Candidate, Geography
Spatial Analysis and Modeling Lab
Simon Fraser University, Vancouver, Canada

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

GISNetworkListener.java (6K) Download Attachment
MyNetworkEdge.java (304 bytes) Download Attachment
MyNetworkStyle.java (1K) Download Attachment