Hot answers tagged

11

Following the advice at the postgis-users maillist it was possible to identify the existence of outdated ligbeos libraries as the source of the problem: $ locate libgeos_c.so /usr/lib/libgeos_c.so /usr/lib/libgeos_c.so.1 /usr/lib/libgeos_c.so.1.8.2 /usr/local/lib/libgeos_c.so /usr/local/lib/libgeos_c.so.1 /usr/local/lib/libgeos_c.so.1.7.1 /usr/local/src/...


10

If you're comfortable with C/C++, GEOS: http://trac.osgeo.org/geos If you're comfortable with C#, NTS: http://code.google.com/p/nettopologysuite/ If you're comfortable with Java, JTS: http://tsusiatsoftware.net/jts/main.html If you're comfortable with Python, shapely: https://github.com/Toblerity/Shapely If you're comfortable with Ruby, ffi-geos: https://...


8

In this case, it looks like you need to help the dissolve tool along by fixing the topology first. Here's how you can do this in GRASS. When you load the shapefile, this is how GRASS sees it: Each cross marks an area. You can see that there are some crosses on the boundary lines: These are the sliver polygons caused by the slight offset between the ...


7

Lazy geometries are not another kind of geometry. This only describes how Geodjango manages to load, instantiate and use geometry objects, and is pretty much like lazy loading in an O/R mapping framework. If you access a whole bunch of geometry data (lets say from a table), geodjango loads them in text based "Well known text" (WKT) format. If you then pick ...


6

As of Shapely version 1.2.14, coordinates are slicable. This looks very similar to GEOSExtractLine, where a subset of the LineString can be extracted. Here are some examples how you can slice coordinates to extract a new line object: from shapely.geometry import LineString, Point # Original LineString used for examples line = LineString([(30, 50), (60, ...


6

Possible error of your geometric operation depends on: overall size of the objects - bigger size increase errors, projection that you use, datum that you use (each datum suits some parts of the Earth more than the others) quality of your data. Generally you don't want to work with unprojected data at all unless there is some specific reasons like ...


5

Ok, got this working - and feel like putting the long answer here, as it has a lot of useful GEOS example bits in it. Here we go. Warnings I haven't compiled this - I stripped out a load of project specific stuff and replaced it with a simple Point class which probably needs a copy/assignment operator. But it worked before I did that. I'm not sure this ...


5

Haven't tried, but found a tweet that looks promising https://mobile.twitter.com/JCSanford/status/281540051203141632 Seems like the concept of "buildpack" is a way to get things loaded on Heroku, and someone has made GEOS iavailable as a buildpack. By setting a custom geos-path you can install Shapely via pip and it will find GEOS.


4

No need to clone any geometries. Also, iterate over geometries[1:] to save one Union(). If osgeo.ogr has something like Shapely's cascaded_union use that instead of accumulating unions in a loop.


4

I used the 2to3 tool (see geographika's answer) to convert Shapely-1.2.13 and then manually had to change 3 lines of code to handle Python 3.x's explicit handling of string and byte encoding. I have put this as a separate answer just for clarity and in case anybody else needs to do the same here are the lines I manually changed: \geos.py (line 97) old: v ...


4

Use GRASS GIS command v.dissolve (in Sextante plugin -> GRASS Commands -> Vector) If I quickly reproduce you example: The result with v.dissolve: Explanation The problem is easy to understand. A shapefile has no topology, if two areas shared a common border that border would be digitized two times and also stored in duplicate. You see this clearly ...


4

You can use Select By Location and then switch the selection by right clicking the layer that has the selection and choosing "Selection" and then "Switch Selection". The image shows something similar to how you might select the points that are identical. The final step would be to export the selection that remains after the switch by right-clicking the layer ...


4

If you inverse the coordinates, it does not work (geopy uses (latitude,longitude) in the WGS84 crs) dublin = (53.33306,-6.24889) liverpool = ( 53.41058,-2.97794) print distance(dublin, liverpool).km 217.863019038 print(vincenty(dublin, liverpool).kilometers) 217.863019038 print(great_circle(dublin, liverpool).kilometers) 217.211596704 GEOS (...


3

In my experience using Ubuntu with GIS products will not be problematic. But you should try to keep to Long Term Support (LTS) versions of Ubuntu. The reasons are among others: Cutting edge versions of Ubuntu tend to have fewer compiled versions of GIS-software (both desktop and server) LTS releases are designed to be stable platforms that you can stick ...


3

I had the same problem, and here is how I solved it: The problem lies in PolygonBuilder.cpp within the libgeos library. The line causing the problem has actually been fixed already, but the fix is not in the current ubuntu/debian repository that is installed via apt-get. Details of the change can be found here. I downloaded the libgeos from github and ...


3

In regards to Shapely and Python 3.2: We're not yet testing or deploying Shapely on Python 3 + Windows. There's probably some non-conforming code in the shapely.geometry.geo module that prevents its import. June, 2011 - http://old.nabble.com/Shapely-package-installation-td31879542.html So you could try getting the Shapely source from GitHub and ...


3

The only way I could get POSTGis on "Trusty" was to build from Sources, here is what I used .. sudo mkdir postgis-build cd postgis-build ------------------------------------------------------ then put the script below in a shell script file sudo nano build.sh make it executable and run it sudo chmod a+x build.sh -----------------------------------------...


3

Yes, if you want ST_Area() on a bare geometry to return a planar area, you need to use an area-preserving CRS. GEOS is not magic, it just works in whatever units are handed to it, assuming cartesian math, so the expectation in a planar CRS if you want useful areas/lengths etc.


3

Why with Geos? I've used pygc (based on Spheroid) for another Python solution (excerpt below) from pygc import great_circle # New point from initial point, distance, and azimuth great_circle(distance=111000, azimuth=65, latitude=30, longitude=-74) {'latitude': 30.41900364921926, 'longitude': -72.952930949727573, 'reverse_azimuth': 245.52686122611451} ...


2

I think you have incompatible spatialite and geos packages. In particular, it looks like you have an earlier version of geos installed than 3.3.5. Is it possible you have a distro package and a self-compiled version as well?


2

I would use org2ogr to do the reprojection of each file and wrap the command line in a for loop. #!/bin/bash for i in *.shp do x=`basename $i .shp` outfile = ${x}_eqa.shp ogr2ogr -t_srs epsg:xxxx $outfile $i done You'll need to go to spatialreference.org to look up a relevant epsg code for an equal area projection for your region if you don't ...


2

I would perform both a left and right single-sided offset buffer on one of the linestrings and test if the other linestring crosses both sides of the offset buffer. You would need to use a suitable small buffer distance for your analysis. For example, using Shapely: from shapely.wkt import loads def actually_crosses(A, B, precis=0.0001): """A hybrid ...


2

You also install them using pip. You'll have to specify a requirements.txt file though. It's basically just a text file where you list the Python libraries you want to install. Just put the text file on the root of your repository. Once it's there, you can just run pip like so: $pip install -r requirements.txt Here's an example requirements.txt file ...


2

Christian, you can't have your circle center and point in long,lat space and have R with mile units. Computational geometry algorithms require you to choose one coordinate system. Latitude and longitude is not a good one to work in, by the way unless your objects are very small in extent. After you transform your points to a local coordinate system and scale ...


2

You can use the distance_lte function in geodjango to check if your point is in a circle or not. It is the same as ST_Distance method in PostGIS. The method which I have mentioned is drawing a 5 meter radius of a circle to find points from Zipcode models. Returns models where the distance to the geometry field from the lookup geometry is less than or ...


2

I'd suggest picking up on using Python with the Rtree and shapely modules. Rtree uses an R-tree index, which can be used to very quickly a point to be contained in a bounding-box of what you describe as a zone, then shapely can check to see if the point is actually within the polygon of each zone (rather than just within the bbox). Shapely uses GEOS library ...


2

If you don't want to build from source we have a public repository of packages for CartoDB for both lucid and precise. Maybe precise packages will work in 13.xx. https://launchpad.net/~cartodb


2

The points being returned to you by Google Maps are in lat/lng, which almost always these days means SRID=4326. So change your geometry SRID in your PostGIS table to that: location = geos.Point(data['lng'], data['lat'], srid=4326) Then, when displaying points on a web map the projection of the map is commonly set to the Spherical Mercator coordinate ...


2

It's not a bug, more like a strategic laziness. 1.X versions of PostGIS only supported GEOMETRYCOLLECTION EMPTY, not other forms of empty. For 2.X I (perhaps foolishly) embraced the full variety of nothings. The result is a not-entirely-complete support of varieties of nothing, made slightly ill-formed by the fact that support libraries like GEOS have their ...


2

This doesn't answer your question directly - Mapperz has probably pointed you in the right direction. But I recommend using the UbuntuGIS package(s) as they've proven to be e-a-s-y to install and all the dependencies are there. # UbuntuGIS package: sudo apt-add-repository ppa:ubuntugis/ppa sudo apt-get update #or for bleeding edge: sudo add-apt-...



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