0

I'm developing an application which uses PostGIS functions for measurements in the USA. In nutshell: the software is running in a car and use PostGIS functions in real time. For example: to measure distance of the nearest object (ST_Dwithin) and decide wheter the car is within a protected area or not (ST_Intersects). It is important that the function should be called at least 5 times in every seconds, so the running time is very important.

The input parameter of the function is the current GPS position, and returns with distance values (in meters). In addition to this: Important: I have to calculate the distance of the nearest objects within 0.4 mile.

I have polygon datasets that contain the special areas in WGS84 (EPSG:4326).

Now, I have to choose a suitable projection for this purpose (measurements of distances). The problem is that this software should be able to run in any sates within the USA (except for Alaska and the islands).

Is it possbile to use one CRS for this job or I have to split the polygons and use different projections in every states (this method would make a lot of difficulties)?

I don't want to use Geography data type because it is much slower than the geography.

What do you think, which CRS would be the best for this task?

I read many articles regaring this topic, but I'm still confused about the accuracy. I have to measure relatively short distances (maximum 0.4 mile).

4
  • 2
    I doubt the accuracy of your GPS unit will be high enough to need 0.2 sec intervals, or in many cases to allow you to hit a .4 mile buffer with confidence.
    – Ian Turton
    Jan 31, 2020 at 9:15
  • Yeah, you probably need to go back to the drawing board on this. The technology probably only will support sampling every 3-5 aeconds, with 10-20 meter accuracy. If you know the intended route, you can snap to that, otherwise you'll need some pretty sophisticated analysis churning in the background and reporting violations within a minute or two of their occurance, with only moderate confidence.
    – Vince
    Jan 31, 2020 at 11:15
  • This is a 20hz GPS receiver, but without RTK. The max. speed of the car is 40 mph.
    – zsoooc
    Jan 31, 2020 at 11:44
  • Let me say this: use a sphere. Choose a sphere that intersects the ellipsoid at the center of the range of latitudes. And proyect that sphere to a conus. Choose two standard parallels (manuals say at one-sixth and five-sixths of the range of latitudes), and make the conus intersect the sphere there. Reproject all your data in that plane. Then, when you get geographic coordinates, project them in real time to the conus as if they where given from a spheric datum, and perform your spatial computations there. You will get deformations using an ellipsoid too, same but slower. Just an opinion. Feb 1, 2020 at 8:16

1 Answer 1

1

I don't really get why you can't use Geography data directly, and let Postgis do the work. This kind of computation usually work in a few ms, the computation itself is generally way less than or the other costs (like reading data). If you have performance issues, maybe the problem is not the projection but the request or the indexes.

If you really are in a case where the projection cost begin to be important, maybe you shouldn't use postgis but write it directly to optimize the data loading, where there should be way more to gain. You can also look at the way Postgis choose the more fitting projection when you ask problems like intersection on 4326 data, by choosing the best UTM projection for the request.

And if you really think that using a projection is better, you can look at this post.

4
  • Given your geofencing problem, there should be many ways to optimize the data management. For exemple, the car won't teleport to the other way of the country, so you don't need to test all the polygons all the time. You can for exemple get the polygons in a few miles around every minute, and only work with with them when you do your check. Also, if your check needs to have a 0.4 mile precision, do you really need to do it multiple times by seconds ? Feb 3, 2020 at 9:30
  • Also, you can try to set the parameter use_spheroid to false in the ST_DWithin function (on geographical data) to fasten a little the computation by using a sphere instead of a spheroid. Feb 3, 2020 at 9:44
  • No, far better than 0.4 miles precision needed. My function searches for the nearest object WITHIN 0.4 miles, so I don't want to measure long distances, but need better precision.
    – zsoooc
    Feb 3, 2020 at 12:02
  • Ok. if you have performance issues and you want good precision, you should definitly periodically gather polygons in a few miles around the given point, and use the best local projection (at least you can use the best local UTM, for exemple: gis.stackexchange.com/a/269552/120505) Feb 3, 2020 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.