Hot answers tagged

4

I like to use the json_build_object function. SELECT row_to_json(fc) FROM ( SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM ( SELECT 'Feature' As type , ST_AsGeoJSON(lg.geometry)::json As geometry , json_build_object( 'attribute1', attribute1, 'attribute2', ...


4

If you're happy with the characteristics of your projection, you should just use ST_Distance(geometry, geometry). In your example you seem to be in UTM, which is a pretty good projection, so why not? It's much much less CPU intensive than the geodetic functions ST_Distance(geography, geography). (Note that ST_Distance_Spheroid() just calls into the same ...


3

You seem to have a PostGIS installation that was created by loading the postgis.sql file, rather than using the CREATE EXTENSION postgis command. So when you dumped your database, you got not only the data, but also all the function definitions, which includes references to the 2.1 PostGIS library. Install PostGIS 2.1.8 on your new system. Create a blank ...


2

Rebuilding from source worked for me also. The problem wasn't realy system upgrade. Simply, creating extensions such as postgis_topology or postgis_tiger_geocoder threw exactly the same error. I advise also restarting postgresql service after rebuilding, just in case. Or better : -stop the service; -rebuild; -start again the service; And it might be ...


2

900913 was the Google Mercator SRID. The new one is 3857. The spatial_ref_sys table in my installation of PostGIS no longer contains 900913, only 3857 remains.


2

Over at geofabrik you can download up-to-date shapefiles with selected osm attributes. They have even have categorized per country. Once downloaded and sorted the data that you need; you can upload your data to your postgis using a variety of tools depending on your project: Qgis, gdal, shp2pgsql and others. Also take heed, the data are in WSG84 (4326) so ...


2

OGR method, courtesy of this page: from osgeo import ogr conx = ogr.Open('PG:dbname=my_db user=postgres password=12345678') sql = 'SELECT * FROM table_name LIMIT 10;' for row in conx.ExecuteSQL(sql): print row.GetField(0) #gets first column, usually the id Another way: Adapted from here. Doesn't use ogr but it does let you access the data a bit more ...


1

There are several alternatives using CARTO to solve the points-overlapping problem. First, if you have a timestamp column and the deaths have happened in two different dates, you can use Torque. That is an animated map. Second, the Wizard of the old Editor allow you to aggregate points in clusters, intensity or density maps. But my favorite example is using ...


1

The unit of measure for 900913 or EPSG:3857 is not a meter. Please do not use this projection for measuring distances. This is a sphere-based Mercator projection of ellipsoid coordinates, which throws conformality out the window. The unit of measure is technically a "non-Earth" meter, and the map gets stretched as you move further away from the equator. ...


1

Your syntax is wrong. But in the documentation is exactly the example given you need. Just took an example for streetname from the first basic example in the documentation an put it together to an insert statement. Did not test it. It is also important how your table is structured and that you have the appropriate columns as it is needed for the correct ...


1

Paolo Corti provides an excellent answer on the postgis mailing list Use ST_Segmentize and then ST_DumpPoints, like this: SELECT ST_AsText((dp).geom) As wkt_geom FROM ( SELECT ST_DumpPoints( ST_Segmentize( ST_GeomFromText('LINESTRING(1 30, 15 30)',28992), -- this is the defined distance 1 ) ) ...



Only top voted, non community-wiki answers of a minimum length are eligible