alphabetasoup
  • Member for 8 years
  • Last seen this week
Import GeoJSON into PostGIS
27 votes

You can use PostGIS's ST_GeomFromGeoJSON to bring in just the geometry part of the GeoJSON. Better yet, you can use ogr2ogr to import the entire JSON document: ogr2ogr -f "PostgreSQL" PG:"dbname=...

View answer
Can a PostGIS table or view have two geometry columns?
Accepted answer
21 votes

You can have many geometry columns. You can name them whatever you want. There is no 'default' geometry. It's just another attribute. That would be like asking which is the default date for a feature ...

View answer
Spatialite spatial queries do not function on GeoPackage
Accepted answer
16 votes

The issue is with the way I am using Spatialite. After talking with the company behind the web service that provides these datasets (since I initially assumed it may have been an export bug), they ...

View answer
What is meant with EPSG:4326 projection
Accepted answer
11 votes

You've got a good grasp of it. EPSG 4326 (i.e. WGS 84) is not a projection. But if you don't associate a projection to this geographic coordinate system, and naively render the coordinates as x/y ...

View answer
Avoid time out error Nominatim Geopy OpenStreetMap
Accepted answer
11 votes

You could make a recursive function. Just typing Python-esque pseudo-code: from geopy.exc import GeocoderTimedOut def do_geocode(address, attempt=1, max_attempts=5): try: return geopy....

View answer
Getting geometries of hurricane's 'cone of uncertainty' using shapely?
Accepted answer
11 votes

Shapely geometries have a convex_hull method. Should be as simple as polygons.convex_hull, but it will work with any Shapely geometry. A note on cyclones as a domain: you should use the input ...

View answer
Transform GeoJSON geometry to WKB
11 votes

Use ST_GeomFromGeoJSON. SELECT ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[[-125045.48351212002,4577567.588141698],[-124816.19981552364,4577552.93014355],[-124765.99472517562,4577419....

View answer
Get latitude and longitude of a geography column
10 votes

This is what ST_DumpPoints is for: SELECT ST_X((dp).geom) AS lon, ST_Y((dp).geom) AS lat FROM ( SELECT ST_DumpPoints( ST_GeogFromText('MULTILINESTRING((-121.382859 41.9831,-121.382849 41....

View answer
Avoiding labeling features if overlapped by another layer in QGIS?
Accepted answer
10 votes

Automated labelling is a really hard problem, but feature geometry is not so bad. Even if you can get placement to work adequately most of the time, there are likely to be exceptions. Some of these ...

View answer
PostGIS equivalent to ArcGIS Select by Location "Are within"
9 votes

This depends a little on whether the small features are dependent on the larger features: do they actually share a common boundary, or are there small discrepancies along their apparently common edges?...

View answer
Calculating mean value of polygon from raster in PostGIS?
Accepted answer
9 votes

Thanks to the comment from Stefan yesterday, I think I can put something together from related questions and the official documentation and offer a range of solutions. PostGIS documentation (...

View answer
Reverse Engineering of Vector tiles and Tiles Security
Accepted answer
8 votes

No, the data is absolutely not secure by virtue of being encoded as vector tiles. Vector tiles are typically PBF data (protocol buffers) in the Mapbox Vector Tile (MVT) specification. (Media type: ...

View answer
Showing only selected features from attribute table on layer using QGIS?
8 votes

Double click on your layer in the table of contents to go to Layer Properties. Go to the general tab (hammer and screwdriver icon). Look for "Feature subset" and enter an expression (perhaps using the ...

View answer
Counting values of each classification code using QGIS
7 votes

If you symbolise a layer by your chosen attribute, and then right click the layer in the list of layers, you can select "Show Feature Count". This will then calculate and display a number ...

View answer
Adding new fields to shapefile alters appearance of borders in QGIS?
7 votes

It is because you are still in editing mode. What you are seeing are little red 'x' symbols over every vertex in your shapefile. Once you have finished with your edit, right-click your layer and ...

View answer
Visualize WKT polygon on a map
Accepted answer
6 votes

Yes. QGIS: the QuickWKT plugin. The description of the tool is as follows: Quick WKT/WKB viewer, this Qgis Plugin opens a dialog where the user can paste (E)WKT and WKB code and see it on the ...

View answer
Creating centerline of polygon using PostGIS?
Accepted answer
6 votes

PostGIS has ST_StraightSkeleton, which implements a polygon thinning algorithm: ST_StraightSkeleton — Compute a straight skeleton from a geometry

View answer
Estimating Area of farm under cultivation using NDVI?
6 votes

Take raster NDVI dataset and use a raster calculator-type function to create a binary surface of 1 and NULL (no data); 1 is where values are between 0.1 and 1; NULL is everything else. For each farm ...

View answer
Rasterio. Pixel value of a point X km away from current point
5 votes

If you're ultimately working toward a polygon (circle) intersection with your raster, there are built-in methods for calculating a numpy mask, given a polygon. You can use this question to see how ...

View answer
Importing QGIS3 processing tools in standalone script
Accepted answer
5 votes

This is an example of getting access to processing to run the QGIS "raster statistics" process, which returns useful information about a raster layer. In particular, raster statistics is useful for ...

View answer
Information about algorithm used by Terrain models
5 votes

There is good documentation on all aspects of GRASS internals, including references to literature. So see the documentation on r.slope.aspect. Unfortunately I find it difficult to get this level of ...

View answer
How to use NOT IN correctly in a WFS CQL attribute filter?
Accepted answer
5 votes

You can successfully use the NOT IN syntax if you are filtering more than one feature. "attribute" NOT IN (1, 2) ← works "attribute" NOT IN (1) ← does not work So I suppose this syntax is limited ...

View answer
PostGIS view has missing features
Accepted answer
5 votes

Your features do not properly intersect; using a series of JOIN statements in the definition of your view meant that not all features of your table_a table were retained in the final view. Using LEFT ...

View answer
Create a raster with fixed 10meter pixel scale in PostGIS
Accepted answer
5 votes

I've found the best way to create a raster feature is to use a template raster. The template raster should have the same extent as the union of the features you want to rasterise, and each pixel the ...

View answer
how can I update linestring on postgis?
Accepted answer
5 votes

You need to use a geometry object, rather than just the text representation. UPDATE roads SET geom = ST_AddPoint(geom, ST_MakePoint(0,0)) WHERE id = 9; That will work if you want to add the point to ...

View answer
basic problem using division in field calculator
5 votes

You need to cast your denominator to a float (decimal) value. See this thread: Why is this field calculator expression evaluated incorrectly when using Python syntax? Your output field also must ...

View answer
Nearest neighbor between point layer and line layer?
5 votes

This is a bit old, but I was searching for solutions to this problem today (point --> line). The simplest solution I've come across for this related problem is: >>> from shapely.geometry ...

View answer
Downsides to saving rasters with NaN as no data values?
Accepted answer
4 votes

Generally, it's a lot better to use NaN. I can think of one reason not to, however. NaN only exists with floating-point data types. So if you need to write out or read a GeoTIFF with integer values (e....

View answer
Having difficulty retrieving city and area names using Geopy (Google V3)
Accepted answer
4 votes

Be careful with your variable names. You're dangerously re-defining the variable c within your list comprehensions. Do this instead: counties = [x['long_name'] for x in c if 'neighborhood' in x['...

View answer
How to host QGIS threejs outputs?
4 votes

Github pages With Github, create a username.github.io repository. Then, for your other repositories, you can create a gh-pages branch. If you have an index.html, you'll be able to navigate to http://...

View answer
1
2 3 4 5