matsim-org / matsim-code-examples

A repository containing code examples around MATSim
GNU General Public License v3.0
83 stars 179 forks source link

How to select the nearest node in MATSim? #506

Open jyj0712 opened 3 years ago

jyj0712 commented 3 years ago

Hi,

I'm a beginner at MATSim.

I would like to select the nearest node and assign a link by simply changing the code of the config.xml file to be uploaded to the MATSim GUI. I have a network file and a plan file. However, x,y coordinates do not match the plan file and the network file. For example, in the plan file, x="306306" y="547256", but in the network file, the coordinates of the node are shown as x="306306.40625" y="53310.75" and x="306306.34375" y=" 5475.875.875.875.85.

I think there is an error because the x and y coordinates do not match exactly. (Because no error occurs when I modify x,y in the plan file to x,y coordinates in the network file.)

Therefore, I would like to select x,y coordinates (306306,547256) from the nearest network file, x,y coordinates (306306.40625, 533160.75 or 306306.34375,547263.875).

Also, I would like to know how to change the coordinate system in the config.xml file. In my opinion, maybe I change the value of "coordinateSystem" from "Atlantis" to something else (shown in bottom code). But I don't know what's in the value. So I would appreciate it if you could tell me where I can find the value and which value I should change to if I want to use the WGS84 coordinate system.

Thanks a lot :)

JWJoubert commented 3 years ago

Firstly, you have to use a projected coordinated reference system (CRS), which measures distance in metres (typically), so you cannot use the WGS84 (measured in decimal degrees).

You cannot, as far as I know, just change something in the config.xml file that will align the coordinates. I am not 100% sure I understand your concern. The activity locations of agents (the coordinates in the plans file) need not be exactly the same as the coordinates in the network file. For example, your house's coordinates may be some distance away from the closest road network... that's perfectly fine. At the start of the mobility simulation, there is a process called PersonPrepareForSim that (as far as I understand) will ensure that the activity location is associated with the closest link in the network (provided the plans and network coordinates are using the same coordinate reference system).