Is there a way to animate value change in a static point/geohash in time? - mapbox

I have a dataset of geographic points (lat, lon) and geohash values that each corresponds to a specific depth value in time. Meaning for each point and geohash I have a water depth value in that point from various dates, for example:
lat
lon
geohash
depth
date
-21.41
-40.91
7h4yhy6vx
9.4
2023-01-18
-21.24
-40.88
7h4zjv2h4
6.23
2023-01-18
-21.37
-40.84
7h4yqttnx
7.85
2023-01-18
-21.41
-40.91
7h4yhy6vx
9.1
2023-01-22
-21.24
-40.88
7h4zjv2h4
6.17
2023-01-22
-21.37
-40.84
7h4yqttnx
8.1
2023-01-22
-21.41
-40.91
7h4yhy6vx
8.5
2023-01-26
-21.24
-40.88
7h4zjv2h4
6.19
2023-01-26
-21.37
-40.84
7h4yqttnx
8.62
2023-01-26
I want to animate the change in each point's depth across time, using WebGL based tools. Is there a way to do that?
My stack:
React JS
Mapbox
Deck GL
I tried using DeckGL's TripLayer by adding the depth attribute to the list of coordinates and changing the color of the points by this value, but it didn't work.
I can't find any other web based tool to animate change in static points over time, does anyone know that kind of tool?

Related

QGIS not rendering PostGis Geometry column correctly

I'm currently storing a lot of data on a Azure SQL for Postgres instance. My table consists of columns like lat, lon, and geometry which is created using PostGis function
ST_SetSRID(ST_MakePoint(lat,lon),4326))
However, when I import the table into QGIS using a filter on an identifier column and between two timestamps the QGIS Query Builder clearly shows a decent number of records being returned. However, QGIS (I've tried Google Map, OpenStreetMap) renders the Geometry points near Africa (see screenshot below). Looking at some lat and lon pairs on maps.google.com that make up the geometry points, the location is completely different from what QGIS shows.
I've changed the CRS of the project, the Layers for the Map and the Coordinates (i.e. geometry points) to 4326. But still all the data points show up near Africa.
Any ideas what may be causing this and how to resolve it?
PostGIS convention is to pass longitude first (as X coordinate) and latitude second (as Y). So try
ST_MakePoint(lon, lat, 4326)

Mapbox Unity SDK: storying and displaying short relative distances

I was wondering how I can go about storing and displaying small, but geographically accurate distances in the mapbox unity SDK?
I'm storing radius' about markers on a map, I get the value in meters (from ~0.5m-10m), and then, adaptively with the zoom level, I want to accurately display those meters in Unity world space (draw an ellipse) using these stored values. The problem is that the mapbox api from my understanding only lets you to convert lat/long to unity world coordinates and I'm running into precision errors. I can get adequate precision when using the CheapRuler class and meters, but as soon as I use the _map.GeoToWorld(latlon) method the precision is lost.
How would I go about keeping adequate precession, is there a way I can use the marker as the reference point and the radius as the offset, and get the relative unity world coordinate distance (of the radius) that way? I know you can also store scale relative to the mapbox tiles, but I'm not sure how I can convert that back to a unity world distance. I'm operating on very small distances, so any warping due to lat/long being a Mercator projection can probably be ignored.
I figured out a round-about solution.
First I convert the meters into unity world space using whatever IMapScalingStrategy Mapbox is currently using.
Then I convert from world to the view space of whatever camera I want to scale to the given bounds.
After that, I use find out the scale of the bounds, solving for:
UnityRelativeScaleChange = 2Map Zoom Level Change; which (to my estimations) is the relationship between unity scale and mapbox zoom levels.
This solutions works great as long as you don't have to zoom in/out by too much, otherwise you'll run into precision problems as the functions rely on the relative view-based size of a given bounds to do their calculations which will lead to unstable results if those initially take a tiny portion of the screen.

Lat/Long spatial reference

I am new to PostGIS, am not getting the area of polygon right, my sample data is from Google maps, I know the area of the polygon is 11 acres, but the area returned by st_area doesn't match,
I already referred to a few links like below, but unable to resolve the issue, Internet says google follows 4326 Spatial references, I tried a lot, can you please help, Image attached is the polygon from google maps.
I am expecting an array of such coordinates from the user, I have to calculate the area from PostGIS and give an error back to the user if the area entered is not approximated to calculated area.
https://gis.stackexchange.com/questions/169422/how-does-st-area-in-postgis-work
How do I convert a latitude/longitude pair into a PostGIS geography type?
https://gis.stackexchange.com/questions/56862/what-spatial-reference-system-do-i-store-google-maps-lat-lng-in/56925
17.475197 78.389024
17.4771 78.39044
17.475657 78.391652
17.474408 78.390847
17.475197 78.389024
l_polygon_text='MULTIPOLYGON(((
17.4771000000000001 78.3904399999999981,
17.4751970000000014 78.3890240000000063,
17.4756570000000018 78.3916519999999934,
17.4751970000000014 78.3890240000000063,
17.4744080000000004 78.3908469999999937,
17.4771000000000001 78.3904399999999981)))';
st_area(ST_GeometryFromText(l_polygon_text,4326))
st_area(ST_GeometryFromText(l_polygon_text,2163));
st_area(ST_GeometryFromText(l_polygon_text,2249));
st_area(ST_GeometryFromText(l_polygon_text,3859));
ST_AREA(ST_Transform(ST_GeomFromText(l_polygon_text,4326),31467));
ST_Area(ST_Transform(ST_SetSRID(ST_GeomFromText(l_polygon_text),4326),900913));
polygon
In PostGIS, coordinates must be expressed as longitude first, then latitude. Google uses the opposite.
After swapping the coordinates to the proper order, you can't directly call st_area, else you would get an area in "square degrees" which is meaningless. You would have to project to a suitable local coordinate system, or you can use the geography type which will return an area in m2.
select st_area(st_geogFromText('MULTIPOLYGON(((78.3904399999999981 17.4771000000000001, 78.3890240000000063 17.4751970000000014,78.3916519999999934 17.4756570000000018,78.3890240000000063 17.4751970000000014,78.3908469999999937 17.4744080000000004,78.3904399999999981 17.4771000000000001)))'));
st_area
--------------------
26956.897848576307
That being said, the example you have provided is about 6.5 acres, not 11, because the polygon is not properly defined:

how to use st_intersection() with re-projection in POSTGIS?

This is a shipping route from 'portland to busan' and I want to check the route against land_polygons like how much distance is traveled by a route through land.And the problem is while checking the land intersection it consider as if the route is passing through North America,Europe etc. though it is not passing through any land region in real.
SELECT sum(ST_Length(ST_Intersection(route::geography,polygon))) as intersection
FROM land_polygons l,
routes t
where t.route_id = ? and
ST_intersects(route::geometry,geom);
postgis version:
POSTGIS="2.1.7 r13414" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0,
6 March 2012" GDAL="GDAL 1.10.1, released 2013/08/26" LIBXML="2.9.1"
LIBJSON="UNKNOWN" TOPOLOGY RASTER
How is the route being constructed? It looks like it's being constructed until the date-line, and then from that as a straight line to the "next" date-line, to destination.
You should be constructing these routes as great circle distances, between the sea points.
Interesting blogs/answers:
https://gis.stackexchange.com/questions/109562/does-postgis-have-a-vincenty-distance-calculation
https://gis.stackexchange.com/questions/84443/what-is-this-postgis-query-doing-to-show-great-circle-connections
http://anitagraser.com/2011/08/20/visualizing-global-connections/
The key to all of these examples is the use of ST_Segmentize, that will create many vertices along a projected line, virtually "bending" the line.
After the route construction problem is handled (you are indeed connection two points that are not on the route, going over land), use the spheroid distance functions to get an accurate measure.

Using OSM and EPSG:4326 with openlayers increase latitude in near 90 degrees. Why?

I am using openLayers and creating a OSM base layer. By default the layer use EPSG:900913 and the coordinates are in meters. I want to use coordinates in degrees with EPSG:4326 so I initilize layer with:
base_layer.addOptions({ sphericalMercator: true,
projection: new OpenLayers.Projection('EPSG:4326')}, true);
Now the map uses degrees but have the next problem: The point with latitude 37.296 and longitude -5.929 (http://www.openstreetmap.org/?lat=37.296&lon=-5.929&zoom=12&layers=Q# and the same coordinates in Google Maps) appears to me (moving map and executing map.getCenter() in firebug) in lat. -49.75, lon. -5.929.
Why? How can I use an OSM layer with same degrees coordinates as in openstreetmap.org and as are returned by nominatim.openstreetmap.org?
You can't just claim the layer is EPSG:4326 when the tiles you are displaying are actually rendered in EPSG:3857. That is nonsensical.
I'm not quite clear on what you are trying to do here to be honest, but it may help to set displayProjection to EPSG:4326 which will cause OpenLayers to use degrees when it is communicating values to/from the user.
If you want to to read or set the map location in code then you will need to reproject the value you get from getCenter or give to setCenter yourself by calling the transform method on the location value.