Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] use State Plain Coordinates to move vehicle (MoveToXY)

The problem comes from an earlier step because the lon,lat values are
outside the network boundary to begin with (The network covers an area
around lon=-122,lat=37 whereas your lon,lat inputs are widely off the
mark).
It turns out that "CA State Plane NAD83 coordinate" is something differente
altogether from NAD83 (as I was assuming).
You therefore need to convert your values to lon,lat in WSG84 using a
separate projection before converting lon,lat into sumo network coordinates.
This can be done using the python proj library using the appropriate proj4
code (though I'm not sure which one exactly as there appear to be multiple
zones for CA)
see

http://spatialreference.org/ref/epsg/nad83-california-zone-3-ftus/
http://spatialreference.org/ref/epsg/nad83-california-zone-3-ftus/proj4/
proj = pyproj.Proj("+proj=lcc +lat_1=38.43333333333333
+lat_2=37.06666666666667 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000.0001016
+y_0=500000.0001016001 +ellps=GRS80 +datum=NAD83
+to_meter=0.3048006096012192 +no_defs")
lon,lat = proj(x,y, inverse=True)

regards,
Jakob




Am Mi., 10. Okt. 2018 um 08:08 Uhr schrieb Gama Lins de Araujo, Thais <
thais.gama@xxxxxx>:

>     <location netOffset="-561583.51,-4188054.44"
> convBoundary="205.71,83.75,327.03,729.01"
> origBoundary="-122.300034,37.837827,-122.295689,37.846489"
> projParameter="+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m
> +no_defs"/>
>
> lon, lat values for first x2,y2 example with *x2, y2 =
> net.convertLonLat2XY(lon, lat, rawUTM=True**): (This works best) *
> lon=-127.488699 lat=0.000207
> x2=4.956658 y2=22.982225
>
> lon, lat values for first x2,y2 example with *x2, y2 =
> net.convertLonLat2XY(lon, lat):*
> lon=-127.488699 lat=0.000207
> x2=-561578.553342 y2=-4188031.457775
>
> ------------------------------
> *Von:* Jakob Erdmann <namdre.sumo@xxxxxxxxx>
> *Gesendet:* Mittwoch, 10. Oktober 2018 07:57:34
> *An:* Gama Lins de Araujo, Thais
> *Betreff:* Re: [sumo-user] use State Plain Coordinates to move vehicle
> (MoveToXY)
>
> Please post the contents of the <location> element from your .net.xml file
> (to be found at the top of the file). Along with the lon,lat values
> corresponding the the first x2,y2 example.
>
> Am Mi., 10. Okt. 2018 um 06:20 Uhr schrieb Gama Lins de Araujo, Thais <
> thais.gama@xxxxxx>:
>
>> Hello Mr. Jakob, I am very sorry once again, but it still does not work.
>>
>> When I use this:
>>
>> x2, y2 = net.convertLonLat2XY(lon, lat, rawUTM=True)
>>
>> I get these outputs to use in moveToXY:
>>
>> x2=4.956658 y2=22.982225
>> x2=5.009388 y2=34.633814
>> x2=5.097475 y2=45.349363
>> x2=4.368089 y2=57.215837
>> x2=4.624426 y2=69.318226
>> x2=5.126126 y2=81.546192
>> x2=4.925263 y2=95.019266
>> x2=4.932274 y2=108.620357
>>
>> and the vehicle drives on the left side of the road.
>>
>> If I use what you said :
>>
>> x2, y2 = net.convertLonLat2XY(lon, lat)
>>
>> I get this kind of output:
>>
>> x2=-561578.553342 y2=-4188031.457775
>> x2=-561578.500612 y2=-4188019.806186
>> x2=-561578.412525 y2=-4188009.090637
>> x2=-561579.141911 y2=-4187997.224163
>> x2=-561578.885574 y2=-4187985.121774
>> x2=-561578.383874 y2=-4187972.893808
>> x2=-561578.584737 y2=-4187959.420734
>> x2=-561578.577726 y2=-4187945.819643
>> x2=-561578.277498 y2=-4187931.796405
>> x2=-561577.983976 y2=-4187918.083758
>>
>> and the vehicle is nowhere to be seen.
>>
>> Is there anything I can do to fix this issue?
>>
>> Thak you very much for your help.
>>
>> ------------------------------
>> *Von:* Jakob Erdmann <namdre.sumo@xxxxxxxxx>
>> *Gesendet:* Dienstag, 9. Oktober 2018 08:56:19
>> *An:* Gama Lins de Araujo, Thais
>> *Cc:* Sumo project User discussions; sumo-user
>> *Betreff:* Re: [sumo-user] use State Plain Coordinates to move vehicle
>> (MoveToXY)
>>
>>
>> when converting lon, lat to network coordinates, leave out the rawUTM=True.
>> moveToXY requires the shifted positions rather than raw UTM.
>>
>>   x2, y2 = net.convertLonLat2XY(lon, lat)
>>
>>
>>
>> Am Di., 9. Okt. 2018 um 08:03 Uhr schrieb Gama Lins de Araujo, Thais <
>> thais.gama@xxxxxx>:
>>
>>> Hello Mr Jakob,
>>>
>>>
>>> I am sorry to bother again, but I replaced the line of code I had with
>>> the one you provided, and the simulation looks just the same. The vehicle
>>> drives by the side of the road the whole time, and it also seems not to
>>> have the right angle. This is how my code looks like now:
>>>
>>>
>>> x,y = df_dropped_1st_veh_instance['Local_X'].iloc[k], df_dropped_1st_veh_instance['Local_Y'].iloc[k]
>>> lon, lat = net.convertXY2LonLat(x * 0.3048, y * 0.3048, True)
>>> x2, y2 = net.convertLonLat2XY(lon, lat, rawUTM=True)
>>>
>>> traci.vehicle.moveToXY(traci_veh, '', 0, x2, y2, angle, 2)
>>>
>>> for the angle I used INVALID_DOUBLE_VALUE and transformed it to radians.
>>>
>>> Here is a sample of the data I have:
>>>
>>>        Local_X   Local_Y     Global_X     Global_Y
>>> 0       16.467    35.381  6451137.641  1873344.962
>>> 1       16.447    39.381  6451140.329  1873342.000
>>> 2       16.426    43.381  6451143.018  1873339.038
>>> 3       16.405    47.380  6451145.706  1873336.077
>>> 4       16.385    51.381  6451148.395  1873333.115
>>> 5       16.364    55.381  6451151.084  1873330.153
>>> 6       16.344    59.381  6451153.772  1873327.192
>>> 7       16.323    63.379  6451156.461  1873324.230
>>>
>>> Thank you in advance,
>>>
>>> Thais Gama
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------
>>> *Von:* Jakob Erdmann <namdre.sumo@xxxxxxxxx>
>>> *Gesendet:* Montag, 8. Oktober 2018 12:51
>>> *An:* Gama Lins de Araujo, Thais; Sumo project User discussions
>>> *Cc:* sumo-user
>>> *Betreff:* Re: [sumo-user] use State Plain Coordinates to move vehicle
>>> (MoveToXY)
>>>
>>> Hello,
>>> the position conversion functions provided by traci and libsumo only
>>> support the projection embedded in the .net.xml file. In case of an OSM
>>> import this means it will always transform between meters and WGS84 lon,lat.
>>>
>>> Since NAD83 and WGS84 are within 1m of each other, you could use
>>> net.convertXY2LonLat(x_feet * 0,3048, y_feet * 0,3048, True)
>>> (The third argument is for using raw UTM values instead adding the
>>> network offset)
>>>
>>> regards,
>>> Jakob
>>>
>>> Am Mo., 8. Okt. 2018 um 12:24 Uhr schrieb Gama Lins de Araujo, Thais via
>>> sumo-user <sumo-user@xxxxxxxxxxxxxxxxxxxxx>:
>>>
>>>> Hello Mr. Behrisch<https://sourceforge.net/u/behrisch/> / Erdmann<
>>>> https://sourceforge.net/u/namdre/>,
>>>>
>>>>
>>>> I would like to know if there is a way in SUMO that I can directly use
>>>> CA State Plane NAD83 coordinate in feet to move vehicles in a network with
>>>> the moveToXY command, or do I need to do any transformations before hand?
>>>>
>>>>
>>>> When I use this piece of code (I got from
>>>> http://sumo.dlr.de/wiki/Tools/Sumolib#coordinate_transformations) I
>>>> seem to get reasonable results for latitude and longitude, but the x and y
>>>> resulting from conversion are not matching the network. When I run this
>>>> code:
>>>>
>>>>
>>>> x,y = df_dropped_1st_veh_instance['Local_X'].iloc[k],
>>>> df_dropped_1st_veh_instance['Local_Y'].iloc[k]
>>>> #x, y = traci.vehicle.getPosition(traci_veh)
>>>> lon, lat = traci.simulation.convertGeo(x, y)
>>>> x2, y2 = traci.simulation.convertGeo(lon, lat, fromGeo=True)
>>>> #x, y = net.convertLonLatXY(lon, lat)
>>>> print 'x=%4.6f y=%4.6f' % (x2, y2)
>>>>
>>>> the vehicle drives off the road network the whole time. In this case I
>>>> am using the local coordinates (Local_X and Local_Y) which are described
>>>> as: "Lateral (X) coordinate of the front center of the vehicle with respect
>>>> to the left-most edge of the section in the direction of travel". When I
>>>> use the Global coordinates (Global_X and Global_Y) my vehicle will just
>>>> stand outside the network for the whole time, and those are the actual geo
>>>> coordinates, described as such: "CA State Plane NAD83 coordinate".
>>>>
>>>> i know my network is in datum=WGS84, by the information given in the
>>>> network xml file, and that it is shifted by the netOffset parameter.
>>>>
>>>> I wonder if that might be the problem?
>>>>
>>>> <location netOffset="-561583.51,-4188054.44"
>>>> convBoundary="205.71,83.75,327.03,729.01"
>>>> origBoundary="-122.300034,37.837827,-122.295689,37.846489"
>>>> projParameter="+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m
>>>> +no_defs"/>
>>>>
>>>>
>>>> PS.: i need high accuracy and precision, the vehicles should move
>>>> exactly according to my coordinates, provided in the data I have. The data
>>>> is very big (more than 1Gb), so I am sending only a subset of it, which
>>>> refers to one car only. And also my code and files to run the simulation,
>>>> in case those are needed.
>>>>
>>>>
>>>> Thank you in advance for your help,
>>>>
>>>>
>>>> Thais
>>>> _______________________________________________
>>>> sumo-user mailing list
>>>> sumo-user@xxxxxxxxxxxxxxxxxxxxx
>>>> https://lists.sourceforge.net/lists/listinfo/sumo-user
>>>> _______________________________________________
>>>> sumo-user mailing list
>>>> sumo-user@xxxxxxxxxxx
>>>> To change your delivery options, retrieve your password, or unsubscribe
>>>> from this list, visit
>>>> https://dev.eclipse.org/mailman/listinfo/sumo-user
>>>>
>>>

_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/sumo-user


Back to the top