Spatial geometry columns vs float/decimal columns in storing longitude/lattitude - postgresql

I need to store and give out long/lat coordinates and display on google maps. I would need to store points, lines, and polygons. Then add metadata on them to for generating info.
Currently looking into postgis, and it seems a fair bit to absorb. Now I'm wondering if I need to delve into it.
Is it advisable to use a spatial database for the said purpose? or using float/decimal columns for long/lat is fine?

Currently looking into postgis, and it seems a fair bit to absorb. Now I'm wondering if I need to delve into it. Is it advisable to use a spatial database for the said purpose? or using float/decimal columns for long/lat is fine?
It is a lot to absorb. Storing as a float/decimal gets you nothing. Nothing at all. Spatial functions require spatial types. You gotta learn it. You don't have to learn all of it, but you have to learn it. And, it's not too hard to get started.
CREATE TABLE foo(id,geom)
AS
VALUES ( 1, ST_MakePoint(long,lat)::geography );
Etc.
I highly suggest PostGIS in Action 2nd Edition

If the only thing you need is store and give out, then float/decimal columns would be more than enough. However, if you are querying for spatial relations (whether a point is located within a polygon, whether polygons intersect etc.), you'd better to use either PostGIS or, for instance, MySQL extensions for spatial data.

Related

Is here any standard CRS name for plain 2D data aka non-Earth projection?

I'm interested in using different geotools for work with spatial data, but without Earth projection, plain 2D like big game maps. But I'm struggling each time to configure a tool that way.
Hence the question: does exist some standard projection name for GDAL, MariaDB, etc? I've tried to find any, but no luck. This seems strange, might be a quite common user case.

GeoTools filters for shapefiles

I am looking at using GeoTools to read shapefiles. The tutorial for using it is straightforward showing how to set a filter to "Filter filter = Filter.INCLUDE;" to specify everything.
I want to split up the reading for performance purposes on very large shape files. In essence I want to split the reading of the info in the DBF file from the reading of the "THE_GEOM" data. We have a lot of our own filtering already built and it is easier to just use it and then retrieve the actual geometry as required.
How do I specify a filter to retrieve all the DBF info without the geometry?
How do I specify a filter to retrieve the geometry without the DBF info? This isn't as important since it probably won't impact performance so much but I would like to know.
Thanks.
By design the GeoTools' Shapefile Datastore goes to great lengths to keep the geometry and the attributes (the DBF stuff) together. So you are going to have to poke around in the internals to be able to do this. So you could use a DBFFileReader and a ShapefileReader to split the reading up.
I would consider porting your filters to GeoTools as it gives you the flexibility to switch data sources later when Shapefiles prove too small or too slow. It might be worth looking at the CQL and ECQL classes to help out in constructing them.
If you are really dealing with large Shapefiles (>2Gb) then going with a proper spatial database like PostGIS is almost certainly going to give better performance and GeoTools will access the data in exactly the same way with exactly the same filters.

What is the best data structure to store road network data

I am working on a map-matching/trajectory matching project. What I am unsure after reading a number of research papers is what is the most efficient data structure to store the road network (described by a weighted directed graph) so as to facilitate real time searching (Fast). I am getting things like grids, MTrees, Quadtrees...do I need a database in the backend for these. I am working on MATLAB at the moment but can shift languages. What are the programming languages used in actual satellite navigators.
Help will be much appreciated
There are many such index structures like K-D Trees, R-Trees etc. that can be built on the data that you store on the database. You can store your data on SQL Server and use these indexes. You might also want to take a look at SQL Server Spatial tools that helps to perform Spatial queries on your data.

Links to files outside a PostgreSQL database

A stupid newbie question: I want to make a PostgreSQL (9.2.2 with PostGIS 2.0.1; on 32-bit Windows XP) database with rasters saved outside the database (I will need the rasters to be accessed from outside the database and they won't be uploaded/migrated frequently, so consistence is not an issue). My problem is: I don't know how to make the links to the rasters (from database with metadata), and I didn't find anything comprehensible enough.
I have found something about data wrappers, but they seem to be intended for data with table structure, not files like rasters. DATALINK seems better, but I'm afraid it's the same case, plus I'm not sure I understood how to use it. In some of the discussions I've found a mention of symbollic links, but these seem to be something Unix-based, and probably only vaguely related.
I'm sure it must be simple, but I didn't manage to solve it myself.
Databases provide no possibilities to link outside objects.
I can think of at least 2 approaches:
Save a full path to your files in some metadata table as one of the attributes or type text. Don't use it for joining tables in queries though, having artifitial key of internal numeric type (like integer or bigint) is a better choice for performance reasons;
Name your raster files according to their numeric keys in the database. This approach has a drawback — without database you will not be able to obtain any usefull info about your files.
Further paths depends on the complexity of your system and choosen optimization techniques.

mongodb: inserting and querying geometries and WMS

I am discovering mongodb, looks nice but i am still wondering if it can solve my needs.
The question is that we have 16 million point data and we want to cross some part of it with polygons to get statistics (how many points in each polygon).
Basic geometries would be cell degrees (1 degree, 0.5 degree...) covering all the world. In that case the $within function would work, right?
But I wonder, how do I insert these geometries (coming from a shapefile) inside mongodb? Till now I was using postgreSQL-postGIS, and for that I have a lot of tools, but for mongodb...I am also wondering if more complex geometries could be inserted and queried against points.
MongoDB only provides JSON as result, right? if we want to plot some hundreds of points it would be no problem, but hundreds of thousands to be converted to vectorial data via javascript... is for this reason that WMS services are useful, as they provide one image.
Any hope to connect mongodb to any WMS? I saw someone announcing a plugin for Geoserver but it makes a year ago and nothing happened since then.
In case it is not possible, about how many GeoJSON features can be plotted at time keeping a nice browser performance?
Not much help, but I saw a talk on someone who added MongoDB as a back end to GeoServer last year.
IIRC, he said he would open source it (if his company approved), so maybe it's worth tracking him down.
EDIT: Looks like he got approval. Dug up some code here but not sure where associated documentation is. The Geotools/opengeo mailing list is where I found that.
I'm also starting to investigate using NoSQL for geographic data.
There is an article
The example code Python, PyMongo and the OGR libraries to convert shapefiles to a MongoDB collection and vice versa.