Hot answers tagged

5

If you have imported a planet or extract some time ago and have now downloaded a (much) newer planet or extract: It does not really make sense to do any updating as I think calculating and applying the diff will not save you time. Just re-run osm2pgsql again and it will remove the tables and create new ones resulting in updated data. If you want to keep ...


4

QGIS + PostGIS should handle a 400 MB dataset without too much grief, give it a try. One of the most important aspects is to ensure you have a spatial index of the geometry column, e.g. CREATE INDEX roads_geom_idx ON roads USING gist (geom); which will allow it to load quicker in QGIS when you zoom into a specific area. And if you are classifying / ...


4

There is a configuration switch for this in GDAL 2.1 onwards: http://www.gdal.org/drv_geojson.html It defaults to 16 decimal places. So upgrading to GDAL 2.1 should solve your issue. If not you can try a higher number of decimal for floating point numbers: -lco SIGNIFICANT_FIGURES=17


3

ST_MakeBox2D already returns a geometry that is a polygon for PostGIS. The right syntax has points in lower left-upper right order but function does not seem to be strict with that. SELECT ST_MakeBox2D( ST_GeomFromText('POINT (0 0)'), ST_GeomFromText('POINT (1 1)')); "BOX(0 0,1 1)" SELECT ST_MakeBox2D( ST_GeomFromText('POINT (1 1)'), ...


2

The invalid GeoJSON object error appears to be a product of your edited code, where the temp variable is actually a string, not a GeoJSON object. From your sample output in the comments, it appears that you are getting an array of GeoJson Polygon objects, which L.geoJson can interpret correctly, so your original code (before the edit) should successfully add ...


2

Assuming that the coordinate system of your points uses meters, you can produce boxes centered around those points with ST_Expand. For example: SELECT ST_AsText(ST_Expand('POINT (0 0)'::geometry, 4)); st_astext -------------------------------------- POLYGON((-4 -4,-4 4,4 4,4 -4,-4 -4))


2

The current implementations of ST_ClusterWithin and its friends ST_ClusterIntersecting and ST_ClusterDBSCAN (PostGIS 2.3) are all Cartesian-based, so they won't work on geographic coordinates. Your best option is to do as @JohnBarça says and transform your coordinates to a planar system in meters. The "private" function _ST_BestSRID might be of some use ...


2

You need to define how the tables included are related. Also, for this purpose you have st_shortestline, that creates the line for you. The syntax is: Select st_shortestline(a.geom, b.geom) From a, b Then you probably want to put some where clause there or you will get all possible combinations between the tables.


2

This can be done a bit more simply with json_build_object in PostgreSQL 9.4+, which lets you build up a JSON by supplying alternating key/value arguments. For example: SELECT json_build_object( 'type', 'Feature', 'id', gid, 'geometry', ST_AsGeoJSON(geom), 'properties', json_build_object( 'feat_type' : feat_type, ...


1

It looks like you have confused the username and the database name. If you created a database called shashi, you should have Database: shashi in the QGIS PostGIS Connection window. Your username is likely postgres. If that doesn't work, look in the message log. My logs are in /usr/local/pgsql/var/, but they may be somewhere else on your machine.


1

I made a test with OSGeo4W version of GDAL gdalinfo --version GDAL 2.0.2, released 2016/01/26 I created a test point in OpenJUMP JML format with one decimal attribute. <?xml version='1.0' encoding='UTF-8'?> <JCSDataFile xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" > ...


1

There is an extension called "Batch save vector Layers". With this tool, you can save multiple files as ESRI Shapefiles in a user defined destination folder. Note that the extension is marked as experimental, but everything works fine for me so far.


1

Cause for this must have been an unstable internet connection (hotspot via Smartphone). One should not try to install various things from the internet (eg. OSGeo4w etc.) at the same time over a weak internet connection. Patience is required here! Second issue went away with reboot and reconnect to the PostgreSQL Database Server. No big deal at all.


1

ST_Difference Returns a geometry that represents that part of geometry A that does not intersect with geometry B. postgis.net/docs/ST_Difference.html


1

First, use only the select and st_astext() to check the results: (adapt to your fields) select test_data_,id_field,test_data_.geom,st_astext(ST_OffsetCurve( test_data_.geom, test_data_.buffer_dis, 'join=mitre mitre_limit=5.0')) If all right then: select test_data_,id_field,test_data_.geom,ST_OffsetCurve( test_data_.geom, test_data_.buffer_dis, ...


1

You can change the getFeatureInfo template used by geoserver, see section "Advanced Formatting". You could try to intercept the ${attribute.rawValue} and print this directly or modify it before sending the feature info back.


1

You are missing a union call and also 0.1 is pretty low for a concave hull, try something like 0.7. (that is really the shrink parameter so 0.1 would be like target to 10% of convexhull area. The smaller the value the longer the processing and more likely you'll run into invalid geometry) SELECT SUM(ST_AREA(ST_CONCAVEHULL(ST_Union(wkb_geometry), ...


1

@> is not a PostGIS bounding box operator. It is a PostgreSQL geometric operator with the box type. So essentially, the query in your question casts the PostGIS bounding box to PostgreSQL box types. Box types are not equivalent to point-in-polygon operators required for your problem. Furthermore, mixing PostGIS types and PostgreSQL geometric types is ...


1

Make a set of unique geometries by deleting duplicates (following the example you have already found - create as a new table). In the new table, create an attribute to uniquely identify each polygon (you could do this as part of step one by adding a serial field). Use the new table to do a spatial join on the original table. this will add the new unique ...


1

I believe you could solve this with a case statement: CASE WHEN st_within(st_centroid(tx_county.geom), puma.geom) AND tx_county.aland <= puma.aland10 THEN 'TRUE' ELSE 'FALSE' END AS "Within" You would need to revise how the tables join, likely using ST_Intersects(puma.geom, tx_county.geom) that way you don't end up with ...


1

Your first statement is correct in what you're trying to achieve - at least testing on my PostgreSQL 9.3 server. Let me explain: The trigger fires BEFORE the changes are applied to the table. In this state, it already has information about the OLD content of the row and the NEW content of the row (i.e. how the row will look like after the changes implied ...


1

probably you are not entering correct password. Please make sure you can access db from pgAdmin. Then use same user/password (copy&paste).


1

It seems the PostGIS version you are using does not provide SFCGAL support. I managed to compile PostGIS 2.2.2 with SFCGAL 1.3.0 support for PostgreSQL 9.5 using following script, which is based on this. You need to get the latest CGAL library first using the PPA given on this webpage. I was facing some 'missing keys errors' on the way I was able to resove ...



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