[GIS] Using geometry or point for postgis

hibernate-spatiallatitude longitudepostgisst-geometry

I have a table with points that has lon/lat, i am adding postgis to my app. I am doing some tests and I found type POINT and type GEOMETRY. I want to convert my columns lon and lat to a point. For what i was reading it made more sense to add column of type POINT, but most examples I have seeing use geometry to store points.

@Column(columnDefinition="Point")
    private Point locacion;

Should I use geometry or geography instead of points. I am planning on using this points to find other points within a certain radius of meters

Best Answer

POINT is type of GEOMETRY though there is also a native POINT datatype in Postgres (Which as the name implies only deals with point features), I have mostly used Point as a geometry type in PostGIS.

There is also a data type of geography in PostGIS but it is limited to only geographic coordinate systems (According to the documentation it is restricted to WGS 84: SRID 4326, I haven't used it much myself so I'm not sure how it deals with spatial functions and queries) which means that you wont be able to use spatial queries in meters (which require a projected coordinate system)

Your best bet would be to import your GPX files into postgres using this guide, once you have your data in postgres you should be able to reproject it as you want and run spatial queries using meters.

PS: As Micah pointed out, using Geography datatype will return the results of the spatial queries you need in meters, however the Geography datatype is till limited to the lat/long based system so you need to be sure thats what your data uses.

Related Question